propgate through

This commit is contained in:
Ashley Hughes 2014-02-14 17:40:11 +00:00
parent 076a7ec4a1
commit ba62d30563
3 changed files with 33 additions and 10 deletions

View File

@ -586,9 +586,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
getKeysExpiryDates(mKeysView)); getKeysExpiryDates(mKeysView));
data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId()); data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId());
data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, masterCanSign); data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, masterCanSign);
data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, ); data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_DELETED_IDS,
data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, mUserIdsView.getDeletedIDs());
toPrimitiveArray(mUserIdsView.getNeedsSavingArray())); data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS,
mUserIdsView.getOriginalIDs());
data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_MODDED_KEYS, data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_MODDED_KEYS,
toPrimitiveArray(mKeysView.getNeedsSavingArray())); toPrimitiveArray(mKeysView.getNeedsSavingArray()));

View File

@ -65,6 +65,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
private int mNewKeySize; private int mNewKeySize;
private boolean canEdit = true; private boolean canEdit = true;
private boolean oldItemDeleted = false; private boolean oldItemDeleted = false;
private ArrayList<String> mDeletedIDs = new ArrayList<String>();
private ActionBarActivity mActivity; private ActionBarActivity mActivity;
@ -135,6 +136,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
/** {@inheritDoc} */ /** {@inheritDoc} */
public void onDeleted(Editor editor, boolean wasNewItem) { public void onDeleted(Editor editor, boolean wasNewItem) {
oldItemDeleted |= !wasNewItem; oldItemDeleted |= !wasNewItem;
if (oldItemDeleted && mType == Id.type.user_id)
mDeletedIDs.add(((UserIdEditor)editor).getOriginalID());
this.updateEditorsVisible(); this.updateEditorsVisible();
if (mEditorListener != null) { if (mEditorListener != null) {
mEditorListener.onEdited(); mEditorListener.onEdited();
@ -164,18 +167,30 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
return ret; return ret;
} }
public ArrayList<String> getOriginalIDs()
{
ArrayList<String> orig = new ArrayList<String>();
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<String> getDeletedIDs()
{
return mDeletedIDs;
}
public List<Boolean> getNeedsSavingArray() public List<Boolean> getNeedsSavingArray()
{ {
ArrayList<Boolean> mList = new ArrayList<Boolean>(); ArrayList<Boolean> mList = new ArrayList<Boolean>();
for (int i = 0; i < mEditors.getChildCount(); ++i) { for (int i = 0; i < mEditors.getChildCount(); ++i) {
Editor editor = (Editor) mEditors.getChildAt(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()); mList.add(editor.needsSaving());
} }
return mList; return mList;

View File

@ -40,6 +40,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
private BootstrapButton mDeleteButton; private BootstrapButton mDeleteButton;
private RadioButton mIsMainUserId; private RadioButton mIsMainUserId;
private String mOriginalID;
private EditText mName; private EditText mName;
private String mOriginalName; private String mOriginalName;
private EditText mEmail; private EditText mEmail;
@ -130,6 +131,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
mEmail.setText(""); mEmail.setText("");
mOriginalEmail = ""; mOriginalEmail = "";
mIsNewId = isNewId; mIsNewId = isNewId;
mOriginalID = userId;
String[] result = PgpKeyHelper.splitUserId(userId); String[] result = PgpKeyHelper.splitUserId(userId);
if (result[0] != null) { if (result[0] != null) {
@ -226,4 +228,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
retval |= mIsNewId; retval |= mIsNewId;
return retval; return retval;
} }
public String getOriginalID()
{
return mOriginalID;
}
} }