From 56f01c29b9560879eb84ff6b2848fefda86a8cbe Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 10 Mar 2022 12:39:43 +0100 Subject: [PATCH] allow deletion of all files --- .../eu/siacs/conversations/persistance/FileBackend.java | 6 +++++- .../eu/siacs/conversations/ui/ConversationFragment.java | 7 ++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 5c23bf0fa..55b324533 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -362,8 +362,12 @@ public class FileBackend { } private static boolean weOwnFileLollipop(final Uri uri) { + final String path = uri.getPath(); + if (path == null) { + return false; + } try { - File file = new File(uri.getPath()); + File file = new File(path); FileDescriptor fd = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY) .getFileDescriptor(); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 073e77cc3..7420ca50a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1184,11 +1184,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke cancelTransmission.setVisible(true); } if (m.isFileOrImage() && !deleted && !cancelable) { - final String path = m.getRelativeFilePath(); - if (path == null || !path.startsWith("/")) { - deleteFile.setVisible(true); - deleteFile.setTitle(activity.getString(R.string.delete_x_file, UIHelper.getFileDescriptionString(activity, m))); - } + deleteFile.setVisible(true); + deleteFile.setTitle(activity.getString(R.string.delete_x_file, UIHelper.getFileDescriptionString(activity, m))); } if (showError) { showErrorMessage.setVisible(true);