mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Set different titles when changing in nav drawer
This commit is contained in:
parent
28da731201
commit
64ca19464b
@ -49,7 +49,8 @@ public class MainActivity extends ActionBarActivity implements FabContainer {
|
|||||||
private KeyListFragment mKeyListFragment ;
|
private KeyListFragment mKeyListFragment ;
|
||||||
private AppsListFragment mAppsListFragment;
|
private AppsListFragment mAppsListFragment;
|
||||||
private EncryptDecryptOverviewFragment mEncryptDecryptOverviewFragment;
|
private EncryptDecryptOverviewFragment mEncryptDecryptOverviewFragment;
|
||||||
private Fragment lastUsedFragment;
|
private Fragment mLastUsedFragment;
|
||||||
|
private Toolbar mToolbar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -63,14 +64,14 @@ public class MainActivity extends ActionBarActivity implements FabContainer {
|
|||||||
transaction.replace(R.id.main_fragment_container, mainFragment);
|
transaction.replace(R.id.main_fragment_container, mainFragment);
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
|
||||||
final Toolbar toolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
|
mToolbar = (Toolbar) findViewById(R.id.activity_main_toolbar);
|
||||||
toolbar.setTitle(R.string.app_name);
|
mToolbar.setTitle(R.string.app_name);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(mToolbar);
|
||||||
|
|
||||||
result = new Drawer()
|
result = new Drawer()
|
||||||
.withActivity(this)
|
.withActivity(this)
|
||||||
.withHeader(R.layout.main_drawer_header)
|
.withHeader(R.layout.main_drawer_header)
|
||||||
.withToolbar(toolbar)
|
.withToolbar(mToolbar)
|
||||||
.addDrawerItems(
|
.addDrawerItems(
|
||||||
new PrimaryDrawerItem().withName(R.string.nav_keys).withIcon(CommunityMaterial.Icon.cmd_key).withIdentifier(1).withCheckable(false),
|
new PrimaryDrawerItem().withName(R.string.nav_keys).withIcon(CommunityMaterial.Icon.cmd_key).withIdentifier(1).withCheckable(false),
|
||||||
new PrimaryDrawerItem().withName(R.string.nav_encrypt_decrypt).withIcon(FontAwesome.Icon.faw_lock).withIdentifier(2).withCheckable(false),
|
new PrimaryDrawerItem().withName(R.string.nav_encrypt_decrypt).withIcon(FontAwesome.Icon.faw_lock).withIdentifier(2).withCheckable(false),
|
||||||
@ -144,7 +145,7 @@ public class MainActivity extends ActionBarActivity implements FabContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setFragment(Fragment fragment, boolean addToBackStack) {
|
private void setFragment(Fragment fragment, boolean addToBackStack) {
|
||||||
this.lastUsedFragment = fragment;
|
this.mLastUsedFragment = fragment;
|
||||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
ft.replace(R.id.main_fragment_container, fragment);
|
ft.replace(R.id.main_fragment_container, fragment);
|
||||||
if (addToBackStack) {
|
if (addToBackStack) {
|
||||||
@ -154,6 +155,7 @@ public class MainActivity extends ActionBarActivity implements FabContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean onKeysSelected() {
|
private boolean onKeysSelected() {
|
||||||
|
mToolbar.setTitle(R.string.app_name);
|
||||||
clearFragments();
|
clearFragments();
|
||||||
|
|
||||||
if (mKeyListFragment == null) {
|
if (mKeyListFragment == null) {
|
||||||
@ -165,6 +167,7 @@ public class MainActivity extends ActionBarActivity implements FabContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean onEnDecryptSelected() {
|
private boolean onEnDecryptSelected() {
|
||||||
|
mToolbar.setTitle(R.string.nav_encrypt_decrypt);
|
||||||
clearFragments();
|
clearFragments();
|
||||||
if (mEncryptDecryptOverviewFragment == null) {
|
if (mEncryptDecryptOverviewFragment == null) {
|
||||||
mEncryptDecryptOverviewFragment = new EncryptDecryptOverviewFragment();
|
mEncryptDecryptOverviewFragment = new EncryptDecryptOverviewFragment();
|
||||||
@ -175,6 +178,7 @@ public class MainActivity extends ActionBarActivity implements FabContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean onAppsSelected() {
|
private boolean onAppsSelected() {
|
||||||
|
mToolbar.setTitle(R.string.nav_apps);
|
||||||
clearFragments();
|
clearFragments();
|
||||||
if (mAppsListFragment == null) {
|
if (mAppsListFragment == null) {
|
||||||
mAppsListFragment = new AppsListFragment();
|
mAppsListFragment = new AppsListFragment();
|
||||||
|
Loading…
Reference in New Issue
Block a user