From f9dea313004b51c5220a2d0b5e9407aab0604df5 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Tue, 23 Jun 2015 17:07:59 +0200 Subject: implement deletion of files --- .../keychain/ui/AsymmetricFileOperationTests.java | 2 +- .../keychain/ui/AsymmetricTextOperationTests.java | 2 +- .../keychain/operations/results/CertifyResult.java | 2 +- .../keychain/operations/results/DeleteResult.java | 2 +- .../operations/results/ImportKeyResult.java | 2 +- .../operations/results/OperationResult.java | 2 +- .../keychain/ui/DecryptListFragment.java | 21 +++++++++++++++++---- .../src/main/res/menu/decrypt_item_context_menu.xml | 2 +- OpenKeychain/src/main/res/values-de/strings.xml | 2 +- OpenKeychain/src/main/res/values-es/strings.xml | 2 +- OpenKeychain/src/main/res/values-eu/strings.xml | 2 +- OpenKeychain/src/main/res/values-fr/strings.xml | 2 +- OpenKeychain/src/main/res/values-ja/strings.xml | 2 +- OpenKeychain/src/main/res/values-nl/strings.xml | 2 +- OpenKeychain/src/main/res/values-pl/strings.xml | 2 +- OpenKeychain/src/main/res/values-ru/strings.xml | 2 +- OpenKeychain/src/main/res/values-sl/strings.xml | 2 +- OpenKeychain/src/main/res/values-sr/strings.xml | 2 +- OpenKeychain/src/main/res/values-sv/strings.xml | 2 +- OpenKeychain/src/main/res/values-zh-rTW/strings.xml | 2 +- OpenKeychain/src/main/res/values/strings.xml | 14 +++++++++----- 21 files changed, 45 insertions(+), 28 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java index cfeb04328..406e40ba6 100644 --- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java +++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java @@ -300,7 +300,7 @@ public class AsymmetricFileOperationTests { onView(withText(R.string.btn_delete_original)).check(doesNotExist()); // check if log looks ok - onView(withText(R.string.view_log)).perform(click()); + onView(withText(R.string.snackbar_details)).perform(click()); onView(withText(R.string.msg_dc_clear_signature_ok)).check(matches(isDisplayed())); pressBack(); diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricTextOperationTests.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricTextOperationTests.java index e53df4f8d..11c9f1bee 100644 --- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricTextOperationTests.java +++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricTextOperationTests.java @@ -198,7 +198,7 @@ public class AsymmetricTextOperationTests { onView(withText(R.string.btn_delete_original)).check(doesNotExist()); // check if log looks ok - onView(withText(R.string.view_log)).perform(click()); + onView(withText(R.string.snackbar_details)).perform(click()); onView(withText(R.string.msg_dc_clear_signature_ok)).check(matches(isDisplayed())); pressBack(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/CertifyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/CertifyResult.java index 0a0e63330..a9f8170d9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/CertifyResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/CertifyResult.java @@ -132,7 +132,7 @@ public class CertifyResult extends InputPendingResult { intent.putExtra(LogDisplayFragment.EXTRA_RESULT, CertifyResult.this); activity.startActivity(intent); } - }, R.string.view_log); + }, R.string.snackbar_details); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/DeleteResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/DeleteResult.java index 50f49add2..52ff8bf44 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/DeleteResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/DeleteResult.java @@ -124,7 +124,7 @@ public class DeleteResult extends OperationResult { intent.putExtra(LogDisplayFragment.EXTRA_RESULT, DeleteResult.this); activity.startActivity(intent); } - }, R.string.view_log); + }, R.string.snackbar_details); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/ImportKeyResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/ImportKeyResult.java index 1438ad698..2a032cef2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/ImportKeyResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/ImportKeyResult.java @@ -190,7 +190,7 @@ public class ImportKeyResult extends OperationResult { intent.putExtra(LogDisplayFragment.EXTRA_RESULT, ImportKeyResult.this); activity.startActivity(intent); } - }, R.string.view_log); + }, R.string.snackbar_details); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java index f110b9186..c9e427462 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java @@ -253,7 +253,7 @@ public abstract class OperationResult implements Parcelable { intent.putExtra(LogDisplayFragment.EXTRA_RESULT, OperationResult.this); activity.startActivity(intent); } - }, R.string.view_log); + }, R.string.snackbar_details); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java index 0d527926d..549922526 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java @@ -491,12 +491,28 @@ public class DecryptListFragment askForOutputFilename(model.mInputUri, metadata.getFilename(), metadata.getMimeType()); return true; case R.id.decrypt_delete: - Notify.create(activity, "decrypt/delete not yet implemented", Style.ERROR).show(this); + deleteFile(activity, model.mInputUri); return true; } return false; } + private void deleteFile(Activity activity, Uri uri) { + + try { + int deleted = activity.getContentResolver().delete(uri, null, null); + if (deleted > 0) { + Notify.create(activity, R.string.file_delete_ok, Style.OK).show(); + } else { + Notify.create(activity, R.string.file_delete_none, Style.WARN).show(); + } + } catch (Exception e) { + Log.e(Constants.TAG, "exception deleting file", e); + Notify.create(activity, R.string.file_delete_exception, Style.ERROR).show(); + } + + } + public static class DecryptFilesAdapter extends RecyclerView.Adapter { private Context mContext; private ArrayList mDataset; @@ -664,9 +680,6 @@ public class DecryptListFragment mMenuClickedModel = model; PopupMenu menu = new PopupMenu(mContext, view); menu.inflate(R.menu.decrypt_item_context_menu); - if (!"file".equals(model.mInputUri.getScheme())) { - menu.getMenu().findItem(R.id.decrypt_delete).setVisible(false); - } menu.setOnMenuItemClickListener(mMenuItemClickListener); menu.setOnDismissListener(new OnDismissListener() { @Override diff --git a/OpenKeychain/src/main/res/menu/decrypt_item_context_menu.xml b/OpenKeychain/src/main/res/menu/decrypt_item_context_menu.xml index e18bdf8e4..b825fa498 100644 --- a/OpenKeychain/src/main/res/menu/decrypt_item_context_menu.xml +++ b/OpenKeychain/src/main/res/menu/decrypt_item_context_menu.xml @@ -3,7 +3,7 @@ diff --git a/OpenKeychain/src/main/res/values-de/strings.xml b/OpenKeychain/src/main/res/values-de/strings.xml index d0610e06b..d2f643e9f 100644 --- a/OpenKeychain/src/main/res/values-de/strings.xml +++ b/OpenKeychain/src/main/res/values-de/strings.xml @@ -363,7 +363,7 @@ QR-Code scannen Halte deine Kamera über den QR-Code! - Details + Details , mit Warnungen . bis abgebrochen wurde diff --git a/OpenKeychain/src/main/res/values-es/strings.xml b/OpenKeychain/src/main/res/values-es/strings.xml index 8c469bf71..8b20aeb04 100644 --- a/OpenKeychain/src/main/res/values-es/strings.xml +++ b/OpenKeychain/src/main/res/values-es/strings.xml @@ -363,7 +363,7 @@ Escanear código QR ¡Sitúe su cámara sobre el código QR! - Detalles + Detalles , con advertencias , hasta que sea cancelado diff --git a/OpenKeychain/src/main/res/values-eu/strings.xml b/OpenKeychain/src/main/res/values-eu/strings.xml index b51b85b16..a0b206f93 100644 --- a/OpenKeychain/src/main/res/values-eu/strings.xml +++ b/OpenKeychain/src/main/res/values-eu/strings.xml @@ -304,7 +304,7 @@ Eskaneatu QR Kodea Jarri zure kamera QR Kodearen gainean! - Xehetasunak + Xehetasunak , kontuz oharrekin Ez dago ezer inportatzeko. diff --git a/OpenKeychain/src/main/res/values-fr/strings.xml b/OpenKeychain/src/main/res/values-fr/strings.xml index fd8a51220..7f408f603 100644 --- a/OpenKeychain/src/main/res/values-fr/strings.xml +++ b/OpenKeychain/src/main/res/values-fr/strings.xml @@ -363,7 +363,7 @@ Balayer le code QR Placez votre appareil photo au-dessus du code QR ! - Détails + Détails , avec des avertissements , jusqu\'à l\'annulation diff --git a/OpenKeychain/src/main/res/values-ja/strings.xml b/OpenKeychain/src/main/res/values-ja/strings.xml index 87eb5e9df..790913684 100644 --- a/OpenKeychain/src/main/res/values-ja/strings.xml +++ b/OpenKeychain/src/main/res/values-ja/strings.xml @@ -364,7 +364,7 @@ QCコードのスキャン カメラをQRコードにかざしてください! - 概要 + 概要 、とワーニング 、キャンセルされるまで diff --git a/OpenKeychain/src/main/res/values-nl/strings.xml b/OpenKeychain/src/main/res/values-nl/strings.xml index dc612e0f6..e69208dbb 100644 --- a/OpenKeychain/src/main/res/values-nl/strings.xml +++ b/OpenKeychain/src/main/res/values-nl/strings.xml @@ -363,7 +363,7 @@ QR code scannen Plaats je camera voor de QR-code! - Details + Details , met waarschuwingen , tot annulatie diff --git a/OpenKeychain/src/main/res/values-pl/strings.xml b/OpenKeychain/src/main/res/values-pl/strings.xml index 10df2a5cb..caa9092e5 100644 --- a/OpenKeychain/src/main/res/values-pl/strings.xml +++ b/OpenKeychain/src/main/res/values-pl/strings.xml @@ -308,7 +308,7 @@ Skanuj kod QR Umieść kod QR przed kamerą! - Szczegóły + Szczegóły , z ostrzeżeniami , aż anulowano diff --git a/OpenKeychain/src/main/res/values-ru/strings.xml b/OpenKeychain/src/main/res/values-ru/strings.xml index f9377ef0e..e5e164c49 100644 --- a/OpenKeychain/src/main/res/values-ru/strings.xml +++ b/OpenKeychain/src/main/res/values-ru/strings.xml @@ -332,7 +332,7 @@ Сканировать QR код... Расположите вашу камеру над QR кодом! - Сведения + Сведения , с предупреждениями , до отмены diff --git a/OpenKeychain/src/main/res/values-sl/strings.xml b/OpenKeychain/src/main/res/values-sl/strings.xml index e6b28b6e5..21c528820 100644 --- a/OpenKeychain/src/main/res/values-sl/strings.xml +++ b/OpenKeychain/src/main/res/values-sl/strings.xml @@ -371,7 +371,7 @@ Skeniraj kodo QR Zajamite kodo QR s kamero! - Podrobnosti + Podrobnosti , z opozorili , do preklica diff --git a/OpenKeychain/src/main/res/values-sr/strings.xml b/OpenKeychain/src/main/res/values-sr/strings.xml index 8a8ad3449..ebacebb5f 100644 --- a/OpenKeychain/src/main/res/values-sr/strings.xml +++ b/OpenKeychain/src/main/res/values-sr/strings.xml @@ -370,7 +370,7 @@ Очитај бар-код Усмерите камеру на бар-код! - Детаљи + Детаљи , са упозорењима , док није отказано diff --git a/OpenKeychain/src/main/res/values-sv/strings.xml b/OpenKeychain/src/main/res/values-sv/strings.xml index 39d55e258..94f4fbe31 100644 --- a/OpenKeychain/src/main/res/values-sv/strings.xml +++ b/OpenKeychain/src/main/res/values-sv/strings.xml @@ -350,7 +350,7 @@ Skanna QR-kod Håll din kamera över QR-koden! - Detaljer + Detaljer , med varningar , tills det avbryts diff --git a/OpenKeychain/src/main/res/values-zh-rTW/strings.xml b/OpenKeychain/src/main/res/values-zh-rTW/strings.xml index 3ef6269dd..53cc26aeb 100644 --- a/OpenKeychain/src/main/res/values-zh-rTW/strings.xml +++ b/OpenKeychain/src/main/res/values-zh-rTW/strings.xml @@ -348,7 +348,7 @@ 掃描二維條碼 將您的相機對準 QR Code ! - 詳細 + 詳細 ,包含警告 ,直到被取消 diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index fa6c585b1..7f5998772 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -63,7 +63,8 @@ "Decrypt, verify, and save file" "Encrypt and share file" "Encrypt and save file" - "Save" + "Save file" + "View log" "Cancel" "Delete" "No Expiry" @@ -420,7 +421,7 @@ "No search query defined. You can still manually search on this keyserver." - "Details" + "Details" ", with warnings" ", until cancelled" @@ -1341,8 +1342,11 @@ "View in OpenKeychain" "Error preparing data!" "Encrypted Data" - Processing… - Error saving file! - File saved! + "Processing…" + "Error saving file!" + "File saved!" + "Original file deleted." + "No file deleted! (Already deleted?)" + "Could not delete original file!" -- cgit v1.2.3