diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-06 00:58:04 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-06 00:59:02 +0100 |
commit | 708baaa68c76391a3e15cd086d3829eb058819c9 (patch) | |
tree | 575852431114003becdc608fc149f87207795ae0 /OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java | |
parent | 28d9a2f26b71158823d73451bf25e1f5cf0c5431 (diff) | |
download | open-keychain-708baaa68c76391a3e15cd086d3829eb058819c9.tar.gz open-keychain-708baaa68c76391a3e15cd086d3829eb058819c9.tar.bz2 open-keychain-708baaa68c76391a3e15cd086d3829eb058819c9.zip |
Work on multiselect in key list
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java')
-rw-r--r-- | OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 638702b57..101167777 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -38,7 +38,7 @@ import android.support.v4.app.FragmentActivity; public class DeleteKeyDialogFragment extends DialogFragment { private static final String ARG_MESSENGER = "messenger"; - private static final String ARG_DELETE_KEY_RING_ROW_ID = "delete_file"; + private static final String ARG_DELETE_KEY_RING_ROW_IDS = "delete_file"; private static final String ARG_KEY_TYPE = "key_type"; public static final int MESSAGE_OKAY = 1; @@ -48,13 +48,13 @@ public class DeleteKeyDialogFragment extends DialogFragment { /** * Creates new instance of this delete file dialog fragment */ - public static DeleteKeyDialogFragment newInstance(Messenger messenger, long deleteKeyRingRowId, + public static DeleteKeyDialogFragment newInstance(Messenger messenger, long[] keyRingRowIds, int keyType) { DeleteKeyDialogFragment frag = new DeleteKeyDialogFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_MESSENGER, messenger); - args.putLong(ARG_DELETE_KEY_RING_ROW_ID, deleteKeyRingRowId); + args.putLongArray(ARG_DELETE_KEY_RING_ROW_IDS, keyRingRowIds); args.putInt(ARG_KEY_TYPE, keyType); frag.setArguments(args); @@ -70,36 +70,48 @@ public class DeleteKeyDialogFragment extends DialogFragment { final FragmentActivity activity = getActivity(); mMessenger = getArguments().getParcelable(ARG_MESSENGER); - final long deleteKeyRingRowId = getArguments().getLong(ARG_DELETE_KEY_RING_ROW_ID); + final long[] keyRingRowIds = getArguments().getLongArray(ARG_DELETE_KEY_RING_ROW_IDS); final int keyType = getArguments().getInt(ARG_KEY_TYPE); - // TODO: better way to do this? - String userId = activity.getString(R.string.unknown_user_id); + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setTitle(R.string.warning); + + if (keyRingRowIds.length == 1) { + // TODO: better way to do this? + String userId = activity.getString(R.string.unknown_user_id); + + if (keyType == Id.type.public_key) { + PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRingByRowId(activity, + keyRingRowIds[0]); + userId = PgpKeyHelper.getMainUserIdSafe(activity, + PgpKeyHelper.getMasterKey(keyRing)); + } else { + PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByRowId(activity, + keyRingRowIds[0]); + userId = PgpKeyHelper.getMainUserIdSafe(activity, + PgpKeyHelper.getMasterKey(keyRing)); + } - if (keyType == Id.type.public_key) { - PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRingByRowId(activity, - deleteKeyRingRowId); - userId = PgpKeyHelper.getMainUserIdSafe(activity, PgpKeyHelper.getMasterKey(keyRing)); + builder.setMessage(getString( + keyType == Id.type.public_key ? R.string.key_deletion_confirmation + : R.string.secret_key_deletion_confirmation, userId)); } else { - PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByRowId(activity, - deleteKeyRingRowId); - userId = PgpKeyHelper.getMainUserIdSafe(activity, PgpKeyHelper.getMasterKey(keyRing)); + builder.setMessage(R.string.key_deletion_confirmation_multi); } - AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setTitle(R.string.warning); - builder.setMessage(getString( - keyType == Id.type.public_key ? R.string.key_deletion_confirmation - : R.string.secret_key_deletion_confirmation, userId)); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setPositiveButton(R.string.btn_delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (keyType == Id.type.public_key) { - ProviderHelper.deletePublicKeyRing(activity, deleteKeyRingRowId); + for (long keyRowId : keyRingRowIds) { + ProviderHelper.deletePublicKeyRing(activity, keyRowId); + } } else { - ProviderHelper.deleteSecretKeyRing(activity, deleteKeyRingRowId); + for (long keyRowId : keyRingRowIds) { + ProviderHelper.deleteSecretKeyRing(activity, keyRowId); + } } dismiss(); |