Search in sources :

Example 71 with ActionBar

use of androidx.appcompat.app.ActionBar in project zxing-android-embedded by journeyapps.

the class TabbedScanning method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tabbed_scanning);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOffscreenPageLimit(0);
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });
    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}
Also used : ViewPager(androidx.viewpager.widget.ViewPager) ActionBar(androidx.appcompat.app.ActionBar)

Example 72 with ActionBar

use of androidx.appcompat.app.ActionBar in project Conversations by siacs.

the class ConversationsActivity method invalidateActionBarTitle.

private void invalidateActionBarTitle() {
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar == null) {
        return;
    }
    final FragmentManager fragmentManager = getFragmentManager();
    final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment);
    if (mainFragment instanceof ConversationFragment) {
        final Conversation conversation = ((ConversationFragment) mainFragment).getConversation();
        if (conversation != null) {
            actionBar.setTitle(EmojiWrapper.transform(conversation.getName()));
            actionBar.setDisplayHomeAsUpEnabled(true);
            ActionBarUtil.setActionBarOnClickListener(binding.toolbar, (v) -> openConversationDetails(conversation));
            return;
        }
    }
    actionBar.setTitle(R.string.app_name);
    actionBar.setDisplayHomeAsUpEnabled(false);
    ActionBarUtil.resetActionBarOnClickListeners(binding.toolbar);
}
Also used : FragmentManager(android.app.FragmentManager) Conversation(eu.siacs.conversations.entities.Conversation) Fragment(android.app.Fragment) ActionBar(androidx.appcompat.app.ActionBar)

Example 73 with ActionBar

use of androidx.appcompat.app.ActionBar in project Conversations by siacs.

the class EditAccountActivity method updateAccountInformation.

