diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-04-13 21:24:52 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-04-13 21:24:52 +0200 |
commit | 22229d6b4312108144e1f132272dd9e9d848fdf7 (patch) | |
tree | 64f64126a696a945ffda32658b8d3e71d7c18e83 /src/main/java/de/pixart/messenger/ui | |
parent | 522538e2acbc104346f8669e61cdb35731481837 (diff) |
treat URL as file if URL is in oob or contains key
Diffstat (limited to '')
3 files changed, 4 insertions, 19 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index ef46bf0e3..52899f21e 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -807,7 +807,7 @@ public class ConversationActivity extends XmppActivity if (!transferable.start()) { Toast.makeText(this, R.string.not_connected_try_again, Toast.LENGTH_SHORT).show(); } - } else if (message.treatAsDownloadable() != Message.Decision.NEVER) { + } else if (message.treatAsDownloadable()) { xmppConnectionService.getHttpConnectionManager().createNewDownloadConnection(message, true); } } diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index fc735785c..7324f27b0 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -627,14 +627,13 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa MenuItem shareWith = menu.findItem(R.id.share_with); MenuItem sendAgain = menu.findItem(R.id.send_again); MenuItem copyUrl = menu.findItem(R.id.copy_url); - MenuItem downloadFile = menu.findItem(R.id.download_file); MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission); MenuItem deleteFile = menu.findItem(R.id.delete_file); MenuItem showErrorMessage = menu.findItem(R.id.show_error_message); if (!treatAsFile && !GeoHelper.isGeoUri(m.getBody()) && !XmppUri.isXmppUri(m.getBody()) - && m.treatAsDownloadable() != Message.Decision.MUST) { + && !m.treatAsDownloadable()) { copyText.setVisible(true); selectText.setVisible(ListSelectionManager.isSupported()); } @@ -662,15 +661,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa if (m.hasFileOnRemoteHost() || GeoHelper.isGeoUri(m.getBody()) || XmppUri.isXmppUri(m.getBody()) - || m.treatAsDownloadable() == Message.Decision.MUST + || m.treatAsDownloadable() || (t != null && t instanceof HttpDownloadConnection)) { copyUrl.setVisible(true); } - if ((m.getType() == Message.TYPE_TEXT && t == null && m.treatAsDownloadable() != Message.Decision.NEVER) - || (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; @@ -712,9 +706,6 @@ 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; @@ -839,11 +830,6 @@ 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/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 6143f382f..4519406f9 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -936,8 +936,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie displayHeartMessage(viewHolder, message.getBody().trim()); } else if (message.bodyIsXmpp()) { displayXmppMessage(viewHolder, message.getBody().trim()); - } else if (message.treatAsDownloadable() == Message.Decision.MUST || - message.treatAsDownloadable() == Message.Decision.SHOULD) { + } else if (message.treatAsDownloadable()) { try { URL url = new URL(message.getBody()); displayDownloadableMessage(viewHolder, |