pass through info that keys are new without relying on new keys orginally being empty

This commit is contained in:
Ashley Hughes 2014-04-01 23:37:13 +01:00
parent abfe416503
commit 2ad616ed3f
5 changed files with 22 additions and 2 deletions

View File

@ -478,7 +478,9 @@ public class PgpKeyOperation {
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey);
sigList.add(new Pair<String, PGPSignature>(userId, certification));
}
if (!saveParcel.newIDs[userIDIndex]) {
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID);
}
userIDIndex++;
}
for (Pair<String, PGPSignature> toAdd : sigList) {
@ -500,7 +502,9 @@ public class PgpKeyOperation {
sGen.setUnhashedSubpackets(unhashedPacketsGen.generate());
}
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey);
if (!saveParcel.newIDs[userIDIndex]) {
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID);
}
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification);
}
userIDIndex++;

View File

@ -32,6 +32,7 @@ public class SaveKeyringParcel implements Parcelable {
public ArrayList<String> userIDs;
public ArrayList<String> originalIDs;
public ArrayList<String> deletedIDs;
public boolean[] newIDs;
public boolean primaryIDChanged;
public boolean[] moddedKeys;
public ArrayList<PGPSecretKey> deletedKeys;
@ -50,6 +51,7 @@ public class SaveKeyringParcel implements Parcelable {
userIDs = (ArrayList<String>)source.readSerializable();
originalIDs = (ArrayList<String>)source.readSerializable();
deletedIDs = (ArrayList<String>)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;

View File

@ -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();

View File

@ -252,6 +252,16 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
return mList;
}
public List<Boolean> getNewIDFlags()
{
ArrayList<Boolean> mList = new ArrayList<Boolean>();
for (int i = 0; i < mEditors.getChildCount(); ++i) {
Editor editor = (Editor) mEditors.getChildAt(i);
mList.add(((UserIdEditor)editor).getIsNewID());
}
return mList;
}
public List<Boolean> getNewKeysArray()
{
ArrayList<Boolean> mList = new ArrayList<Boolean>();

View File

@ -261,4 +261,6 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
{
return mOriginalID;
}
public boolean getIsNewID() { return mIsNewId; }
}