aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-09-06 00:58:10 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-09-06 00:58:13 +0200
commit31cfbdc5d25f79ecda7c9c9290b8d80a4df5d89a (patch)
tree3ff712e0340b6e2bb5cc6b4628ad799dec5c9d7d /OpenKeychain/src/main/java
parent60e9141b8612ee8d0344e3c66109dfb9877e108a (diff)
downloadopen-keychain-31cfbdc5d25f79ecda7c9c9290b8d80a4df5d89a.tar.gz
open-keychain-31cfbdc5d25f79ecda7c9c9290b8d80a4df5d89a.tar.bz2
open-keychain-31cfbdc5d25f79ecda7c9c9290b8d80a4df5d89a.zip
linked: fix "navigate up" in LinkedIdWizard (imperfect)
Diffstat (limited to 'OpenKeychain/src/main/java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdWizard.java35
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java3
3 files changed, 38 insertions, 3 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
index a15dc74ca..930c1fc26 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
@@ -371,6 +371,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
Intent intent = new Intent(this, LinkedIdWizard.class);
intent.setData(mDataUri);
startActivity(intent);
+ finish();
return true;
}
case R.id.menu_key_view_edit: {
@@ -427,7 +428,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
private void certifyImmediate() {
Intent intent = new Intent(this, CertifyKeyActivity.class);
- intent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{mMasterKeyId});
+ intent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[] { mMasterKeyId });
startActivityForResult(intent, REQUEST_CERTIFY);
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdWizard.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdWizard.java
index 2c29d1d77..8c677199d 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdWizard.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdWizard.java
@@ -19,10 +19,14 @@ package org.sufficientlysecure.keychain.ui.linked;
import android.content.Context;
+import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
+import android.support.v4.app.NavUtils;
+import android.support.v4.app.TaskStackBuilder;
+import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -31,6 +35,7 @@ import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract;
+import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
import org.sufficientlysecure.keychain.util.Log;
@@ -126,4 +131,34 @@ public class LinkedIdWizard extends BaseActivity {
inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
+ @Override
+ public void onBackPressed() {
+ if (!getFragmentManager().popBackStackImmediate()) {
+ navigateBack();
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ // Respond to the action bar's Up/Home button
+ case android.R.id.home:
+ navigateBack();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void navigateBack() {
+ Intent upIntent = NavUtils.getParentActivityIntent(this);
+ upIntent.setData(KeyRings.buildGenericKeyRingUri(mMasterKeyId));
+ // This activity is NOT part of this app's task, so create a new task
+ // when navigating up, with a synthesized back stack.
+ TaskStackBuilder.create(this)
+ // Add all of this activity's parents to the back stack
+ .addNextIntentWithParentStack(upIntent)
+ // Navigate up to the closest parent
+ .startActivities();
+ }
+
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java
index e3ec3d34b..04ed35deb 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java
@@ -119,8 +119,7 @@ public abstract class KeySpinner extends AppCompatSpinner implements
if (getContext() instanceof FragmentActivity) {
((FragmentActivity) getContext()).getSupportLoaderManager().restartLoader(LOADER_ID, null, this);
} else {
- throw new AssertionError("KeySpinner must be attached to FragmentActivity, this is "
- + getContext().getClass());
+ // ignore, this happens during preview! we use fragmentactivities everywhere either way
}
}