This commit is contained in:
Nikhil Peter Raj 2014-03-21 01:50:20 +05:30
parent 77365202e0
commit 2816461283
8 changed files with 185 additions and 140 deletions

View File

@ -53,14 +53,14 @@ public class ExportHelper {
this.mActivity = activity; this.mActivity = activity;
} }
public void deleteKey(Uri dataUri, final int keyType, Handler deleteHandler) { public void deleteKey(Uri dataUri, Handler deleteHandler) {
long keyRingRowId = Long.valueOf(dataUri.getLastPathSegment()); long keyRingRowId = Long.valueOf(dataUri.getLastPathSegment());
// Create a new Messenger for the communication back // Create a new Messenger for the communication back
Messenger messenger = new Messenger(deleteHandler); Messenger messenger = new Messenger(deleteHandler);
DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger, DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger,
new long[]{keyRingRowId}, keyType); new long[]{keyRingRowId});
deleteKeyDialog.show(mActivity.getSupportFragmentManager(), "deleteKeyDialog"); deleteKeyDialog.show(mActivity.getSupportFragmentManager(), "deleteKeyDialog");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2013 Dominik Schürmann <dominik@dominikschuermann.de> * Copyright (C) 2012-2013 Dominik Schürmann <dominik@dominikschuermann.de>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -230,7 +230,7 @@ public class ProviderHelper {
// get current _ID of key // get current _ID of key
long currentRowId = -1; long currentRowId = -1;
Cursor oldQuery = context.getContentResolver() Cursor oldQuery = context.getContentResolver()
.query(deleteUri, new String[]{KeyRings._ID}, null, null, null); .query(deleteUri, new String[]{KeyRings._ID}, null, null, null);
if (oldQuery != null && oldQuery.moveToFirst()) { if (oldQuery != null && oldQuery.moveToFirst()) {
currentRowId = oldQuery.getLong(0); currentRowId = oldQuery.getLong(0);
} else { } else {
@ -288,7 +288,7 @@ public class ProviderHelper {
* Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing * Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing
*/ */
private static ContentProviderOperation buildPublicKeyOperations(Context context, private static ContentProviderOperation buildPublicKeyOperations(Context context,
long keyRingRowId, PGPPublicKey key, int rank) throws IOException { long keyRingRowId, PGPPublicKey key, int rank) throws IOException {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(Keys.KEY_ID, key.getKeyID()); values.put(Keys.KEY_ID, key.getKeyID());
values.put(Keys.IS_MASTER_KEY, key.isMasterKey()); values.put(Keys.IS_MASTER_KEY, key.isMasterKey());
@ -316,7 +316,7 @@ public class ProviderHelper {
* Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing * Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing
*/ */
private static ContentProviderOperation buildPublicUserIdOperations(Context context, private static ContentProviderOperation buildPublicUserIdOperations(Context context,
long keyRingRowId, String userId, int rank) { long keyRingRowId, String userId, int rank) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId); values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId);
values.put(UserIds.USER_ID, userId); values.put(UserIds.USER_ID, userId);
@ -331,7 +331,7 @@ public class ProviderHelper {
* Build ContentProviderOperation to add PGPSecretKey to database corresponding to a keyRing * Build ContentProviderOperation to add PGPSecretKey to database corresponding to a keyRing
*/ */
private static ContentProviderOperation buildSecretKeyOperations(Context context, private static ContentProviderOperation buildSecretKeyOperations(Context context,
long keyRingRowId, PGPSecretKey key, int rank) throws IOException { long keyRingRowId, PGPSecretKey key, int rank) throws IOException {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
boolean hasPrivate = true; boolean hasPrivate = true;
@ -368,7 +368,7 @@ public class ProviderHelper {
* Build ContentProviderOperation to add SecretUserIds to database corresponding to a keyRing * Build ContentProviderOperation to add SecretUserIds to database corresponding to a keyRing
*/ */
private static ContentProviderOperation buildSecretUserIdOperations(Context context, private static ContentProviderOperation buildSecretUserIdOperations(Context context,
long keyRingRowId, String userId, int rank) { long keyRingRowId, String userId, int rank) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId); values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId);
values.put(UserIds.USER_ID, userId); values.put(UserIds.USER_ID, userId);
@ -469,6 +469,15 @@ public class ProviderHelper {
cr.delete(KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)), null, null); cr.delete(KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)), null, null);
} }
public static void deleteUnifiedKeyRing(Context context,String masterKeyId,boolean isSecretKey){
ContentResolver cr= context.getContentResolver();
cr.delete(KeyRings.buildPublicKeyRingsByMasterKeyIdUri(masterKeyId),null,null);
if(isSecretKey){
cr.delete(KeyRings.buildSecretKeyRingsByMasterKeyIdUri(masterKeyId),null,null);
}
}
/** /**
* Get master key id of keyring by its row id * Get master key id of keyring by its row id
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2013 Dominik Schürmann <dominik@dominikschuermann.de> * Copyright (C) 2012-2013 Dominik Schürmann <dominik@dominikschuermann.de>
* Copyright (C) 2010 Thialfihar <thi@thialfihar.org> * Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -46,6 +46,7 @@ import org.sufficientlysecure.keychain.helper.ExportHelper;
import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
@ -58,7 +59,6 @@ import org.sufficientlysecure.keychain.ui.widget.SectionView;
import org.sufficientlysecure.keychain.ui.widget.UserIdEditor; import org.sufficientlysecure.keychain.ui.widget.UserIdEditor;
import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.IterableIterator;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.Vector; import java.util.Vector;
@ -325,9 +325,13 @@ public class EditKeyActivity extends ActionBarActivity {
long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri);
long[] ids = new long[]{masterKeyId}; long[] ids = new long[]{masterKeyId};
mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC,
null); null);
return true; return true;
case R.id.menu_key_edit_delete: { case R.id.menu_key_edit_delete: {
//Convert the uri to one based on rowId
long rowId= ProviderHelper.getRowId(this,mDataUri);
Uri convertUri = KeychainContract.KeyRings.buildSecretKeyRingsUri(Long.toString(rowId));
// Message is received after key is deleted // Message is received after key is deleted
Handler returnHandler = new Handler() { Handler returnHandler = new Handler() {
@Override @Override
@ -339,7 +343,7 @@ public class EditKeyActivity extends ActionBarActivity {
} }
}; };
mExportHelper.deleteKey(mDataUri, Id.type.secret_key, returnHandler); mExportHelper.deleteKey(convertUri, returnHandler);
return true; return true;
} }
} }

View File

@ -355,25 +355,7 @@ public class KeyListFragment extends Fragment
@Override @Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) { if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) {
Bundle returnData = message.getData(); mode.finish();
if (returnData != null
&& returnData.containsKey(DeleteKeyDialogFragment.MESSAGE_NOT_DELETED)) {
ArrayList<String> notDeleted =
returnData.getStringArrayList(DeleteKeyDialogFragment.MESSAGE_NOT_DELETED);
String notDeletedMsg = "";
for (String userId : notDeleted) {
notDeletedMsg += userId + "\n";
}
Toast.makeText(getActivity(),
getString(R.string.error_can_not_delete_contacts, notDeletedMsg)
+ getResources()
.getQuantityString(
R.plurals.error_can_not_delete_info,
notDeleted.size()),
Toast.LENGTH_LONG).show();
mode.finish();
}
} }
} }
}; };
@ -382,7 +364,7 @@ public class KeyListFragment extends Fragment
Messenger messenger = new Messenger(returnHandler); Messenger messenger = new Messenger(returnHandler);
DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger, DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger,
keyRingRowIds, Id.type.public_key); keyRingRowIds);
deleteKeyDialog.show(getActivity().getSupportFragmentManager(), "deleteKeyDialog"); deleteKeyDialog.show(getActivity().getSupportFragmentManager(), "deleteKeyDialog");
} }

View File

@ -237,25 +237,12 @@ public class ViewKeyActivity extends ActionBarActivity {
Handler returnHandler = new Handler() { Handler returnHandler = new Handler() {
@Override @Override
public void handleMessage(Message message) { public void handleMessage(Message message) {
if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) { setResult(RESULT_CANCELED);
Bundle returnData = message.getData(); finish();
if (returnData != null
&& returnData.containsKey(DeleteKeyDialogFragment.MESSAGE_NOT_DELETED)) {
// we delete only this key, so MESSAGE_NOT_DELETED will solely contain this key
Toast.makeText(ViewKeyActivity.this,
getString(R.string.error_can_not_delete_contact)
+ getResources()
.getQuantityString(R.plurals.error_can_not_delete_info, 1),
Toast.LENGTH_LONG).show();
} else {
setResult(RESULT_CANCELED);
finish();
}
}
} }
}; };
mExportHelper.deleteKey(dataUri, Id.type.public_key, returnHandler); mExportHelper.deleteKey(dataUri, returnHandler);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2012-2013 Dominik Schürmann <dominik@dominikschuermann.de> * Copyright (C) 2013-2014 Dominik Schürmann <dominik@dominikschuermann.de>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.sufficientlysecure.keychain.ui.dialog; package org.sufficientlysecure.keychain.ui.dialog;
import android.app.AlertDialog; import android.app.AlertDialog;
@ -28,6 +27,11 @@ import android.os.Messenger;
import android.os.RemoteException; import android.os.RemoteException;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity; 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.Constants;
import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
@ -35,148 +39,167 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
public class DeleteKeyDialogFragment extends DialogFragment { public class DeleteKeyDialogFragment extends DialogFragment {
private static final String ARG_MESSENGER = "messenger"; private static final String ARG_MESSENGER = "messenger";
private static final String ARG_DELETE_KEY_RING_ROW_IDS = "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; public static final int MESSAGE_OKAY = 1;
public static final int MESSAGE_ERROR = 0;
public static final String MESSAGE_NOT_DELETED = "not_deleted"; private boolean isSingleSelection = false;
private TextView mainMessage;
private CheckBox checkDeleteSecret;
private LinearLayout deleteSecretKeyView;
private View inflateView;
private Messenger mMessenger; private Messenger mMessenger;
/** /**
* Creates new instance of this delete file dialog fragment * Creates new instance of this delete file dialog fragment
*/ */
public static DeleteKeyDialogFragment newInstance(Messenger messenger, long[] keyRingRowIds, public static DeleteKeyDialogFragment newInstance(Messenger messenger, long[] keyRingRowIds
int keyType) { ) {
DeleteKeyDialogFragment frag = new DeleteKeyDialogFragment(); DeleteKeyDialogFragment frag = new DeleteKeyDialogFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable(ARG_MESSENGER, messenger); args.putParcelable(ARG_MESSENGER, messenger);
args.putLongArray(ARG_DELETE_KEY_RING_ROW_IDS, keyRingRowIds); args.putLongArray(ARG_DELETE_KEY_RING_ROW_IDS, keyRingRowIds);
args.putInt(ARG_KEY_TYPE, keyType); //We don't need the key type
frag.setArguments(args); frag.setArguments(args);
return frag; return frag;
} }
/**
* Creates dialog
*/
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
final FragmentActivity activity = getActivity(); final FragmentActivity activity = getActivity();
mMessenger = getArguments().getParcelable(ARG_MESSENGER); mMessenger = getArguments().getParcelable(ARG_MESSENGER);
final long[] keyRingRowIds = getArguments().getLongArray(ARG_DELETE_KEY_RING_ROW_IDS); final long[] keyRingRowIds = getArguments().getLongArray(ARG_DELETE_KEY_RING_ROW_IDS);
final int keyType = getArguments().getInt(ARG_KEY_TYPE);
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
//Setup custom View to display in AlertDialog
LayoutInflater inflater = activity.getLayoutInflater();
inflateView = inflater.inflate(R.layout.view_key_delete_fragment, null);
builder.setView(inflateView);
deleteSecretKeyView = (LinearLayout) inflateView.findViewById(R.id.deleteSecretKeyView);
mainMessage = (TextView) inflateView.findViewById(R.id.mainMessage);
checkDeleteSecret = (CheckBox) inflateView.findViewById(R.id.checkDeleteSecret);
builder.setTitle(R.string.warning); builder.setTitle(R.string.warning);
//If only a single key has been selected
if (keyRingRowIds.length == 1) { if (keyRingRowIds.length == 1) {
Uri dataUri; Uri dataUri;
if (keyType == Id.type.public_key) { ArrayList<Long> publicKeyRings; //Any one will do
dataUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(String.valueOf(keyRingRowIds[0])); isSingleSelection = true;
} else {
dataUri = KeychainContract.KeyRings.buildSecretKeyRingsUri(String.valueOf(keyRingRowIds[0])); long selectedRow = keyRingRowIds[0];
} long keyType;
String userId = ProviderHelper.getUserId(activity, dataUri); publicKeyRings = ProviderHelper.getPublicKeyRingsRowIds(activity);
if (publicKeyRings.contains(selectedRow)) {
//TODO Should be a better method to do this other than getting all the KeyRings
dataUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(String.valueOf(selectedRow));
keyType = Id.type.public_key;
} else {
dataUri = KeychainContract.KeyRings.buildSecretKeyRingsUri(String.valueOf(selectedRow));
keyType = Id.type.secret_key;
}
String userId = ProviderHelper.getUserId(activity, dataUri);
//Hide the Checkbox and TextView since this is a single selection,user will be notified thru message
deleteSecretKeyView.setVisibility(View.GONE);
//Set message depending on which key it is.
mainMessage.setText(getString(keyType == Id.type.secret_key ? R.string.secret_key_deletion_confirmation
: R.string.public_key_deletetion_confirmation, userId));
builder.setMessage(getString(
keyType == Id.type.public_key ? R.string.key_deletion_confirmation
: R.string.secret_key_deletion_confirmation, userId));
} else { } else {
builder.setMessage(R.string.key_deletion_confirmation_multi); deleteSecretKeyView.setVisibility(View.VISIBLE);
mainMessage.setText(R.string.key_deletion_confirmation_multi);
} }
builder.setIcon(R.drawable.ic_dialog_alert_holo_light); builder.setIcon(R.drawable.ic_dialog_alert_holo_light);
builder.setPositiveButton(R.string.btn_delete, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.btn_delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Uri queryUri = KeychainContract.KeyRings.buildUnifiedKeyRingsUri();
String[] projection = new String[]{
KeychainContract.KeyRings.MASTER_KEY_ID, // 0
KeychainContract.KeyRings.TYPE// 1
};
@Override // make selection with all entries where _ID is one of the given row ids
public void onClick(DialogInterface dialog, int id) { String selection = KeychainDatabase.Tables.KEY_RINGS + "." +
ArrayList<String> notDeleted = new ArrayList<String>(); KeychainContract.KeyRings._ID + " IN(";
String selectionIDs = "";
if (keyType == Id.type.public_key) { for (int i = 0; i < keyRingRowIds.length; i++) {
Uri queryUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(); selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'";
String[] projection = new String[]{ if (i + 1 < keyRingRowIds.length)
KeychainContract.KeyRings._ID, // 0 selectionIDs += ",";
KeychainContract.KeyRings.MASTER_KEY_ID, // 1
KeychainContract.UserIds.USER_ID // 2
};
// make selection with all entries where _ID is one of the given row ids
String selection = KeychainDatabase.Tables.KEY_RINGS + "." +
KeychainContract.KeyRings._ID + " IN(";
String selectionIDs = "";
for (int i = 0; i < keyRingRowIds.length; i++) {
selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'";
if (i + 1 < keyRingRowIds.length) {
selectionIDs += ",";
} }
} selection += selectionIDs + ")";
selection += selectionIDs + ")";
Cursor cursor = activity.getContentResolver().query(queryUri, projection, Cursor cursor = activity.getContentResolver().query(queryUri, projection,
selection, null, null); selection, null, null);
long rowId;
long masterKeyId;
String userId;
try {
while (cursor != null && cursor.moveToNext()) {
rowId = cursor.getLong(0);
masterKeyId = cursor.getLong(1);
userId = cursor.getString(2);
Log.d(Constants.TAG, "rowId: " + rowId + ", masterKeyId: " + masterKeyId long masterKeyId;
+ ", userId: " + userId); long keyType;
boolean isSuccessfullyDeleted;
try {
isSuccessfullyDeleted = false;
while (cursor != null && cursor.moveToNext()) {
masterKeyId = cursor.getLong(0);
keyType = cursor.getLong(1);
// check if a corresponding secret key exists... Log.d(Constants.TAG, "masterKeyId: " + masterKeyId
Cursor secretCursor = activity.getContentResolver().query( + ", keyType:" + (keyType == KeychainContract.KeyTypes.PUBLIC ? "Public" : "Private"));
KeychainContract.KeyRings
.buildSecretKeyRingsByMasterKeyIdUri(
String.valueOf(masterKeyId)), if (keyType == KeychainContract.KeyTypes.SECRET) {
null, null, null, null if (checkDeleteSecret.isChecked() || isSingleSelection) {
); ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), true);
if (secretCursor != null && secretCursor.getCount() > 0) { }
notDeleted.add(userId); } else {
} else { ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), false);
// it is okay to delete this key, no secret key found! }
ProviderHelper.deletePublicKeyRing(activity, rowId);
} }
if (secretCursor != null) {
secretCursor.close(); //Check if the selected rows have actually been deleted
cursor = activity.getContentResolver().query(queryUri, projection, selection, null, null);
if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) {
isSuccessfullyDeleted = true;
} }
} finally {
if (cursor != null) {
cursor.close();
}
} }
} finally {
if (cursor != null) { dismiss();
cursor.close();
if (isSuccessfullyDeleted) {
sendMessageToHandler(MESSAGE_OKAY, null);
} else {
sendMessageToHandler(MESSAGE_ERROR, null);
} }
} }
} else {
for (long keyRowId : keyRingRowIds) {
ProviderHelper.deleteSecretKeyRing(activity, keyRowId);
}
}
dismiss();
if (notDeleted.size() > 0) {
Bundle data = new Bundle();
data.putStringArrayList(MESSAGE_NOT_DELETED, notDeleted);
sendMessageToHandler(MESSAGE_OKAY, data);
} else {
sendMessageToHandler(MESSAGE_OKAY, null);
} }
} );
});
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override @Override
@ -198,7 +221,6 @@ public class DeleteKeyDialogFragment extends DialogFragment {
if (data != null) { if (data != null) {
msg.setData(data); msg.setData(data);
} }
try { try {
mMessenger.send(msg); mMessenger.send(msg);
} catch (RemoteException e) { } catch (RemoteException e) {
@ -207,4 +229,5 @@ public class DeleteKeyDialogFragment extends DialogFragment {
Log.w(Constants.TAG, "Messenger is null!", e); Log.w(Constants.TAG, "Messenger is null!", e);
} }
} }
} }

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mainMessage"
android:layout_margin="4dp"
android:textAppearance="?android:textAppearanceMedium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1"
android:id="@+id/deleteSecretKeyView">
<CheckBox
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:layout_margin="4dp"
android:id="@+id/checkDeleteSecret" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:textAppearance="?android:textAppearanceMedium"
android:layout_weight="0.9"
android:text="@string/secret_key_delete_text" />
</LinearLayout>
</LinearLayout>

View File

@ -220,6 +220,8 @@
<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?\nYou can\'t undo this!</string> <string name="key_deletion_confirmation_multi">Do you really want to delete all selected 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="public_key_deletetion_confirmation">Do you really want to delete the PUBLIC key \'%s\'?\nYou can\'t undo this!</string>
<string name="secret_key_delete_text">Delete Secret Keys ?</string>
<string name="also_export_secret_keys">Also export secret keys?</string> <string name="also_export_secret_keys">Also export secret keys?</string>
<plurals name="keys_added_and_updated_1"> <plurals name="keys_added_and_updated_1">