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 0aa8b7410..66f1f3f01 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 @@ -478,7 +478,9 @@ public class PgpKeyOperation { PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); sigList.add(new Pair(userId, certification)); } - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + if (!saveParcel.newIDs[userIDIndex]) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + } userIDIndex++; } for (Pair toAdd : sigList) { @@ -500,7 +502,9 @@ public class PgpKeyOperation { sGen.setUnhashedSubpackets(unhashedPacketsGen.generate()); } PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + if (!saveParcel.newIDs[userIDIndex]) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + } masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); } userIDIndex++; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index c99284847..b7ae4e1f1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -32,6 +32,7 @@ public class SaveKeyringParcel implements Parcelable { public ArrayList userIDs; public ArrayList originalIDs; public ArrayList deletedIDs; + public boolean[] newIDs; public boolean primaryIDChanged; public boolean[] moddedKeys; public ArrayList deletedKeys; @@ -50,6 +51,7 @@ public class SaveKeyringParcel implements Parcelable { userIDs = (ArrayList)source.readSerializable(); originalIDs = (ArrayList)source.readSerializable(); deletedIDs = (ArrayList)source.readSerializable(); + newIDs = source.createBooleanArray(); primaryIDChanged = source.readByte() != 0; moddedKeys = source.createBooleanArray(); byte[] tmp = source.createByteArray(); @@ -72,6 +74,7 @@ public class SaveKeyringParcel implements Parcelable { destination.writeSerializable(userIDs); //might not be the best method to store. destination.writeSerializable(originalIDs); destination.writeSerializable(deletedIDs); + destination.writeBooleanArray(newIDs); destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); destination.writeBooleanArray(moddedKeys); byte[] tmp = null; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 2cdd64f4a..a9ab49c76 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -584,6 +584,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener saveParams.userIDs = getUserIds(mUserIdsView); saveParams.originalIDs = mUserIdsView.getOriginalIDs(); saveParams.deletedIDs = mUserIdsView.getDeletedIDs(); + saveParams.newIDs = toPrimitiveArray(mUserIdsView.getNewIDFlags()); saveParams.primaryIDChanged = mUserIdsView.primaryChanged(); saveParams.moddedKeys = toPrimitiveArray(mKeysView.getNeedsSavingArray()); saveParams.deletedKeys = mKeysView.getDeletedKeys(); 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 6c7737e6d..e99a4ef04 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 @@ -252,6 +252,16 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return mList; } + public List getNewIDFlags() + { + ArrayList mList = new ArrayList(); + for (int i = 0; i < mEditors.getChildCount(); ++i) { + Editor editor = (Editor) mEditors.getChildAt(i); + mList.add(((UserIdEditor)editor).getIsNewID()); + } + return mList; + } + public List getNewKeysArray() { ArrayList mList = new ArrayList(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index d4b15613a..cf0cb6d44 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -261,4 +261,6 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene { return mOriginalID; } + + public boolean getIsNewID() { return mIsNewId; } }