From c9d9e7ea8114b7a23cfa46fcafa1b3e491bc33b4 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Fri, 25 Jan 2019 22:35:16 +0100 Subject: check if we have storage permission before marking a file as deleted on resend --- src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index eba4c88c5..55f6d7334 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -108,6 +108,7 @@ import de.pixart.messenger.ui.util.SendButtonAction; import de.pixart.messenger.ui.util.SendButtonTool; import de.pixart.messenger.ui.util.ShareUtil; import de.pixart.messenger.ui.widget.EditMessage; +import de.pixart.messenger.utils.Compatibility; import de.pixart.messenger.utils.GeoHelper; import de.pixart.messenger.utils.MenuDoubleTabUtil; import de.pixart.messenger.utils.MessageUtils; @@ -1906,8 +1907,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke return; } final Conversation conversation = (Conversation) message.getConversation(); - DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); - if (file.exists()) { + final DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); + if ((file.exists() && file.canRead()) || message.hasFileOnRemoteHost()) { final XmppConnection xmppConnection = conversation.getAccount().getXmppConnection(); if (!message.hasFileOnRemoteHost() && xmppConnection != null @@ -1923,9 +1924,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke }); return; } + } else if (!Compatibility.hasStoragePermission(getActivity())) { + Toast.makeText(activity, R.string.no_storage_permission, Toast.LENGTH_SHORT).show(); + return; } else { Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show(); - //TODO check if we have storage permission message.setFileDeleted(true); activity.xmppConnectionService.updateMessage(message, false); activity.onConversationsListItemUpdated(); -- cgit v1.2.3