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));
}
}
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);
}
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);
}
}
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);
}
}
}
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);
}
Aggregations