From 305b8c1858247a0c0a1f73a405d4c2cf0733e818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 11 Apr 2014 19:52:59 +0200 Subject: Simplify and fix delete key dialog --- .../ui/dialog/DeleteKeyDialogFragment.java | 28 +++++----------------- .../main/res/layout/view_key_delete_fragment.xml | 24 ------------------- OpenKeychain/src/main/res/values/strings.xml | 5 ++-- 3 files changed, 8 insertions(+), 49 deletions(-) (limited to 'OpenKeychain') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index c717f80ec..7b4a7be83 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -28,15 +28,12 @@ import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.view.LayoutInflater; import android.view.View; -import android.widget.CheckBox; -import android.widget.LinearLayout; import android.widget.TextView; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.util.Log; @@ -49,11 +46,7 @@ public class DeleteKeyDialogFragment extends DialogFragment { public static final int MESSAGE_OKAY = 1; public static final int MESSAGE_ERROR = 0; - private boolean mIsSingleSelection = false; - private TextView mMainMessage; - private CheckBox mCheckDeleteSecret; - private LinearLayout mDeleteSecretKeyView; private View mInflateView; private Messenger mMessenger; @@ -61,14 +54,12 @@ public class DeleteKeyDialogFragment extends DialogFragment { /** * Creates new instance of this delete file dialog fragment */ - public static DeleteKeyDialogFragment newInstance(Messenger messenger, - long[] masterKeyIds) { + public static DeleteKeyDialogFragment newInstance(Messenger messenger, long[] masterKeyIds) { DeleteKeyDialogFragment frag = new DeleteKeyDialogFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_MESSENGER, messenger); args.putLongArray(ARG_DELETE_MASTER_KEY_IDS, masterKeyIds); - //We don't need the key type frag.setArguments(args); @@ -85,39 +76,32 @@ public class DeleteKeyDialogFragment extends DialogFragment { AlertDialog.Builder builder = new AlertDialog.Builder(activity); - //Setup custom View to display in AlertDialog + // Setup custom View to display in AlertDialog LayoutInflater inflater = activity.getLayoutInflater(); mInflateView = inflater.inflate(R.layout.view_key_delete_fragment, null); builder.setView(mInflateView); - mDeleteSecretKeyView = (LinearLayout) mInflateView.findViewById(R.id.deleteSecretKeyView); mMainMessage = (TextView) mInflateView.findViewById(R.id.mainMessage); - mCheckDeleteSecret = (CheckBox) mInflateView.findViewById(R.id.checkDeleteSecret); builder.setTitle(R.string.warning); // If only a single key has been selected if (masterKeyIds.length == 1) { - mIsSingleSelection = true; - long masterKeyId = masterKeyIds[0]; HashMap data = new ProviderHelper(activity).getUnifiedData(masterKeyId, new String[]{ KeyRings.USER_ID, KeyRings.HAS_SECRET - }, new int[] { ProviderHelper.FIELD_TYPE_STRING, ProviderHelper.FIELD_TYPE_INTEGER }); + }, new int[]{ProviderHelper.FIELD_TYPE_STRING, ProviderHelper.FIELD_TYPE_INTEGER}); String userId = (String) data.get(KeyRings.USER_ID); boolean hasSecret = ((Long) data.get(KeyRings.HAS_SECRET)) == 1; - // Hide the Checkbox and TextView since this is a single selection,user will be notified through message - mDeleteSecretKeyView.setVisibility(View.GONE); // Set message depending on which key it is. mMainMessage.setText(getString( hasSecret ? R.string.secret_key_deletion_confirmation - : R.string.public_key_deletetion_confirmation, + : R.string.public_key_deletetion_confirmation, userId)); } else { - mDeleteSecretKeyView.setVisibility(View.VISIBLE); mMainMessage.setText(R.string.key_deletion_confirmation_multi); } @@ -127,10 +111,10 @@ public class DeleteKeyDialogFragment extends DialogFragment { public void onClick(DialogInterface dialog, int which) { boolean success = false; - for(long masterKeyId : masterKeyIds) { + for (long masterKeyId : masterKeyIds) { int count = activity.getContentResolver().delete( KeyRingData.buildPublicKeyRingUri(Long.toString(masterKeyId)), null, null - ); + ); success = count > 0; } if (success) { diff --git a/OpenKeychain/src/main/res/layout/view_key_delete_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_delete_fragment.xml index ef31f7690..bbc723bfa 100644 --- a/OpenKeychain/src/main/res/layout/view_key_delete_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_delete_fragment.xml @@ -1,5 +1,4 @@ - - - - - - - - - \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index a58e3a484..71340f6ec 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -220,12 +220,11 @@ 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?\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 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 ? + Do you really want to delete the public key \'%s\'?\nYou can\'t undo this! Also export secret keys? -- cgit v1.2.3