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
This commit is contained in:
Harshit Bansal 2018-03-18 14:00:22 +05:30 committed by Daniel Gultsch
parent 83a4cb8a11
commit f2885575ba
37 changed files with 772 additions and 627 deletions

View File

@ -6,6 +6,8 @@ import android.support.v7.app.AppCompatActivity;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import static eu.siacs.conversations.ui.XmppActivity.configureActionBar;
public class AboutActivity extends AppCompatActivity { public class AboutActivity extends AppCompatActivity {
@Override @Override
@ -18,5 +20,7 @@ public class AboutActivity extends AppCompatActivity {
setTheme(mTheme); setTheme(mTheme);
setContentView(R.layout.activity_about); setContentView(R.layout.activity_about);
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
} }
} }

View File

@ -3,6 +3,7 @@ package eu.siacs.conversations.ui;
import android.content.Context; import android.content.Context;
import android.databinding.DataBindingUtil; import android.databinding.DataBindingUtil;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.Menu; import android.view.Menu;
@ -95,6 +96,8 @@ public abstract class AbstractSearchableListItemActivity extends XmppActivity {
public void onCreate(final Bundle savedInstanceState) { public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
this.binding = DataBindingUtil.setContentView(this,R.layout.activity_choose_contact); this.binding = DataBindingUtil.setContentView(this,R.layout.activity_choose_contact);
setSupportActionBar((Toolbar) binding.toolbar);
configureActionBar(getSupportActionBar());
this.binding.chooseContactList.setFastScrollEnabled(true); this.binding.chooseContactList.setFastScrollEnabled(true);
mListItemsAdapter = new ListItemAdapter(this, listItems); mListItemsAdapter = new ListItemAdapter(this, listItems);
this.binding.chooseContactList.setAdapter(mListItemsAdapter); this.binding.chooseContactList.setAdapter(mListItemsAdapter);

View File

@ -60,6 +60,8 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_change_password); setContentView(R.layout.activity_change_password);
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
Button mCancelButton = findViewById(R.id.left_button); Button mCancelButton = findViewById(R.id.left_button);
mCancelButton.setOnClickListener(view -> finish()); mCancelButton.setOnClickListener(view -> finish());
this.mChangePasswordButton = findViewById(R.id.right_button); this.mChangePasswordButton = findViewById(R.id.right_button);

View File

@ -11,6 +11,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -226,10 +227,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
this.binding.mucMoreDetails.setVisibility(View.GONE); this.binding.mucMoreDetails.setVisibility(View.GONE);
this.binding.changeConferenceButton.setOnClickListener(this.mChangeConferenceSettings); this.binding.changeConferenceButton.setOnClickListener(this.mChangeConferenceSettings);
this.binding.invite.setOnClickListener(inviteListener); this.binding.invite.setOnClickListener(inviteListener);
if (getSupportActionBar() != null) { setSupportActionBar((Toolbar) binding.toolbar);
getSupportActionBar().setHomeButtonEnabled(true); configureActionBar(getSupportActionBar());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
this.binding.editNickButton.setOnClickListener(v -> quickEdit(mConversation.getMucOptions().getActualNick(), this.binding.editNickButton.setOnClickListener(v -> quickEdit(mConversation.getMucOptions().getActualNick(),
0, 0,
value -> { value -> {

View File

@ -12,6 +12,7 @@ import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents; import android.provider.ContactsContract.Intents;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -190,10 +191,8 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
this.messageFingerprint = getIntent().getStringExtra("fingerprint"); this.messageFingerprint = getIntent().getStringExtra("fingerprint");
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_contact_details); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_contact_details);
if (getSupportActionBar() != null) { setSupportActionBar((Toolbar) binding.toolbar);
getSupportActionBar().setHomeButtonEnabled(true); configureActionBar(getSupportActionBar());
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
binding.showInactiveDevices.setOnClickListener(v -> { binding.showInactiveDevices.setOnClickListener(v -> {
showInactiveOmemo = !showInactiveOmemo; showInactiveOmemo = !showInactiveOmemo;
populateView(); populateView();

View File

@ -48,6 +48,7 @@ import android.support.annotation.IdRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -364,6 +365,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
new EmojiService(this).init(); new EmojiService(this).init();
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_conversations);
setSupportActionBar((Toolbar) binding.toolbar);
configureActionBar(getSupportActionBar());
this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle); this.getFragmentManager().addOnBackStackChangedListener(this::invalidateActionBarTitle);
this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview); this.getFragmentManager().addOnBackStackChangedListener(this::showDialogsIfMainIsOverview);
this.initializeFragments(); this.initializeFragments();

View File

@ -20,6 +20,7 @@ import android.support.design.widget.TextInputLayout;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder; import android.support.v7.app.AlertDialog.Builder;
import android.support.v7.widget.Toolbar;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log; import android.util.Log;
@ -536,6 +537,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.mSavedInstanceInit = savedInstanceState.getBoolean("initMode", false); this.mSavedInstanceInit = savedInstanceState.getBoolean("initMode", false);
} }
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_edit_account); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_edit_account);
setSupportActionBar((Toolbar) binding.toolbar);
configureActionBar(getSupportActionBar());
binding.accountJid.addTextChangedListener(this.mTextWatcher); binding.accountJid.addTextChangedListener(this.mTextWatcher);
binding.accountJid.setOnFocusChangeListener(this.mEditTextFocusListener); binding.accountJid.setOnFocusChangeListener(this.mEditTextFocusListener);
this.mAccountJidLayout = (TextInputLayout) findViewById(R.id.account_jid_layout); this.mAccountJidLayout = (TextInputLayout) findViewById(R.id.account_jid_layout);

View File

@ -53,6 +53,8 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.magic_create); setContentView(R.layout.magic_create);
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
mFullJidDisplay = findViewById(R.id.full_jid); mFullJidDisplay = findViewById(R.id.full_jid);
mUsername = findViewById(R.id.username); mUsername = findViewById(R.id.username);
mRandom = new SecureRandom(); mRandom = new SecureRandom();

View File

@ -74,7 +74,8 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_accounts); setContentView(R.layout.activity_manage_accounts);
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
if (savedInstanceState != null) { if (savedInstanceState != null) {
String jid = savedInstanceState.getString(STATE_SELECTED_ACCOUNT); String jid = savedInstanceState.getString(STATE_SELECTED_ACCOUNT);
if (jid != null) { if (jid != null) {

View File

@ -41,7 +41,7 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.MTMDecision; import eu.siacs.conversations.entities.MTMDecision;
import eu.siacs.conversations.services.MemorizingTrustManager; 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()); 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"); LOGGER.log(Level.FINE, "onCreate");
setTheme(findTheme()); setTheme(findTheme());
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content));
setSupportActionBar(findViewById(R.id.toolbar));
} }
@Override @Override

View File

@ -94,6 +94,9 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_publish_profile_picture); setContentView(R.layout.activity_publish_profile_picture);
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
this.avatar = findViewById(R.id.account_image); this.avatar = findViewById(R.id.account_image);
this.cancelButton = findViewById(R.id.cancel_button); this.cancelButton = findViewById(R.id.cancel_button);
this.publishButton = findViewById(R.id.publish_button); this.publishButton = findViewById(R.id.publish_button);

