From f2885575bacda63ab39a36af56fa535a16ccbe42 Mon Sep 17 00:00:00 2001 From: Harshit Bansal Date: Sun, 18 Mar 2018 14:00:22 +0530 Subject: [PATCH] replace deprecated action bar with toolbar (#2872) * replace deprecated action bar with toolbar * add toolbar support in each activity * remove redundant themes made earlier * add configure action bar method in xmpp activity * remove android namespace from actionmodeoverlay * solve bug of scrolling toolbar --- .../siacs/conversations/ui/AboutActivity.java | 4 + .../AbstractSearchableListItemActivity.java | 3 + .../ui/ChangePasswordActivity.java | 2 + .../ui/ConferenceDetailsActivity.java | 7 +- .../ui/ContactDetailsActivity.java | 7 +- .../ui/ConversationsActivity.java | 3 + .../conversations/ui/EditAccountActivity.java | 3 + .../conversations/ui/MagicCreateActivity.java | 2 + .../ui/ManageAccountActivity.java | 3 +- .../conversations/ui/MemorizingActivity.java | 4 +- .../ui/PublishProfilePictureActivity.java | 3 + .../conversations/ui/SettingsActivity.java | 11 +- .../ui/ShareViaAccountActivity.java | 3 +- .../conversations/ui/ShareWithActivity.java | 5 +- .../ui/StartConversationActivity.java | 61 ++- .../conversations/ui/TrustKeysActivity.java | 8 +- .../conversations/ui/UriHandlerActivity.java | 2 + .../conversations/ui/WelcomeActivity.java | 1 + .../siacs/conversations/ui/XmppActivity.java | 13 +- .../layout-w945dp/activity_conversations.xml | 32 +- src/main/res/layout/activity_about.xml | 23 +- .../res/layout/activity_change_password.xml | 3 + .../res/layout/activity_choose_contact.xml | 37 +- .../res/layout/activity_contact_details.xml | 297 ++++++------ .../res/layout/activity_conversations.xml | 20 +- src/main/res/layout/activity_edit_account.xml | 5 +- .../res/layout/activity_manage_accounts.xml | 5 +- src/main/res/layout/activity_muc_details.xml | 425 +++++++++--------- .../activity_publish_profile_picture.xml | 10 +- src/main/res/layout/activity_settings.xml | 12 + src/main/res/layout/activity_share_with.xml | 6 +- .../layout/activity_start_conversation.xml | 27 +- src/main/res/layout/activity_trust_keys.xml | 10 +- src/main/res/layout/magic_create.xml | 168 +++---- src/main/res/layout/toolbar.xml | 11 + src/main/res/layout/welcome.xml | 155 ++++--- src/main/res/values/themes.xml | 8 +- 37 files changed, 772 insertions(+), 627 deletions(-) create mode 100644 src/main/res/layout/activity_settings.xml create mode 100644 src/main/res/layout/toolbar.xml diff --git a/src/main/java/eu/siacs/conversations/ui/AboutActivity.java b/src/main/java/eu/siacs/conversations/ui/AboutActivity.java index f132d8e06..f5ac23654 100644 --- a/src/main/java/eu/siacs/conversations/ui/AboutActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/AboutActivity.java @@ -6,6 +6,8 @@ import android.support.v7.app.AppCompatActivity; import eu.siacs.conversations.R; +import static eu.siacs.conversations.ui.XmppActivity.configureActionBar; + public class AboutActivity extends AppCompatActivity { @Override @@ -18,5 +20,7 @@ public class AboutActivity extends AppCompatActivity { setTheme(mTheme); setContentView(R.layout.activity_about); + setSupportActionBar(findViewById(R.id.toolbar)); + configureActionBar(getSupportActionBar()); } } diff --git a/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java b/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java index d05de8f3c..bafcac0ea 100644 --- a/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/AbstractSearchableListItemActivity.java @@ -3,6 +3,7 @@ package eu.siacs.conversations.ui; import android.content.Context; import android.databinding.DataBindingUtil; import android.os.Bundle; +import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.view.Menu; @@ -95,6 +96,8 @@ public abstract class AbstractSearchableListItemActivity extends XmppActivity { public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.binding = DataBindingUtil.setContentView(this,R.layout.activity_choose_contact); + setSupportActionBar((Toolbar) binding.toolbar); + configureActionBar(getSupportActionBar()); this.binding.chooseContactList.setFastScrollEnabled(true); mListItemsAdapter = new ListItemAdapter(this, listItems); this.binding.chooseContactList.setAdapter(mListItemsAdapter); diff --git a/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java index 639ed2045..4f6245c12 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java @@ -60,6 +60,8 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_change_password); + setSupportActionBar(findViewById(R.id.toolbar)); + configureActionBar(getSupportActionBar()); Button mCancelButton = findViewById(R.id.left_button); mCancelButton.setOnClickListener(view -> finish()); this.mChangePasswordButton = findViewById(R.id.right_button); diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index cd4441651..dd1720268 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -11,6 +11,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; +import android.support.v7.widget.Toolbar; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.Menu; @@ -226,10 +227,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.binding.mucMoreDetails.setVisibility(View.GONE); this.binding.changeConferenceButton.setOnClickListener(this.mChangeConferenceSettings); this.binding.invite.setOnClickListener(inviteListener); - if (getSupportActionBar() != null) { - getSupportActionBar().setHomeButtonEnabled(true); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + setSupportActionBar((Toolbar) binding.toolbar); + configureActionBar(getSupportActionBar()); this.binding.editNickButton.setOnClickListener(v -> quickEdit(mConversation.getMucOptions().getActualNick(), 0, value -> { diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index 8c28fd16c..26a5f09d5 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -12,6 +12,7 @@ import android.provider.ContactsContract.CommonDataKinds; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents; import android.support.v4.content.ContextCompat; +import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -190,10 +191,8 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp this.messageFingerprint = getIntent().getStringExtra("fingerprint"); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_contact_details); - if (getSupportActionBar() != null) { - getSupportActionBar().setHomeButtonEnabled(true); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + setSupportActionBar((Toolbar) binding.toolbar); + configureActionBar(getSupportActionBar()); binding.showInactiveDevices.setOnClickListener(v -> { showInactiveOmemo = !showInactiveOmemo; populateView(); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java index 4a04b931e..804ca9b4a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java @@ -48,6 +48,7 @@ import android.support.annotation.IdRes; import android.support.annotation.NonNull; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; +import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; import android.view.MenuItem; @@ -364,6 +365,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio super.onCreate(savedInstanceState); new EmojiService(this).init(); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations); + setSupportActionBar((Toolbar) binding.toolbar); + configureActionBar(getSupportActionBar()); this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle); this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview); this.initializeFragments(); diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index d78fcd17e..853d23669 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -20,6 +20,7 @@ import android.support.design.widget.TextInputLayout; import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog.Builder; +import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; @@ -536,6 +537,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat this.mSavedInstanceInit = savedInstanceState.getBoolean("initMode", false); } this.binding = DataBindingUtil.setContentView(this, R.layout.activity_edit_account); + setSupportActionBar((Toolbar) binding.toolbar); + configureActionBar(getSupportActionBar()); binding.accountJid.addTextChangedListener(this.mTextWatcher); binding.accountJid.setOnFocusChangeListener(this.mEditTextFocusListener); this.mAccountJidLayout = (TextInputLayout) findViewById(R.id.account_jid_layout); diff --git a/src/main/java/eu/siacs/conversations/ui/MagicCreateActivity.java b/src/main/java/eu/siacs/conversations/ui/MagicCreateActivity.java index 532719053..f210e0adc 100644 --- a/src/main/java/eu/siacs/conversations/ui/MagicCreateActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/MagicCreateActivity.java @@ -53,6 +53,8 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher { } super.onCreate(savedInstanceState); setContentView(R.layout.magic_create); + setSupportActionBar(findViewById(R.id.toolbar)); + configureActionBar(getSupportActionBar()); mFullJidDisplay = findViewById(R.id.full_jid); mUsername = findViewById(R.id.username); mRandom = new SecureRandom(); diff --git a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java index 17340434a..66c693e0c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java @@ -74,7 +74,8 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda super.onCreate(savedInstanceState); setContentView(R.layout.activity_manage_accounts); - + setSupportActionBar(findViewById(R.id.toolbar)); + configureActionBar(getSupportActionBar()); if (savedInstanceState != null) { String jid = savedInstanceState.getString(STATE_SELECTED_ACCOUNT); if (jid != null) { diff --git a/src/main/java/eu/siacs/conversations/ui/MemorizingActivity.java b/src/main/java/eu/siacs/conversations/ui/MemorizingActivity.java index c0407054b..7ff8605b3 100644 --- a/src/main/java/eu/siacs/conversations/ui/MemorizingActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/MemorizingActivity.java @@ -41,7 +41,7 @@ import eu.siacs.conversations.R; import eu.siacs.conversations.entities.MTMDecision; import eu.siacs.conversations.services.MemorizingTrustManager; -public class MemorizingActivity extends AppCompatActivity implements OnClickListener,OnCancelListener { +public class MemorizingActivity extends AppCompatActivity implements OnClickListener, OnCancelListener { private final static Logger LOGGER = Logger.getLogger(MemorizingActivity.class.getName()); @@ -54,6 +54,8 @@ public class MemorizingActivity extends AppCompatActivity implements OnClickList LOGGER.log(Level.FINE, "onCreate"); setTheme(findTheme()); super.onCreate(savedInstanceState); + getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content)); + setSupportActionBar(findViewById(R.id.toolbar)); } @Override diff --git a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java index 9e94a2097..26c305fb2 100644 --- a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java @@ -94,6 +94,9 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_publish_profile_picture); + setSupportActionBar(findViewById(R.id.toolbar)); + configureActionBar(getSupportActionBar()); + this.avatar = findViewById(R.id.account_image); this.cancelButton = findViewById(R.id.cancel_button); this.publishButton = findViewById(R.id.publish_button); diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index bc3f99e6c..4913b2231 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -19,6 +19,8 @@ import android.preference.PreferenceManager; import android.preference.PreferenceScreen; import android.provider.MediaStore; import android.util.Log; +import android.view.View; +import android.view.ViewGroup; import android.widget.Toast; import java.io.File; @@ -57,18 +59,19 @@ public class SettingsActivity extends XmppActivity implements @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.activity_settings); FragmentManager fm = getFragmentManager(); - mSettingsFragment = (SettingsFragment) fm.findFragmentById(android.R.id.content); + mSettingsFragment = (SettingsFragment) fm.findFragmentById(R.id.settings_content); if (mSettingsFragment == null || !mSettingsFragment.getClass().equals(SettingsFragment.class)) { mSettingsFragment = new SettingsFragment(); - fm.beginTransaction().replace(android.R.id.content, mSettingsFragment).commit(); + fm.beginTransaction().replace(R.id.settings_content, mSettingsFragment).commit(); } mSettingsFragment.setActivityIntent(getIntent()); - this.mTheme = findTheme(); setTheme(this.mTheme); getWindow().getDecorView().setBackgroundColor(Color.get(this, R.attr.color_background_primary)); - + setSupportActionBar(findViewById(R.id.toolbar)); + configureActionBar(getSupportActionBar()); } @Override diff --git a/src/main/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java index af84a5f27..1035c766e 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareViaAccountActivity.java @@ -43,7 +43,8 @@ public class ShareViaAccountActivity extends XmppActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_manage_accounts); - + setSupportActionBar(findViewById(R.id.toolbar)); + configureActionBar(getSupportActionBar()); accountListView = (ListView) findViewById(R.id.account_list); this.mAccountAdapter = new AccountAdapter(this, accountList, false); accountListView.setAdapter(this.mAccountAdapter); diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index f66c4d0d1..febdc4c07 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -157,12 +157,15 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); new EmojiService(this).init(); + + setContentView(R.layout.activity_share_with); + + setSupportActionBar(findViewById(R.id.toolbar)); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(false); getSupportActionBar().setHomeButtonEnabled(false); } - setContentView(R.layout.activity_share_with); setTitle(getString(R.string.title_activity_sharewith)); mListView = findViewById(R.id.choose_conversation_list); diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index f614bc1dc..583a900d3 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -9,6 +9,8 @@ import android.graphics.drawable.Drawable; import android.support.annotation.AttrRes; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.design.widget.TabLayout; import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.app.Dialog; @@ -30,6 +32,7 @@ import android.support.v4.view.MenuItemCompat; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBar; +import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.SpannableString; import android.text.Spanned; @@ -141,7 +144,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU private TextView.OnEditorActionListener mSearchDone = new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - int pos = getSupportActionBar().getSelectedNavigationIndex(); + int pos = binding.startConversationViewPager.getCurrentItem(); if (pos == 0) { if (contacts.size() == 1) { openConversationForContact((Contact) contacts.get(0)); @@ -193,31 +196,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } }; private ActivityStartConversationBinding binding; - private ActionBar.TabListener mTabListener = new ActionBar.TabListener() { - - @Override - public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { - return; - } - - @Override - public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { - binding.startConversationViewPager.setCurrentItem(tab.getPosition()); - onTabChanged(); - } - - @Override - public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { - return; - } - }; private ViewPager.SimpleOnPageChangeListener mOnPageChangeListener = new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setSelectedNavigationItem(position); - } onTabChanged(); } }; @@ -265,8 +246,11 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU super.onCreate(savedInstanceState); new EmojiService(this).init(); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_start_conversation); + Toolbar toolbar = (Toolbar) binding.toolbar; + setSupportActionBar(toolbar); + configureActionBar(getSupportActionBar()); this.binding.fab.setOnClickListener((v) -> { - if (getSupportActionBar().getSelectedNavigationIndex() == 0) { + if (binding.startConversationViewPager.getCurrentItem() == 0) { String searchString = mSearchEditText != null ? mSearchEditText.getText().toString() : null; if (searchString != null && !searchString.trim().isEmpty()) { try { @@ -284,15 +268,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU showCreateConferenceDialog(); } }); - ActionBar actionBar = getSupportActionBar(); - actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); - - ActionBar.Tab mContactsTab = actionBar.newTab().setText(R.string.contacts).setTabListener(mTabListener); - ActionBar.Tab mConferencesTab = actionBar.newTab().setText(R.string.conferences).setTabListener(mTabListener); - actionBar.addTab(mContactsTab); - actionBar.addTab(mConferencesTab); - - binding.startConversationViewPager.setOnPageChangeListener(mOnPageChangeListener); + TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); + tabLayout.setupWithViewPager(binding.startConversationViewPager); + binding.startConversationViewPager.addOnPageChangeListener(mOnPageChangeListener); mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager()); binding.startConversationViewPager.setAdapter(mListPagerAdapter); @@ -540,7 +518,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU MenuItem joinGroupChat = menu.findItem(R.id.action_join_conference); MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code); ActionBar bar = getSupportActionBar(); - joinGroupChat.setVisible(bar != null && bar.getSelectedNavigationIndex() == 1); + joinGroupChat.setVisible(bar != null && binding.startConversationViewPager.getCurrentItem() == 1); qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable()); menuHideOffline.setChecked(this.mHideOfflineContacts); mMenuSearchView = menu.findItem(R.id.action_search); @@ -873,7 +851,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU private void onTabChanged() { @DrawableRes final int fabDrawable; - if (getSupportActionBar().getSelectedNavigationIndex() == 0) { + if (binding.startConversationViewPager.getCurrentItem() == 0) { fabDrawable = R.drawable.ic_person_add_white_24dp; } else { fabDrawable = R.drawable.ic_group_add_white_24dp; @@ -1091,6 +1069,19 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU return ((Fragment) fragment).getView() == view; } + @Nullable + @Override + public CharSequence getPageTitle(int position) { + switch (position) { + case 0: + return getResources().getString(R.string.contacts); + case 1: + return getResources().getString(R.string.conferences); + default: + return super.getPageTitle(position); + } + } + public Fragment getItem(int position) { assert (0 <= position && position < fragments.length); if (fragments[position] == null) { diff --git a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java index f3ef8983b..65b365893 100644 --- a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java @@ -5,6 +5,7 @@ import android.content.Intent; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.support.v7.app.ActionBar; +import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Gravity; import android.view.Menu; @@ -80,11 +81,8 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat binding.cancelButton.setOnClickListener(mCancelButtonListener); binding.saveButton.setOnClickListener(mSaveButtonListener); - - if (getSupportActionBar() != null) { - getSupportActionBar().setHomeButtonEnabled(true); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - } + setSupportActionBar((Toolbar) binding.toolbar); + configureActionBar(getSupportActionBar()); if (savedInstanceState != null) { mUseCameraHintShown.set(savedInstanceState.getBoolean("camera_hint_shown", false)); diff --git a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java index 793cc3d63..fb78d5a4b 100644 --- a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java @@ -54,6 +54,8 @@ public class UriHandlerActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.handled = savedInstanceState != null && savedInstanceState.getBoolean("handled", false); + getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content)); + setSupportActionBar(findViewById(R.id.toolbar)); } @Override diff --git a/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java b/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java index 4174e0ed4..d3524faee 100644 --- a/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/WelcomeActivity.java @@ -50,6 +50,7 @@ public class WelcomeActivity extends XmppActivity { } super.onCreate(savedInstanceState); setContentView(R.layout.welcome); + setSupportActionBar(findViewById(R.id.toolbar)); final ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayShowHomeEnabled(false); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 7f36d3c85..10a278574 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -3,6 +3,7 @@ package eu.siacs.conversations.ui; import android.Manifest; import android.annotation.SuppressLint; import android.annotation.TargetApi; +import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog.Builder; import android.app.PendingIntent; @@ -36,7 +37,6 @@ import android.os.PowerManager; import android.os.SystemClock; import android.preference.PreferenceManager; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.text.InputType; import android.util.DisplayMetrics; @@ -420,10 +420,6 @@ public abstract class XmppActivity extends AppCompatActivity { this.mUsingEnterKey = usingEnterKey(); mUseSubject = getPreferences().getBoolean("use_subject", getResources().getBoolean(R.bool.use_subject)); - final ActionBar ab = getSupportActionBar(); - if (ab != null) { - ab.setDisplayHomeAsUpEnabled(true); - } } protected boolean isCameraFeatureAvailable() { @@ -610,6 +606,13 @@ public abstract class XmppActivity extends AppCompatActivity { } } + public static void configureActionBar(ActionBar actionBar) { + if (actionBar != null) { + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + } + } + protected boolean noAccountUsesPgp() { if (!hasPgp()) { return true; diff --git a/src/main/res/layout-w945dp/activity_conversations.xml b/src/main/res/layout-w945dp/activity_conversations.xml index 0a0a3900f..ce2817e55 100644 --- a/src/main/res/layout-w945dp/activity_conversations.xml +++ b/src/main/res/layout-w945dp/activity_conversations.xml @@ -3,20 +3,26 @@ + android:orientation="vertical"> - + - + + + + + - - \ No newline at end of file + diff --git a/src/main/res/layout/activity_about.xml b/src/main/res/layout/activity_about.xml index e37c00e4c..5db5c6485 100644 --- a/src/main/res/layout/activity_about.xml +++ b/src/main/res/layout/activity_about.xml @@ -1,13 +1,16 @@ - + - + + + android:layout_height="match_parent"> - - + + \ No newline at end of file diff --git a/src/main/res/layout/activity_change_password.xml b/src/main/res/layout/activity_change_password.xml index 2148c2e43..17d77aa26 100644 --- a/src/main/res/layout/activity_change_password.xml +++ b/src/main/res/layout/activity_change_password.xml @@ -5,9 +5,12 @@ android:layout_height="match_parent" android:background="?attr/color_background_secondary"> + + - + android:orientation="vertical"> - + + + android:background="?attr/color_background_primary"> - - + + + + + \ No newline at end of file diff --git a/src/main/res/layout/activity_contact_details.xml b/src/main/res/layout/activity_contact_details.xml index dd7b70115..1a9ad4744 100644 --- a/src/main/res/layout/activity_contact_details.xml +++ b/src/main/res/layout/activity_contact_details.xml @@ -1,165 +1,174 @@ - + - + - + + + android:layout_height="fill_parent"> - - - - - - - - - - - - - - - - - -