diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-04-04 16:28:28 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-04-04 16:28:28 +0200 |
commit | cf76a8553a686e1e9c8757b39b6b4e3c4b05bb0c (patch) | |
tree | 7a4273b5644c7edc71d340cc0fd36f5982d8a814 /OpenPGP-Keychain | |
parent | 53e8afaee035c6421c9b4efefea2d6171c6183b8 (diff) | |
download | open-keychain-cf76a8553a686e1e9c8757b39b6b4e3c4b05bb0c.tar.gz open-keychain-cf76a8553a686e1e9c8757b39b6b4e3c4b05bb0c.tar.bz2 open-keychain-cf76a8553a686e1e9c8757b39b6b4e3c4b05bb0c.zip |
db-overhaul: fix delete key from ViewKeyActivity
Diffstat (limited to 'OpenPGP-Keychain')
3 files changed, 12 insertions, 15 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java index 43fdc7751..3040b4e9c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java @@ -30,6 +30,7 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; +import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; @@ -48,14 +49,12 @@ public class ExportHelper { } public void deleteKey(Uri dataUri, Handler deleteHandler) { - long keyRingRowId = Long.valueOf(dataUri.getLastPathSegment()); - // Create a new Messenger for the communication back Messenger messenger = new Messenger(deleteHandler); + long masterKeyId = ProviderHelper.getMasterKeyId(mActivity, dataUri); DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger, - new long[]{keyRingRowId}); - + new long[]{ masterKeyId }); deleteKeyDialog.show(mActivity.getSupportFragmentManager(), "deleteKeyDialog"); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index 5f30848f8..3c6ae514e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -42,7 +42,6 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.ViewKeyKeysAdapter; import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter; @@ -205,6 +204,12 @@ public class ViewKeyMainFragment extends Fragment implements } public void onLoadFinished(Loader<Cursor> loader, Cursor data) { + /* TODO better error handling? May cause problems when a key is deleted, + * because the notification triggers faster than the activity closes. + */ + // Avoid NullPointerExceptions... + if(data.getCount() == 0) + return; // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) switch (loader.getId()) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 36123a98b..72ea4c013 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -75,7 +75,6 @@ public class DeleteKeyDialogFragment extends DialogFragment { return frag; } - @Override public Dialog onCreateDialog(Bundle savedInstanceState) { @@ -122,7 +121,6 @@ public class DeleteKeyDialogFragment extends DialogFragment { mMainMessage.setText(R.string.key_deletion_confirmation_multi); } - builder.setIcon(R.drawable.ic_dialog_alert_holo_light); builder.setPositiveButton(R.string.btn_delete, new DialogInterface.OnClickListener() { @Override @@ -133,21 +131,16 @@ public class DeleteKeyDialogFragment extends DialogFragment { int count = activity.getContentResolver().delete( KeyRingData.buildPublicKeyRingUri(Long.toString(masterKeyId)), null, null ); - if(count > 0) - success = true; + success = count > 0; } - - dismiss(); - if (success) { sendMessageToHandler(MESSAGE_OKAY, null); } else { sendMessageToHandler(MESSAGE_ERROR, null); } + dismiss(); } - - } - ); + }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override |