View File

@ -19,6 +19,8 @@ import android.preference.PreferenceManager;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast; import android.widget.Toast;
import java.io.File; import java.io.File;
@ -57,18 +59,19 @@ public class SettingsActivity extends XmppActivity implements
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
FragmentManager fm = getFragmentManager(); 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)) { if (mSettingsFragment == null || !mSettingsFragment.getClass().equals(SettingsFragment.class)) {
mSettingsFragment = new SettingsFragment(); mSettingsFragment = new SettingsFragment();
fm.beginTransaction().replace(android.R.id.content, mSettingsFragment).commit(); fm.beginTransaction().replace(R.id.settings_content, mSettingsFragment).commit();
} }
mSettingsFragment.setActivityIntent(getIntent()); mSettingsFragment.setActivityIntent(getIntent());
this.mTheme = findTheme(); this.mTheme = findTheme();
setTheme(this.mTheme); setTheme(this.mTheme);
getWindow().getDecorView().setBackgroundColor(Color.get(this, R.attr.color_background_primary)); getWindow().getDecorView().setBackgroundColor(Color.get(this, R.attr.color_background_primary));
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
} }
@Override @Override

View File

@ -43,7 +43,8 @@ public class ShareViaAccountActivity extends XmppActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_accounts); setContentView(R.layout.activity_manage_accounts);
setSupportActionBar(findViewById(R.id.toolbar));
configureActionBar(getSupportActionBar());
accountListView = (ListView) findViewById(R.id.account_list); accountListView = (ListView) findViewById(R.id.account_list);
this.mAccountAdapter = new AccountAdapter(this, accountList, false); this.mAccountAdapter = new AccountAdapter(this, accountList, false);
accountListView.setAdapter(this.mAccountAdapter); accountListView.setAdapter(this.mAccountAdapter);

