From d237ade908db44051628f40f92d31f48175fb331 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 20 Apr 2017 20:47:32 +0200 Subject: re-add redownload context menu entry for deleted files --- .../java/de/pixart/messenger/ui/ConversationFragment.java | 12 ++++++++++++ src/main/res/menu/message_context.xml | 4 ++++ 2 files changed, 16 insertions(+) (limited to 'src/main') diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 11e81bfc6..c218a940e 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -630,6 +630,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa MenuItem sendAgain = menu.findItem(R.id.send_again); MenuItem copyUrl = menu.findItem(R.id.copy_url); MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission); + MenuItem downloadFile = menu.findItem(R.id.download_file); MenuItem deleteFile = menu.findItem(R.id.delete_file); MenuItem showErrorMessage = menu.findItem(R.id.show_error_message); if (!treatAsFile @@ -667,6 +668,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa || (t != null && t instanceof HttpDownloadConnection)) { copyUrl.setVisible(true); } + if ((m.isFileOrImage() && t instanceof TransferablePlaceholder && m.hasFileOnRemoteHost())) { + downloadFile.setVisible(true); + downloadFile.setTitle(activity.getString(R.string.download_x_file, UIHelper.getFileDescriptionString(activity, m))); + } boolean waitingOfferedSending = m.getStatus() == Message.STATUS_WAITING || m.getStatus() == Message.STATUS_UNSEND || m.getStatus() == Message.STATUS_OFFERED; @@ -708,6 +713,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa case R.id.copy_url: copyUrl(selectedMessage); return true; + case R.id.download_file: + downloadFile(selectedMessage); + return true; case R.id.cancel_transmission: cancelTransmission(selectedMessage); return true; @@ -832,6 +840,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } } + private void downloadFile(Message message) { + activity.xmppConnectionService.getHttpConnectionManager().createNewDownloadConnection(message, true); + } + private void cancelTransmission(Message message) { Transferable transferable = message.getTransferable(); if (transferable != null) { diff --git a/src/main/res/menu/message_context.xml b/src/main/res/menu/message_context.xml index a60fdd2e8..0c3220683 100644 --- a/src/main/res/menu/message_context.xml +++ b/src/main/res/menu/message_context.xml @@ -33,6 +33,10 @@ android:id="@+id/send_again" android:title="@string/send_again" android:visible="false" /> +