From 93eae114eac566a9ed2da6275c147b66ca480305 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Wed, 2 Jul 2014 00:34:21 +0200 Subject: Encrypt/Decrypt UI work --- .../keychain/ui/EncryptAsymmetricFragment.java | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java index 51963e963..be845f05e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -59,12 +59,15 @@ public class EncryptAsymmetricFragment extends Fragment { // model private long mSecretKeyId = Constants.key.none; private long mEncryptionKeyIds[] = null; + private String mEncryptionUserIds[] = null; // Container Activity must implement this interface public interface OnAsymmetricKeySelection { public void onSigningKeySelected(long signingKeyId); public void onEncryptionKeysSelected(long[] encryptionKeyIds); + + public void onEncryptionUserSelected(String[] encryptionUserIds); } @Override @@ -91,6 +94,13 @@ public class EncryptAsymmetricFragment extends Fragment { updateView(); } + private void setEncryptionUserIds(String[] encryptionUserIds) { + mEncryptionUserIds = encryptionUserIds; + // update key selection in EncryptActivity + mKeySelectionListener.onEncryptionUserSelected(encryptionUserIds); + updateView(); + } + /** * Inflate the layout for this fragment */ @@ -159,12 +169,14 @@ public class EncryptAsymmetricFragment extends Fragment { if (preselectedEncryptionKeyIds != null) { Vector goodIds = new Vector(); - for (int i = 0; i < preselectedEncryptionKeyIds.length; ++i) { + Vector goodUserIds = new Vector(); + for (long preselectedId : preselectedEncryptionKeyIds) { try { - long id = providerHelper.getCachedPublicKeyRing( - KeyRings.buildUnifiedKeyRingsFindBySubkeyUri( - preselectedEncryptionKeyIds[i]) - ).getMasterKeyId(); + CachedPublicKeyRing ring = providerHelper.getCachedPublicKeyRing( + KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(preselectedId)); + long id = ring.getMasterKeyId(); + ring.getSplitPrimaryUserId(); + goodUserIds.add(ring.getPrimaryUserId()); goodIds.add(id); } catch (PgpGeneralException e) { Log.e(Constants.TAG, "key not found!", e); @@ -176,6 +188,7 @@ public class EncryptAsymmetricFragment extends Fragment { keyIds[i] = goodIds.get(i); } setEncryptionKeyIds(keyIds); + setEncryptionUserIds(goodUserIds.toArray(new String[goodUserIds.size()])); } } } @@ -249,6 +262,7 @@ public class EncryptAsymmetricFragment extends Fragment { Bundle bundle = data.getExtras(); setEncryptionKeyIds(bundle .getLongArray(SelectPublicKeyActivity.RESULT_EXTRA_MASTER_KEY_IDS)); + setEncryptionUserIds(bundle.getStringArray(SelectPublicKeyActivity.RESULT_EXTRA_USER_IDS)); } break; } -- cgit v1.2.3