View File

@ -157,12 +157,15 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
new EmojiService(this).init(); new EmojiService(this).init();
setContentView(R.layout.activity_share_with);
setSupportActionBar(findViewById(R.id.toolbar));
if (getSupportActionBar() != null) { if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false); getSupportActionBar().setHomeButtonEnabled(false);
} }
setContentView(R.layout.activity_share_with);
setTitle(getString(R.string.title_activity_sharewith)); setTitle(getString(R.string.title_activity_sharewith));
mListView = findViewById(R.id.choose_conversation_list); mListView = findViewById(R.id.choose_conversation_list);

View File

@ -9,6 +9,8 @@ import android.graphics.drawable.Drawable;
import android.support.annotation.AttrRes; import android.support.annotation.AttrRes;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; 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.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.app.Dialog; 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.PagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.text.Editable; import android.text.Editable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.Spanned; import android.text.Spanned;
@ -141,7 +144,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
private TextView.OnEditorActionListener mSearchDone = new TextView.OnEditorActionListener() { private TextView.OnEditorActionListener mSearchDone = new TextView.OnEditorActionListener() {
@Override @Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
int pos = getSupportActionBar().getSelectedNavigationIndex(); int pos = binding.startConversationViewPager.getCurrentItem();
if (pos == 0) { if (pos == 0) {
if (contacts.size() == 1) { if (contacts.size() == 1) {
openConversationForContact((Contact) contacts.get(0)); openConversationForContact((Contact) contacts.get(0));
@ -193,31 +196,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
} }
}; };
private ActivityStartConversationBinding binding; 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() { private ViewPager.SimpleOnPageChangeListener mOnPageChangeListener = new ViewPager.SimpleOnPageChangeListener() {
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setSelectedNavigationItem(position);
}
onTabChanged(); onTabChanged();
} }
}; };
@ -265,8 +246,11 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
new EmojiService(this).init(); new EmojiService(this).init();
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_start_conversation); this.binding = DataBindingUtil.setContentView(this, R.layout.activity_start_conversation);
Toolbar toolbar = (Toolbar) binding.toolbar;
setSupportActionBar(toolbar);
configureActionBar(getSupportActionBar());
this.binding.fab.setOnClickListener((v) -> { this.binding.fab.setOnClickListener((v) -> {
if (getSupportActionBar().getSelectedNavigationIndex() == 0) { if (binding.startConversationViewPager.getCurrentItem() == 0) {
String searchString = mSearchEditText != null ? mSearchEditText.getText().toString() : null; String searchString = mSearchEditText != null ? mSearchEditText.getText().toString() : null;
if (searchString != null && !searchString.trim().isEmpty()) { if (searchString != null && !searchString.trim().isEmpty()) {
try { try {
@ -284,15 +268,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
showCreateConferenceDialog(); showCreateConferenceDialog();
} }
}); });
ActionBar actionBar = getSupportActionBar(); TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); tabLayout.setupWithViewPager(binding.startConversationViewPager);
binding.startConversationViewPager.addOnPageChangeListener(mOnPageChangeListener);
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);
mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager()); mListPagerAdapter = new ListPagerAdapter(getSupportFragmentManager());
binding.startConversationViewPager.setAdapter(mListPagerAdapter); 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 joinGroupChat = menu.findItem(R.id.action_join_conference);
MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code); MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
ActionBar bar = getSupportActionBar(); ActionBar bar = getSupportActionBar();
joinGroupChat.setVisible(bar != null && bar.getSelectedNavigationIndex() == 1); joinGroupChat.setVisible(bar != null && binding.startConversationViewPager.getCurrentItem() == 1);
qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable()); qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable());
menuHideOffline.setChecked(this.mHideOfflineContacts); menuHideOffline.setChecked(this.mHideOfflineContacts);
mMenuSearchView = menu.findItem(R.id.action_search); mMenuSearchView = menu.findItem(R.id.action_search);
@ -873,7 +851,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
private void onTabChanged() { private void onTabChanged() {
@DrawableRes final int fabDrawable; @DrawableRes final int fabDrawable;
if (getSupportActionBar().getSelectedNavigationIndex() == 0) { if (binding.startConversationViewPager.getCurrentItem() == 0) {
fabDrawable = R.drawable.ic_person_add_white_24dp; fabDrawable = R.drawable.ic_person_add_white_24dp;
} else { } else {
fabDrawable = R.drawable.ic_group_add_white_24dp; fabDrawable = R.drawable.ic_group_add_white_24dp;
@ -1091,6 +1069,19 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
return ((Fragment) fragment).getView() == view; 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) { public Fragment getItem(int position) {
assert (0 <= position && position < fragments.length); assert (0 <= position && position < fragments.length);
if (fragments[position] == null) { if (fragments[position] == null) {

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.databinding.DataBindingUtil; import android.databinding.DataBindingUtil;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
@ -80,11 +81,8 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
binding.cancelButton.setOnClickListener(mCancelButtonListener); binding.cancelButton.setOnClickListener(mCancelButtonListener);
binding.saveButton.setOnClickListener(mSaveButtonListener); binding.saveButton.setOnClickListener(mSaveButtonListener);
setSupportActionBar((Toolbar) binding.toolbar);
if (getSupportActionBar() != null) { configureActionBar(getSupportActionBar());
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
if (savedInstanceState != null) { if (savedInstanceState != null) {
mUseCameraHintShown.set(savedInstanceState.getBoolean("camera_hint_shown", false)); mUseCameraHintShown.set(savedInstanceState.getBoolean("camera_hint_shown", false));

View File

@ -54,6 +54,8 @@ public class UriHandlerActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
this.handled = savedInstanceState != null && savedInstanceState.getBoolean("handled", false); this.handled = savedInstanceState != null && savedInstanceState.getBoolean("handled", false);
getLayoutInflater().inflate(R.layout.toolbar, findViewById(android.R.id.content));
setSupportActionBar(findViewById(R.id.toolbar));
} }
@Override @Override

View File

@ -50,6 +50,7 @@ public class WelcomeActivity extends XmppActivity {
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.welcome); setContentView(R.layout.welcome);
setSupportActionBar(findViewById(R.id.toolbar));
final ActionBar ab = getSupportActionBar(); final ActionBar ab = getSupportActionBar();
if (ab != null) { if (ab != null) {
ab.setDisplayShowHomeEnabled(false); ab.setDisplayShowHomeEnabled(false);

View File

@ -3,6 +3,7 @@ package eu.siacs.conversations.ui;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder; import android.support.v7.app.AlertDialog.Builder;
import android.app.PendingIntent; import android.app.PendingIntent;
@ -36,7 +37,6 @@ import android.os.PowerManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.text.InputType; import android.text.InputType;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
@ -420,10 +420,6 @@ public abstract class XmppActivity extends AppCompatActivity {
this.mUsingEnterKey = usingEnterKey(); this.mUsingEnterKey = usingEnterKey();
mUseSubject = getPreferences().getBoolean("use_subject", getResources().getBoolean(R.bool.use_subject)); mUseSubject = getPreferences().getBoolean("use_subject", getResources().getBoolean(R.bool.use_subject));
final ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
}
} }
protected boolean isCameraFeatureAvailable() { 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() { protected boolean noAccountUsesPgp() {
if (!hasPgp()) { if (!hasPgp()) {
return true; return true;

View File

@ -3,7 +3,14 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"> android:orientation="vertical">
<include android:id="@+id/toolbar"
layout="@layout/toolbar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout <FrameLayout
android:id="@+id/main_fragment" android:id="@+id/main_fragment"
@ -16,7 +23,6 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1618"/> android:layout_weight="1618"/>
</LinearLayout> </LinearLayout>
</LinearLayout>
</layout> </layout>

View File

@ -1,13 +1,16 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/color_background_secondary" android:background="?attr/color_background_secondary"
tools:context="eu.siacs.conversations.ui.AboutActivity"> tools:context="eu.siacs.conversations.ui.AboutActivity"
android:orientation="vertical">
<LinearLayout <include layout="@layout/toolbar" />
<ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent">
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -28,5 +31,5 @@
android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:typeface="monospace"/> android:typeface="monospace"/>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
</LinearLayout> </ScrollView>
</ScrollView> </LinearLayout>

View File

@ -5,9 +5,12 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/color_background_secondary"> android:background="?attr/color_background_secondary">
<include layout="@layout/toolbar" />
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_below="@id/toolbar"
android:layout_above="@+id/button_bar"> android:layout_above="@+id/button_bar">
<android.support.v7.widget.CardView <android.support.v7.widget.CardView

View File

@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include android:id="@+id/toolbar"
layout="@layout/toolbar" />
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -21,4 +29,5 @@
android:layout_margin="16dp" android:layout_margin="16dp"
android:src="@drawable/ic_person_add_white_24dp"/> android:src="@drawable/ic_person_add_white_24dp"/>
</FrameLayout> </FrameLayout>
</LinearLayout>
</layout> </layout>

View File

@ -1,10 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/color_background_secondary"
android:orientation="vertical">
<include android:id="@+id/toolbar"
layout="@layout/toolbar" />
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent">
android:background="?attr/color_background_secondary">
<LinearLayout <LinearLayout
android:id="@+id/details_main_layout" android:id="@+id/details_main_layout"
@ -160,6 +169,6 @@
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</LinearLayout>
</layout> </layout>

View File

@ -28,8 +28,18 @@
~ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ~ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--> -->
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <layout xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include android:id="@+id/toolbar"
layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/main_fragment" android:id="@+id/main_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
</LinearLayout>
</layout> </layout>

View File

@ -8,11 +8,14 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/color_background_secondary"> android:background="?attr/color_background_secondary">
<include android:id="@+id/toolbar"
layout="@layout/toolbar" />
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@+id/button_bar" android:layout_above="@+id/button_bar"
android:layout_alignParentTop="true"> android:layout_below="@id/toolbar">
<LinearLayout <LinearLayout
android:id="@+id/account_main_layout" android:id="@+id/account_main_layout"

View File

@ -3,7 +3,10 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:background="?attr/color_background_primary" > android:background="?attr/color_background_primary"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<ListView <ListView
android:id="@+id/account_list" android:id="@+id/account_list"

View File

@ -2,11 +2,18 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android" <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<ScrollView <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/color_background_secondary"
android:orientation="vertical">
<include android:id="@+id/toolbar"
layout="@layout/toolbar" />
<ScrollView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent">
android:background="?attr/color_background_secondary">
<LinearLayout <LinearLayout
android:id="@+id/muc_main_layout" android:id="@+id/muc_main_layout"
@ -228,7 +235,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</LinearLayout>
</layout> </layout>

View File

@ -2,11 +2,15 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/color_background_secondary"> android:background="?attr/color_background_secondary">
<include layout="@layout/toolbar" />
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
android:layout_marginBottom="@dimen/activity_vertical_margin" android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin" android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin" android:layout_marginRight="@dimen/activity_horizontal_margin"

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/settings_content"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

View File

@ -2,7 +2,11 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<ListView <ListView
android:id="@+id/choose_conversation_list" android:id="@+id/choose_conversation_list"

View File

@ -1,19 +1,38 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android" > <layout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<include android:id="@+id/toolbar"
layout="@layout/toolbar" />
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_below="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:elevation="6dp"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabTextColor="@color/white70"
app:tabSelectedTextColor="@color/white"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<android.support.v4.view.ViewPager <android.support.v4.view.ViewPager
android:id="@+id/start_conversation_view_pager" android:id="@+id/start_conversation_view_pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_below="@id/tab_layout"
android:background="?attr/color_background_primary"/> android:background="?attr/color_background_primary"/>
<android.support.design.widget.FloatingActionButton <android.support.design.widget.FloatingActionButton
android:id="@+id/fab" android:id="@+id/fab"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end|bottom" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="?attr/icon_add_person" android:src="?attr/icon_add_person"
android:layout_margin="16dp" /> android:layout_margin="16dp" />
</FrameLayout> </RelativeLayout>
</layout> </layout>

View File

@ -1,16 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"> <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/color_background_secondary"> android:background="?attr/color_background_secondary">
<include android:id="@+id/toolbar"
layout="@layout/toolbar" />
<ScrollView <ScrollView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@+id/button_bar" android:layout_below="@id/toolbar"
android:layout_alignParentTop="true"> android:layout_above="@+id/button_bar">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true"> android:fillViewport="true">
@ -64,8 +72,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/linearLayout" android:layout_above="@+id/linearLayout"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true">
android:layout_alignParentTop="true">
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -86,4 +93,5 @@
android:text="@string/free_for_six_month" android:text="@string/free_for_six_month"
android:layout_centerHorizontal="true"/> android:layout_centerHorizontal="true"/>
</RelativeLayout> </RelativeLayout>
</ScrollView> </ScrollView>
</LinearLayout>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:elevation="6dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" />

View File

@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fillViewport="true"> android:fillViewport="true">
<RelativeLayout <RelativeLayout
@ -57,8 +64,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/linearLayout" android:layout_above="@+id/linearLayout"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true">
android:layout_alignParentTop="true">
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -79,4 +85,5 @@
android:text="@string/free_for_six_month" android:text="@string/free_for_six_month"
android:layout_centerHorizontal="true"/> android:layout_centerHorizontal="true"/>
</RelativeLayout> </RelativeLayout>
</ScrollView> </ScrollView>
</LinearLayout>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="ConversationsTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="ConversationsTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary500</item> <item name="colorPrimary">@color/primary500</item>
<item name="colorPrimaryDark">@color/primary700</item> <item name="colorPrimaryDark">@color/primary700</item>
<item name="colorAccent">@color/accent</item> <item name="colorAccent">@color/accent</item>
@ -10,7 +10,7 @@
<item name="color_background_secondary">@color/grey200</item> <item name="color_background_secondary">@color/grey200</item>
<item name="color_warning">@color/red_a700</item> <item name="color_warning">@color/red_a700</item>
<item name="android:windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
<item name="android:actionModeBackground">@color/accent</item> <item name="android:actionModeBackground">@color/accent</item>
<item name="TextSizeInfo">12sp</item> <item name="TextSizeInfo">12sp</item>
@ -77,7 +77,7 @@
<item type="reference" name="icon_enable_undecided_device">@drawable/ic_new_releases_black_24dp</item> <item type="reference" name="icon_enable_undecided_device">@drawable/ic_new_releases_black_24dp</item>
</style> </style>
<style name="ConversationsTheme.Dark" parent="Theme.AppCompat"> <style name="ConversationsTheme.Dark" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/primary800</item> <item name="colorPrimary">@color/primary800</item>
<item name="colorPrimaryDark">@color/primary900</item> <item name="colorPrimaryDark">@color/primary900</item>
<item name="colorAccent">@color/accent</item> <item name="colorAccent">@color/accent</item>
@ -87,7 +87,7 @@
<item name="color_background_secondary">@color/grey900</item> <item name="color_background_secondary">@color/grey900</item>
<item name="color_warning">@color/red_a100</item> <item name="color_warning">@color/red_a100</item>
<item name="android:windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
<item name="android:actionModeBackground">@color/accent</item> <item name="android:actionModeBackground">@color/accent</item>
<item name="TextSizeInfo">12sp</item> <item name="TextSizeInfo">12sp</item>