diff options
Diffstat (limited to 'OpenKeychain/src/main')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java index 008433f78..f5a909676 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentManager.OnBackStackChangedListener; import android.support.v4.app.FragmentTransaction; import android.support.v7.widget.Toolbar; import android.view.View; @@ -42,7 +43,7 @@ import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity; import org.sufficientlysecure.keychain.util.FabContainer; import org.sufficientlysecure.keychain.util.Preferences; -public class MainActivity extends BaseNfcActivity implements FabContainer { +public class MainActivity extends BaseNfcActivity implements FabContainer, OnBackStackChangedListener { private static final int ID_KEYS = 1; private static final int ID_ENCRYPT_DECRYPT = 2; @@ -121,6 +122,8 @@ public class MainActivity extends BaseNfcActivity implements FabContainer { return; } + getSupportFragmentManager().addOnBackStackChangedListener(this); + Intent data = getIntent(); // If we got an EXTRA_RESULT in the intent, show the notification if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) { @@ -206,4 +209,25 @@ public class MainActivity extends BaseNfcActivity implements FabContainer { } + @Override + public void onBackStackChanged() { + FragmentManager fragmentManager = getSupportFragmentManager(); + if (fragmentManager == null) { + return; + } + Fragment frag = fragmentManager.findFragmentById(R.id.main_fragment_container); + if (frag == null) { + return; + } + + // make sure the selected icon is the one shown at this point + if (frag instanceof KeyListFragment) { + mDrawerResult.setSelection(mDrawerResult.getPositionFromIdentifier(ID_KEYS), false); + } else if (frag instanceof EncryptDecryptOverviewFragment) { + mDrawerResult.setSelection(mDrawerResult.getPositionFromIdentifier(ID_ENCRYPT_DECRYPT), false); + } else if (frag instanceof AppsListFragment) { + mDrawerResult.setSelection(mDrawerResult.getPositionFromIdentifier(ID_APPS), false); + } + } + } |