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

View File

@ -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<String> mDeletedIDs = new ArrayList<String>();
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<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()
{
ArrayList<Boolean> mList = new ArrayList<Boolean>();
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;

View File

@ -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;
}
}