secret keys can only be deleted individually from multi selection

This commit is contained in:
Vincent Breitmoser 2014-04-17 12:09:09 +02:00
parent d19830cd1c
commit 52ad83e345
2 changed files with 14 additions and 5 deletions

View File

@ -55,6 +55,7 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import com.beardedhen.androidbootstrap.BootstrapButton; import com.beardedhen.androidbootstrap.BootstrapButton;
import com.devspark.appmsg.AppMsg;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
@ -186,7 +187,7 @@ public class KeyListFragment extends Fragment
} }
case R.id.menu_key_list_multi_delete: { case R.id.menu_key_list_multi_delete: {
ids = mAdapter.getCurrentSelectedMasterKeyIds(); ids = mAdapter.getCurrentSelectedMasterKeyIds();
showDeleteKeyDialog(mode, ids); showDeleteKeyDialog(mode, ids, mAdapter.isAnySecretSelected());
break; break;
} }
case R.id.menu_key_list_multi_export: { 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_VERIFIED = 5;
static final int INDEX_HAS_ANY_SECRET = 6; 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"; KeyRings.HAS_ANY_SECRET + " DESC, " + KeyRings.USER_ID + " ASC";
@ -339,10 +340,17 @@ public class KeyListFragment extends Fragment
* Show dialog to delete key * Show dialog to delete key
* *
* @param masterKeyIds * @param masterKeyIds
* @param hasSecret must contain whether the list of masterKeyIds contains a secret key or not
*/ */
@TargetApi(11) @TargetApi(11)
// TODO: this method needs an overhaul to handle both public and secret keys gracefully! public void showDeleteKeyDialog(final ActionMode mode, long[] masterKeyIds, boolean hasSecret) {
public void showDeleteKeyDialog(final ActionMode mode, long[] masterKeyIds) { // 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 // Message is received after key is deleted
Handler returnHandler = new Handler() { Handler returnHandler = new Handler() {
@Override @Override

View File

@ -219,7 +219,7 @@
<string name="specify_file_to_export_to">Please specify which file to export to.\nWARNING: File will be overwritten if it exists.</string> <string name="specify_file_to_export_to">Please specify which file to export to.\nWARNING: File will be overwritten if it exists.</string>
<string name="specify_file_to_export_secret_keys_to">Please specify which file to export to.\nWARNING: You are about to export SECRET keys.\nWARNING: File will be overwritten if it exists.</string> <string name="specify_file_to_export_secret_keys_to">Please specify which file to export to.\nWARNING: You are about to export SECRET keys.\nWARNING: File will be overwritten if it exists.</string>
<string name="key_deletion_confirmation">Do you really want to delete the key \'%s\'?\nYou can\'t undo this!</string> <string name="key_deletion_confirmation">Do you really want to delete the key \'%s\'?\nYou can\'t undo this!</string>
<string name="key_deletion_confirmation_multi">Do you really want to delete all selected keys (including secret keys)?\nYou can\'t undo this!</string> <string name="key_deletion_confirmation_multi">Do you really want to delete all selected public keys?\nYou can\'t undo this!</string>
<string name="secret_key_deletion_confirmation">Do you really want to delete the SECRET key \'%s\'?\nYou can\'t undo this!</string> <string name="secret_key_deletion_confirmation">Do you really want to delete the SECRET key \'%s\'?\nYou can\'t undo this!</string>
<string name="ask_save_changed_key">You have made changes to the keyring, would you like to save it?</string> <string name="ask_save_changed_key">You have made changes to the keyring, would you like to save it?</string>
<string name="ask_empty_id_ok">"You have added an empty user ID, are you sure you want to continue?"</string> <string name="ask_empty_id_ok">"You have added an empty user ID, are you sure you want to continue?"</string>
@ -537,5 +537,6 @@
<string name="error_key_processing">Error processing key!</string> <string name="error_key_processing">Error processing key!</string>
<string name="no_subkey">subkey unavailable</string> <string name="no_subkey">subkey unavailable</string>
<string name="key_stripped">stripped</string> <string name="key_stripped">stripped</string>
<string name="secret_cannot_multiple">Secret keys can only be deleted individually!</string>
</resources> </resources>