aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-05-17 00:54:09 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-05-17 00:54:14 +0200
commit48f6e20f6ce59ff2581b26e6e11c8e6cda9ecfec (patch)
tree7716c45da401923ce77ebf14add1c6a3199a0727 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
parentc1e7fcf02455b7a03c86bb78efe39684396c15f8 (diff)
downloadopen-keychain-48f6e20f6ce59ff2581b26e6e11c8e6cda9ecfec.tar.gz
open-keychain-48f6e20f6ce59ff2581b26e6e11c8e6cda9ecfec.tar.bz2
open-keychain-48f6e20f6ce59ff2581b26e6e11c8e6cda9ecfec.zip
load yubikey fragment after mMasterKeyId is available
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java50
1 files changed, 33 insertions, 17 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 023483193..4237deff0 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
@@ -131,6 +131,8 @@ public class ViewKeyActivity extends BaseNfcActivity implements
private boolean mIsRevoked = false;
private boolean mIsExpired = false;
+ private boolean mShowYubikeyAfterCreation = false;
+
private MenuItem mRefreshItem;
private boolean mIsRefreshing;
private Animation mRotate, mRotateSpin;
@@ -286,13 +288,9 @@ public class ViewKeyActivity extends BaseNfcActivity implements
.replace(R.id.view_key_fragment, frag)
.commit();
- if (getIntent().hasExtra(EXTRA_NFC_AID)) {
- Intent intent = getIntent();
- byte[] nfcFingerprints = intent.getByteArrayExtra(EXTRA_NFC_FINGERPRINTS);
- String nfcUserId = intent.getStringExtra(EXTRA_NFC_USER_ID);
- byte[] nfcAid = intent.getByteArrayExtra(EXTRA_NFC_AID);
- showYubiKeyFragment(nfcFingerprints, nfcUserId, nfcAid);
- }
+ // need to postpone loading of the yubikey fragment until after mMasterKeyId
+ // is available, but we mark here that this should be done
+ mShowYubikeyAfterCreation = true;
}
@@ -586,18 +584,26 @@ public class ViewKeyActivity extends BaseNfcActivity implements
}
- public void showYubiKeyFragment(byte[] nfcFingerprints, String nfcUserId, byte[] nfcAid) {
- ViewKeyYubiKeyFragment frag = ViewKeyYubiKeyFragment.newInstance(
- mMasterKeyId, nfcFingerprints, nfcUserId, nfcAid);
+ public void showYubiKeyFragment(
+ final byte[] nfcFingerprints, final String nfcUserId, final byte[] nfcAid) {
- FragmentManager manager = getSupportFragmentManager();
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ ViewKeyYubiKeyFragment frag = ViewKeyYubiKeyFragment.newInstance(
+ mMasterKeyId, nfcFingerprints, nfcUserId, nfcAid);
+
+ FragmentManager manager = getSupportFragmentManager();
+
+ manager.popBackStack("yubikey", FragmentManager.POP_BACK_STACK_INCLUSIVE);
+ manager.beginTransaction()
+ .addToBackStack("yubikey")
+ .replace(R.id.view_key_fragment, frag)
+ // if this is called while the activity wasn't resumed, just forget it happened
+ .commitAllowingStateLoss();
+ }
+ });
- manager.popBackStack("yubikey", FragmentManager.POP_BACK_STACK_INCLUSIVE);
- manager.beginTransaction()
- .addToBackStack("yubikey")
- .replace(R.id.view_key_fragment, frag)
- // if this is called while the activity wasn't resumed, just forget it happened
- .commitAllowingStateLoss();
}
private void encrypt(Uri dataUri, boolean text) {
@@ -813,6 +819,16 @@ public class ViewKeyActivity extends BaseNfcActivity implements
mMasterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
mFingerprint = KeyFormattingUtils.convertFingerprintToHex(data.getBlob(INDEX_FINGERPRINT));
+ // if it wasn't shown yet, display yubikey fragment
+ if (mShowYubikeyAfterCreation && getIntent().hasExtra(EXTRA_NFC_AID)) {
+ mShowYubikeyAfterCreation = false;
+ Intent intent = getIntent();
+ byte[] nfcFingerprints = intent.getByteArrayExtra(EXTRA_NFC_FINGERPRINTS);
+ String nfcUserId = intent.getStringExtra(EXTRA_NFC_USER_ID);
+ byte[] nfcAid = intent.getByteArrayExtra(EXTRA_NFC_AID);
+ showYubiKeyFragment(nfcFingerprints, nfcUserId, nfcAid);
+ }
+
mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
mHasEncrypt = data.getInt(INDEX_HAS_ENCRYPT) != 0;
mIsRevoked = data.getInt(INDEX_IS_REVOKED) > 0;