From de0de484482ff6d1d64d5d98ac83354737326f79 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 23 Apr 2018 20:27:54 +0200 Subject: [PATCH] allow to delete voice recordings --- .../eu/siacs/conversations/persistance/FileBackend.java | 6 ++++-- .../eu/siacs/conversations/ui/ConversationFragment.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 370b68057..5b77e1879 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -101,7 +101,10 @@ public class FileBackend { } private static boolean isInDirectoryThatShouldNotBeScanned(Context context, File file) { - String path = file.getAbsolutePath(); + return isInDirectoryThatShouldNotBeScanned(context, file.getAbsolutePath()); + } + + public static boolean isInDirectoryThatShouldNotBeScanned(Context context, String path) { for(String type : new String[]{RecordingActivity.STORAGE_DIRECTORY_TYPE_NAME, "Files"}) { if (path.startsWith(getConversationsDirectory(context, type))) { return true; @@ -280,7 +283,6 @@ public class FileBackend { } public static boolean isPathBlacklisted(String path) { - Environment.getDataDirectory(); final String androidDataPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/"; return path.startsWith(androidDataPath); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index f7a0ffb29..3f32542ce 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1113,7 +1113,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke } if (m.isFileOrImage() && !deleted) { String path = m.getRelativeFilePath(); - if (path == null || !path.startsWith("/")) { + if (path == null || !path.startsWith("/") || FileBackend.isInDirectoryThatShouldNotBeScanned(getActivity(), path) ) { deleteFile.setVisible(true); deleteFile.setTitle(activity.getString(R.string.delete_x_file, UIHelper.getFileDescriptionString(activity, m))); }