diff options
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 12 | ||||
-rw-r--r-- | src/main/res/menu/message_context.xml | 4 |
2 files changed, 16 insertions, 0 deletions
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 @@ -34,6 +34,10 @@ android:title="@string/send_again" android:visible="false" /> <item + android:id="@+id/download_file" + android:title="@string/download_x_file" + android:visible="false" /> + <item android:id="@+id/cancel_transmission" android:title="@string/cancel_transmission" android:visible="false" /> |