private void updateAccountInformation(boolean init) {
    if (init) {
        this.binding.accountJid.getEditableText().clear();
        if (mUsernameMode) {
            this.binding.accountJid.getEditableText().append(this.mAccount.getJid().getEscapedLocal());
        } else {
            this.binding.accountJid.getEditableText().append(this.mAccount.getJid().asBareJid().toEscapedString());
        }
        this.binding.accountPassword.getEditableText().clear();
        this.binding.accountPassword.getEditableText().append(this.mAccount.getPassword());
        this.binding.hostname.setText("");
        this.binding.hostname.getEditableText().append(this.mAccount.getHostname());
        this.binding.port.setText("");
        this.binding.port.getEditableText().append(String.valueOf(this.mAccount.getPort()));
        this.binding.namePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE);
    }
    if (!mInitMode && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        this.binding.accountPassword.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
    }
    final boolean editable = !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY) && !mAccount.isOptionSet(Account.OPTION_FIXED_USERNAME) && QuickConversationsService.isConversations();
    this.binding.accountJid.setEnabled(editable);
    this.binding.accountJid.setFocusable(editable);
    this.binding.accountJid.setFocusableInTouchMode(editable);
    this.binding.accountJid.setCursorVisible(editable);
    final String displayName = mAccount.getDisplayName();
    updateDisplayName(displayName);
    final boolean togglePassword = mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) || !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY);
    final boolean editPassword = !mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) || (!mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY) && QuickConversationsService.isConversations()) || mAccount.getLastErrorStatus() == Account.State.UNAUTHORIZED;
    this.binding.accountPasswordLayout.setPasswordVisibilityToggleEnabled(togglePassword);
    this.binding.accountPassword.setFocusable(editPassword);
    this.binding.accountPassword.setFocusableInTouchMode(editPassword);
    this.binding.accountPassword.setCursorVisible(editPassword);
    this.binding.accountPassword.setEnabled(editPassword);
    if (!mInitMode) {
        this.binding.avater.setVisibility(View.VISIBLE);
        AvatarWorkerTask.loadAvatar(mAccount, binding.avater, R.dimen.avatar_on_details_screen_size);
    } else {
        this.binding.avater.setVisibility(View.GONE);
    }
    this.binding.accountRegisterNew.setChecked(this.mAccount.isOptionSet(Account.OPTION_REGISTER));
    if (this.mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE)) {
        if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) {
            ActionBar actionBar = getSupportActionBar();
            if (actionBar != null) {
                actionBar.setTitle(R.string.create_account);
            }
        }
        this.binding.accountRegisterNew.setVisibility(View.GONE);
    } else if (this.mAccount.isOptionSet(Account.OPTION_REGISTER) && mForceRegister == null) {
        this.binding.accountRegisterNew.setVisibility(View.VISIBLE);
    } else {
        this.binding.accountRegisterNew.setVisibility(View.GONE);
    }
    if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) {
        Features features = this.mAccount.getXmppConnection().getFeatures();
        this.binding.stats.setVisibility(View.VISIBLE);
        boolean showBatteryWarning = !xmppConnectionService.getPushManagementService().available(mAccount) && isOptimizingBattery();
        boolean showDataSaverWarning = isAffectedByDataSaver();
        showOsOptimizationWarning(showBatteryWarning, showDataSaverWarning);
        this.binding.sessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection().getLastSessionEstablished()));
        if (features.rosterVersioning()) {
            this.binding.serverInfoRosterVersion.setText(R.string.server_info_available);
        } else {
            this.binding.serverInfoRosterVersion.setText(R.string.server_info_unavailable);
        }
        if (features.carbons()) {
            this.binding.serverInfoCarbons.setText(R.string.server_info_available);
        } else {
            this.binding.serverInfoCarbons.setText(R.string.server_info_unavailable);
        }
        if (features.mam()) {
            this.binding.serverInfoMam.setText(R.string.server_info_available);
        } else {
            this.binding.serverInfoMam.setText(R.string.server_info_unavailable);
        }
        if (features.csi()) {
            this.binding.serverInfoCsi.setText(R.string.server_info_available);
        } else {
            this.binding.serverInfoCsi.setText(R.string.server_info_unavailable);
        }
        if (features.blocking()) {
            this.binding.serverInfoBlocking.setText(R.string.server_info_available);
        } else {
            this.binding.serverInfoBlocking.setText(R.string.server_info_unavailable);
        }
        if (features.sm()) {
            this.binding.serverInfoSm.setText(R.string.server_info_available);
        } else {
            this.binding.serverInfoSm.setText(R.string.server_info_unavailable);
        }
        if (features.externalServiceDiscovery()) {
            this.binding.serverInfoExternalService.setText(R.string.server_info_available);
        } else {
            this.binding.serverInfoExternalService.setText(R.string.server_info_unavailable);
        }
        if (features.pep()) {
            AxolotlService axolotlService = this.mAccount.getAxolotlService();
            if (axolotlService != null && axolotlService.isPepBroken()) {
                this.binding.serverInfoPep.setText(R.string.server_info_broken);
            } else if (features.pepPublishOptions() || features.pepOmemoWhitelisted()) {
                this.binding.serverInfoPep.setText(R.string.server_info_available);
            } else {
                this.binding.serverInfoPep.setText(R.string.server_info_partial);
            }
        } else {
            this.binding.serverInfoPep.setText(R.string.server_info_unavailable);
        }
        if (features.httpUpload(0)) {
            final long maxFileSize = features.getMaxHttpUploadSize();
            if (maxFileSize > 0) {
                this.binding.serverInfoHttpUpload.setText(UIHelper.filesizeToString(maxFileSize));
            } else {
                this.binding.serverInfoHttpUpload.setText(R.string.server_info_available);
            }
        } else {
            this.binding.serverInfoHttpUpload.setText(R.string.server_info_unavailable);
        }
        this.binding.pushRow.setVisibility(xmppConnectionService.getPushManagementService().isStub() ? View.GONE : View.VISIBLE);
        if (xmppConnectionService.getPushManagementService().available(mAccount)) {
            this.binding.serverInfoPush.setText(R.string.server_info_available);
        } else {
            this.binding.serverInfoPush.setText(R.string.server_info_unavailable);
        }
        final long pgpKeyId = this.mAccount.getPgpId();
        if (pgpKeyId != 0 && Config.supportOpenPgp()) {
            OnClickListener openPgp = view -> launchOpenKeyChain(pgpKeyId);
            OnClickListener delete = view -> showDeletePgpDialog();
            this.binding.pgpFingerprintBox.setVisibility(View.VISIBLE);
            this.binding.pgpFingerprint.setText(OpenPgpUtils.convertKeyIdToHex(pgpKeyId));
            this.binding.pgpFingerprint.setOnClickListener(openPgp);
            if ("pgp".equals(messageFingerprint)) {
                this.binding.pgpFingerprintDesc.setTextAppearance(this, R.style.TextAppearance_Conversations_Caption_Highlight);
            }
            this.binding.pgpFingerprintDesc.setOnClickListener(openPgp);
            this.binding.actionDeletePgp.setOnClickListener(delete);
        } else {
            this.binding.pgpFingerprintBox.setVisibility(View.GONE);
        }
        final String ownAxolotlFingerprint = this.mAccount.getAxolotlService().getOwnFingerprint();
        if (ownAxolotlFingerprint != null && Config.supportOmemo()) {
            this.binding.axolotlFingerprintBox.setVisibility(View.VISIBLE);
            if (ownAxolotlFingerprint.equals(messageFingerprint)) {
                this.binding.ownFingerprintDesc.setTextAppearance(this, R.style.TextAppearance_Conversations_Caption_Highlight);
                this.binding.ownFingerprintDesc.setText(R.string.omemo_fingerprint_selected_message);
            } else {
                this.binding.ownFingerprintDesc.setTextAppearance(this, R.style.TextAppearance_Conversations_Caption);
                this.binding.ownFingerprintDesc.setText(R.string.omemo_fingerprint);
            }
            this.binding.axolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(ownAxolotlFingerprint.substring(2)));
            this.binding.actionCopyAxolotlToClipboard.setVisibility(View.VISIBLE);
            this.binding.actionCopyAxolotlToClipboard.setOnClickListener(v -> copyOmemoFingerprint(ownAxolotlFingerprint));
        } else {
            this.binding.axolotlFingerprintBox.setVisibility(View.GONE);
        }
        boolean hasKeys = false;
        binding.otherDeviceKeys.removeAllViews();
        for (XmppAxolotlSession session : mAccount.getAxolotlService().findOwnSessions()) {
            if (!session.getTrust().isCompromised()) {
                boolean highlight = session.getFingerprint().equals(messageFingerprint);
                addFingerprintRow(binding.otherDeviceKeys, session, highlight);
                hasKeys = true;
            }
        }
        if (hasKeys && Config.supportOmemo()) {
            // TODO: either the button should be visible if we print an active device or the device list should be fed with reactived devices
            this.binding.otherDeviceKeysCard.setVisibility(View.VISIBLE);
            Set<Integer> otherDevices = mAccount.getAxolotlService().getOwnDeviceIds();
            if (otherDevices == null || otherDevices.isEmpty()) {
                binding.clearDevices.setVisibility(View.GONE);
            } else {
                binding.clearDevices.setVisibility(View.VISIBLE);
            }
        } else {
            this.binding.otherDeviceKeysCard.setVisibility(View.GONE);
        }
    } else {
        final TextInputLayout errorLayout;
        if (this.mAccount.errorStatus()) {
            if (this.mAccount.getStatus() == Account.State.UNAUTHORIZED || this.mAccount.getStatus() == Account.State.DOWNGRADE_ATTACK) {
                errorLayout = this.binding.accountPasswordLayout;
            } else if (mShowOptions && this.mAccount.getStatus() == Account.State.SERVER_NOT_FOUND && this.binding.hostname.getText().length() > 0) {
                errorLayout = this.binding.hostnameLayout;
            } else {
                errorLayout = this.binding.accountJidLayout;
            }
            errorLayout.setError(getString(this.mAccount.getStatus().getReadableId()));
            if (init || !accountInfoEdited()) {
                errorLayout.requestFocus();
            }
        } else {
            errorLayout = null;
        }
        removeErrorsOnAllBut(errorLayout);
        this.binding.stats.setVisibility(View.GONE);
        this.binding.otherDeviceKeysCard.setVisibility(View.GONE);
    }
}
Also used : PendingItem(eu.siacs.conversations.ui.util.PendingItem) Arrays(java.util.Arrays) OnCaptchaRequested(eu.siacs.conversations.services.XmppConnectionService.OnCaptchaRequested) Bundle(android.os.Bundle) KeyChain(android.security.KeyChain) SoftKeyboardUtils(eu.siacs.conversations.ui.util.SoftKeyboardUtils) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) ImageView(android.widget.ImageView) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) PendingIntent(android.app.PendingIntent) ActionBar(androidx.appcompat.app.ActionBar) MenuDoubleTabUtil(eu.siacs.conversations.ui.util.MenuDoubleTabUtil) CheckBox(android.widget.CheckBox) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Handler(android.os.Handler) SignupUtils(eu.siacs.conversations.utils.SignupUtils) View(android.view.View) PreferenceManager(android.preference.PreferenceManager) Resolver(eu.siacs.conversations.utils.Resolver) Log(android.util.Log) AvatarWorkerTask(eu.siacs.conversations.ui.util.AvatarWorkerTask) DataBindingUtil(androidx.databinding.DataBindingUtil) XmppConnection(eu.siacs.conversations.xmpp.XmppConnection) KeyChainAliasCallback(android.security.KeyChainAliasCallback) Set(java.util.Set) XmppAxolotlSession(eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession) List(java.util.List) TextView(android.widget.TextView) ActivityNotFoundException(android.content.ActivityNotFoundException) OnUpdateBlocklist(eu.siacs.conversations.xmpp.OnUpdateBlocklist) HttpUrl(okhttp3.HttpUrl) TextWatcher(android.text.TextWatcher) Config(eu.siacs.conversations.Config) AlertDialog(androidx.appcompat.app.AlertDialog) PresenceTemplateAdapter(eu.siacs.conversations.ui.adapter.PresenceTemplateAdapter) Builder(androidx.appcompat.app.AlertDialog.Builder) TextInputLayout(com.google.android.material.textfield.TextInputLayout) DialogPresenceBinding(eu.siacs.conversations.databinding.DialogPresenceBinding) OnKeyStatusUpdated(eu.siacs.conversations.xmpp.OnKeyStatusUpdated) PresenceTemplate(eu.siacs.conversations.entities.PresenceTemplate) Features(eu.siacs.conversations.xmpp.XmppConnection.Features) Intent(android.content.Intent) Account(eu.siacs.conversations.entities.Account) Element(eu.siacs.conversations.xml.Element) Editable(android.text.Editable) MenuItem(android.view.MenuItem) ActivityEditAccountBinding(eu.siacs.conversations.databinding.ActivityEditAccountBinding) CryptoHelper(eu.siacs.conversations.utils.CryptoHelper) IntentSender(android.content.IntentSender) Presence(eu.siacs.conversations.entities.Presence) Toast(android.widget.Toast) Menu(android.view.Menu) UIHelper(eu.siacs.conversations.utils.UIHelper) Settings(android.provider.Settings) AxolotlService(eu.siacs.conversations.crypto.axolotl.AxolotlService) Build(android.os.Build) KnownHostsAdapter(eu.siacs.conversations.ui.adapter.KnownHostsAdapter) Avatar(eu.siacs.conversations.xmpp.pep.Avatar) R(eu.siacs.conversations.R) QuickConversationsService(eu.siacs.conversations.services.QuickConversationsService) CharMatcher(com.google.common.base.CharMatcher) TextUtils(android.text.TextUtils) Data(eu.siacs.conversations.xmpp.forms.Data) BarcodeProvider(eu.siacs.conversations.services.BarcodeProvider) XmppConnectionService(eu.siacs.conversations.services.XmppConnectionService) TorServiceUtils(eu.siacs.conversations.utils.TorServiceUtils) SharedPreferences(android.content.SharedPreferences) Bitmap(android.graphics.Bitmap) OnAccountUpdate(eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate) Activity(android.app.Activity) XmppUri(eu.siacs.conversations.utils.XmppUri) EditText(android.widget.EditText) Jid(eu.siacs.conversations.xmpp.Jid) OnClickListener(android.view.View.OnClickListener) OpenPgpUtils(org.openintents.openpgp.util.OpenPgpUtils) XmppAxolotlSession(eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AxolotlService(eu.siacs.conversations.crypto.axolotl.AxolotlService) OnClickListener(android.view.View.OnClickListener) Features(eu.siacs.conversations.xmpp.XmppConnection.Features) TextInputLayout(com.google.android.material.textfield.TextInputLayout) ActionBar(androidx.appcompat.app.ActionBar)

Example 74 with ActionBar

use of androidx.appcompat.app.ActionBar in project Conversations by siacs.

the class ChooseContactActivity method onStart.

@Override
public void onStart() {
    super.onStart();
    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        try {
            bar.setTitle(getTitleFromIntent());
        } catch (Exception e) {
            bar.setTitle(R.string.title_activity_choose_contact);
        }
    }
}
Also used : ActionBar(androidx.appcompat.app.ActionBar)

