From 52ad83e34536ea79ea5982b16811d3a7f38cdf59 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Thu, 17 Apr 2014 12:09:09 +0200 Subject: secret keys can only be deleted individually from multi selection --- .../sufficientlysecure/keychain/ui/KeyListFragment.java | 16 ++++++++++++---- OpenKeychain/src/main/res/values/strings.xml | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'OpenKeychain/src/main') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 5024a17ed..ebc21a926 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -55,6 +55,7 @@ import android.widget.ListView; import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; +import com.devspark.appmsg.AppMsg; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -186,7 +187,7 @@ public class KeyListFragment extends Fragment } case R.id.menu_key_list_multi_delete: { ids = mAdapter.getCurrentSelectedMasterKeyIds(); - showDeleteKeyDialog(mode, ids); + showDeleteKeyDialog(mode, ids, mAdapter.isAnySecretSelected()); break; } case R.id.menu_key_list_multi_export: { @@ -263,7 +264,7 @@ public class KeyListFragment extends Fragment static final int INDEX_VERIFIED = 5; static final int INDEX_HAS_ANY_SECRET = 6; - static final String ORDER = // IN THE COURT + static final String ORDER = KeyRings.HAS_ANY_SECRET + " DESC, " + KeyRings.USER_ID + " ASC"; @@ -339,10 +340,17 @@ public class KeyListFragment extends Fragment * Show dialog to delete key * * @param masterKeyIds + * @param hasSecret must contain whether the list of masterKeyIds contains a secret key or not */ @TargetApi(11) - // TODO: this method needs an overhaul to handle both public and secret keys gracefully! - public void showDeleteKeyDialog(final ActionMode mode, long[] masterKeyIds) { + public void showDeleteKeyDialog(final ActionMode mode, long[] masterKeyIds, boolean hasSecret) { + // Can only work on singular secret keys + if(hasSecret && masterKeyIds.length > 1) { + AppMsg.makeText(getActivity(), R.string.secret_cannot_multiple, + AppMsg.STYLE_ALERT).show(); + return; + } + // Message is received after key is deleted Handler returnHandler = new Handler() { @Override diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 0a855ae70..4ea5d7adc 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -219,7 +219,7 @@ Please specify which file to export to.\nWARNING: File will be overwritten if it exists. Please specify which file to export to.\nWARNING: You are about to export SECRET keys.\nWARNING: File will be overwritten if it exists. Do you really want to delete the key \'%s\'?\nYou can\'t undo this! - Do you really want to delete all selected keys (including secret keys)?\nYou can\'t undo this! + Do you really want to delete all selected public 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?" @@ -537,5 +537,6 @@ Error processing key! subkey unavailable stripped + Secret keys can only be deleted individually! -- cgit v1.2.3