From 6d4a09f9890d152db32ce72c58a7a60d44a4ecae Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 2 Apr 2014 00:00:24 +0100 Subject: [PATCH] allow blank IDs, allow adding new IDs and let them be master --- .../sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 6 +++--- .../sufficientlysecure/keychain/ui/widget/SectionView.java | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 66f1f3f01..871b5b18b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -458,7 +458,7 @@ public class PgpKeyOperation { ArrayList> sigList = new ArrayList>(); for (String userId : saveParcel.userIDs) { String origID = saveParcel.originalIDs.get(userIDIndex); - if (origID.equals(userId) && !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) { + if ((origID.equals(userId) && !saveParcel.newIDs[userIDIndex]) && !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) { Iterator origSigs = masterPublicKey.getSignaturesForID(origID); //TODO: make sure this iterator only has signatures we are interested in while (origSigs.hasNext()) { PGPSignature origSig = origSigs.next(); @@ -489,7 +489,7 @@ public class PgpKeyOperation { } else { for (String userId : saveParcel.userIDs) { String origID = saveParcel.originalIDs.get(userIDIndex); - if (!origID.equals(userId)) { + if (!origID.equals(userId) || saveParcel.newIDs[userIDIndex]) { anyIDChanged = true; PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) @@ -516,7 +516,7 @@ public class PgpKeyOperation { userIDIndex = 0; for (String userId : saveParcel.userIDs) { String origID = saveParcel.originalIDs.get(userIDIndex); - if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) { + if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged) || !saveParcel.newIDs[userIDIndex]) { Iterator sigs = masterPublicKey.getSignaturesForID(userId); //TODO: make sure this iterator only has signatures we are interested in while (sigs.hasNext()) { PGPSignature sig = sigs.next(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index e99a4ef04..e6b22957b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -256,8 +256,11 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor { ArrayList mList = new ArrayList(); for (int i = 0; i < mEditors.getChildCount(); ++i) { - Editor editor = (Editor) mEditors.getChildAt(i); - mList.add(((UserIdEditor)editor).getIsNewID()); + UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); + if (editor.isMainUserId()) + mList.add(0, editor.getIsNewID()); + else + mList.add(editor.getIsNewID()); } return mList; }