Example 75 with ActionBar

use of androidx.appcompat.app.ActionBar in project Douya by DreaminginCodeZH.

the class WebViewActivity method updateToolbarTitleAndSubtitle.

private void updateToolbarTitleAndSubtitle() {
    String url = mWebView.getUrl();
    if (TextUtils.isEmpty(url)) {
        return;
    }
    if (TextUtils.isEmpty(mTitleOrError)) {
        mTitleOrError = Uri.parse(url).getHost();
    }
    ActionBar actionBar = getSupportActionBar();
    if (TextUtils.isEmpty(actionBar.getSubtitle())) {
        mToolbar.setTitleTextAppearance(mToolbar.getContext(), R.style.TextAppearance_Widget_Douya_Toolbar_Title_WebView);
        mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), R.style.TextAppearance_Widget_Douya_Toolbar_Subtitle_WebView);
    }
    setTitle(mTitleOrError);
    if (Settings.CREATE_NEW_TASK_FOR_WEBVIEW.getValue()) {
        AppUtils.setTaskDescriptionLabel(this, mTitleOrError);
    }
    actionBar.setSubtitle(url);
}
Also used : ActionBar(androidx.appcompat.app.ActionBar)

Aggregations

ActionBar (androidx.appcompat.app.ActionBar)139 View (android.view.View)30 Toolbar (androidx.appcompat.widget.Toolbar)29 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)26 TextView (android.widget.TextView)18 Intent (android.content.Intent)11 Bundle (android.os.Bundle)11 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)8 SuppressLint (android.annotation.SuppressLint)7 AdapterView (android.widget.AdapterView)7 ImageView (android.widget.ImageView)7 Uri (android.net.Uri)6 DefaultItemDecoration (com.yanzhenjie.recyclerview.widget.DefaultItemDecoration)6 SharedPreferences (android.content.SharedPreferences)5 ListView (android.widget.ListView)5 Spinner (android.widget.Spinner)5 Typeface (com.mta.tehreer.graphics.Typeface)5 File (java.io.File)5 MenuItem (android.view.MenuItem)4 Button (android.widget.Button)4