From c3dcc74b23f6590926fef89d16d6b5693d3b8e22 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 22 Sep 2017 11:14:56 +0200 Subject: [PATCH] select presence if necessary when resending file --- .../ui/ConversationFragment.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 170689cd..02b7dd73 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -763,10 +763,25 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } } - private void resendMessage(Message message) { - if (message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) { + private void resendMessage(final Message message) { + if (message.isFileOrImage()) { DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); - if (!file.exists()) { + if (file.exists()) { + final Conversation conversation = message.getConversation(); + final XmppConnection xmppConnection = conversation.getAccount().getXmppConnection(); + if (!message.hasFileOnRemoteHost() + && xmppConnection != null + && !xmppConnection.getFeatures().httpUpload(message.getFileParams().size)) { + activity.selectPresence(conversation, new OnPresenceSelected() { + @Override + public void onPresenceSelected() { + message.setCounterpart(conversation.getNextCounterpart()); + activity.xmppConnectionService.resendFailedMessages(message); + } + }); + return; + } + } else { Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show(); message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); activity.updateConversationList();