From 9764d3fcb98c782a9a16cb090eb019bd8e5e595e Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 2 Apr 2014 01:26:51 +0100 Subject: [PATCH] confirm that empty IDs are really wanted --- .../keychain/ui/EditKeyActivity.java | 47 ++++++++++++++++++- .../src/main/res/values/strings.xml | 1 + 2 files changed, 47 insertions(+), 1 deletion(-) 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 a9ab49c76..633249d15 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 @@ -553,7 +553,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener showPassphraseDialog(masterKeyId); } else { mCurrentPassphrase = passphrase; - finallySaveClicked(); + checkEmptyIDsWanted(); } } catch (PgpGeneralException e) { Toast.makeText(this, getString(R.string.error_message, e.getMessage()), @@ -564,6 +564,51 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } + private void checkEmptyIDsWanted() + { + try { + ArrayList userIDs = getUserIds(mUserIdsView); + List newIDs = mUserIdsView.getNewIDFlags(); + ArrayList originalIDs = mUserIdsView.getOriginalIDs(); + int curID = 0; + for (String userID : userIDs) { + if ( userID.equals("") && (!userID.equals(originalIDs.get(curID)) || newIDs.get(curID) ) ) { + AlertDialog.Builder alert = new AlertDialog.Builder( + EditKeyActivity.this); + + alert.setIcon(android.R.drawable.ic_dialog_alert); + alert.setTitle(R.string.warning); + alert.setMessage(EditKeyActivity.this.getString(R.string.ask_empty_id_ok)); + + alert.setPositiveButton(EditKeyActivity.this.getString(android.R.string.yes), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + finallySaveClicked(); + } + } + ); + alert.setNegativeButton(this.getString(android.R.string.no), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + } + } + ); + alert.setCancelable(false); + alert.create().show(); + return; + } + curID++; + } + } catch (PgpGeneralException e) { + Log.e(Constants.TAG, getString(R.string.error_message, e.getMessage())); + Toast.makeText(this, getString(R.string.error_message, e.getMessage()), + Toast.LENGTH_SHORT).show(); + } + finallySaveClicked(); + } + private boolean[] toPrimitiveArray(final List booleanList) { final boolean[] primitives = new boolean[booleanList.size()]; int index = 0; diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index c9ef6a135..54db372ab 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -225,6 +225,7 @@ Do you really want to delete all selected keys?\nYou can\'t undo this! Do you really want to delete the SECRET key \'%s\'?\nYou can\'t undo this! You have made changes to the keyring, would you like to save it? + "You have added an empty user ID, are you sure you want to continue?" Do you really want to delete the PUBLIC key \'%s\'?\nYou can\'t undo this! Delete Secret Keys ? Also export secret keys?