aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java9
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java27
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml2
4 files changed, 29 insertions, 11 deletions
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 0971320cb..50b7211b1 100644
--- a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/ui/AsymmetricFileOperationTests.java
@@ -165,7 +165,7 @@ public class AsymmetricFileOperationTests {
// delete file
onView(withText(R.string.btn_delete_original)).perform(click());
- checkSnackbar(Style.OK, R.string.file_delete_none);
+ checkSnackbar(Style.WARN, R.string.file_delete_none);
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java
index fc3d43eaf..b1f1a7d9e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java
@@ -210,10 +210,13 @@ public class TemporaryStorageProvider extends ContentProvider {
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
- if (uri.getLastPathSegment() != null) {
- selection = DatabaseUtil.concatenateWhere(selection, COLUMN_ID + "=?");
- selectionArgs = DatabaseUtil.appendSelectionArgs(selectionArgs, new String[]{uri.getLastPathSegment()});
+ if (uri == null || uri.getLastPathSegment() == null) {
+ return 0;
}
+
+ selection = DatabaseUtil.concatenateWhere(selection, COLUMN_ID + "=?");
+ selectionArgs = DatabaseUtil.appendSelectionArgs(selectionArgs, new String[]{uri.getLastPathSegment()});
+
Cursor files = db.getReadableDatabase().query(TABLE_FILES, new String[]{COLUMN_ID}, selection,
selectionArgs, null, null, null);
if (files != null) {
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 549922526..092c5f832 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java
@@ -499,18 +499,33 @@ public class DecryptListFragment
private void deleteFile(Activity activity, Uri uri) {
- try {
- int deleted = activity.getContentResolver().delete(uri, null, null);
- if (deleted > 0) {
+ if ("file".equals(uri.getScheme())) {
+ File file = new File(uri.getPath());
+ if (file.delete()) {
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();
+ return;
+ }
+
+ if ("content".equals(uri.getScheme())) {
+ 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();
+ }
+ return;
}
+ Notify.create(activity, R.string.file_delete_exception, Style.ERROR).show();
+
}
public static class DecryptFilesAdapter extends RecyclerView.Adapter<ViewHolder> {
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 7f5998772..1f1acc2a8 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -1347,6 +1347,6 @@
<string name="file_saved">"File saved!"</string>
<string name="file_delete_ok">"Original file deleted."</string>
<string name="file_delete_none">"No file deleted! (Already deleted?)"</string>
- <string name="file_delete_exception">"Could not delete original file!"</string>
+ <string name="file_delete_exception">"Original file could not be deleted!"</string>
</resources>