From ba62d30563ee5dd316528decd272f1bbdcbee5bd Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Fri, 14 Feb 2014 17:40:11 +0000 Subject: [PATCH] propgate through --- .../keychain/ui/EditKeyActivity.java | 7 +++-- .../keychain/ui/widget/SectionView.java | 29 ++++++++++++++----- .../keychain/ui/widget/UserIdEditor.java | 7 +++++ 3 files changed, 33 insertions(+), 10 deletions(-) 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 5adb65342..9ebe73197 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 @@ -586,9 +586,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener getKeysExpiryDates(mKeysView)); data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId()); data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, masterCanSign); - data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, ); - data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, - toPrimitiveArray(mUserIdsView.getNeedsSavingArray())); + data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_DELETED_IDS, + mUserIdsView.getDeletedIDs()); + data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, + mUserIdsView.getOriginalIDs()); data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_MODDED_KEYS, toPrimitiveArray(mKeysView.getNeedsSavingArray())); 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 5eaf54841..788a80a60 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 @@ -65,6 +65,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor private int mNewKeySize; private boolean canEdit = true; private boolean oldItemDeleted = false; + private ArrayList mDeletedIDs = new ArrayList(); private ActionBarActivity mActivity; @@ -135,6 +136,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor /** {@inheritDoc} */ public void onDeleted(Editor editor, boolean wasNewItem) { oldItemDeleted |= !wasNewItem; + if (oldItemDeleted && mType == Id.type.user_id) + mDeletedIDs.add(((UserIdEditor)editor).getOriginalID()); this.updateEditorsVisible(); if (mEditorListener != null) { mEditorListener.onEdited(); @@ -164,18 +167,30 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return ret; } + public ArrayList getOriginalIDs() + { + ArrayList orig = new ArrayList(); + if (mType == Id.type.user_id) { + for (int i = 0; i < mEditors.getChildCount(); ++i) { + UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); + orig.add(editor.getOriginalID()); + } + return orig; + } else { + return null; + } + } + + public ArrayList getDeletedIDs() + { + return mDeletedIDs; + } + public List getNeedsSavingArray() { ArrayList mList = new ArrayList(); for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); - if (mType == Id.type.user_id) { - try { - if (((UserIdEditor)editor).getValue().equals("")) //other code ignores empty user id - continue; - } catch (UserIdEditor.InvalidEmailException e) { - } - } mList.add(editor.needsSaving()); } return mList; 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 b499a429a..37ab0e051 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 @@ -40,6 +40,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene private BootstrapButton mDeleteButton; private RadioButton mIsMainUserId; + private String mOriginalID; private EditText mName; private String mOriginalName; private EditText mEmail; @@ -130,6 +131,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene mEmail.setText(""); mOriginalEmail = ""; mIsNewId = isNewId; + mOriginalID = userId; String[] result = PgpKeyHelper.splitUserId(userId); if (result[0] != null) { @@ -226,4 +228,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene retval |= mIsNewId; return retval; } + + public String getOriginalID() + { + return mOriginalID; + } }