diff options
3 files changed, 13 insertions, 4 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpDownloadFileTransferService.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpDownloadFileTransferService.java index c7fcc430..583b9d2b 100644 --- a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpDownloadFileTransferService.java +++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpDownloadFileTransferService.java @@ -60,6 +60,7 @@ public class HttpDownloadFileTransferService extends AbstractFileTransferService @Override public boolean accept(Message message) { return MessageUtil.needsDownload(message) - && message.hasFileAttached() && (null == message.getFileParams() || message.getFileParams().isRemoteAvailable()); + && (message.hasFileAttached() || MessageUtil.hasDownloadableLink(message)) + && (null == message.getFileParams() || message.getFileParams().isRemoteAvailable()); } } diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java index 4c2917e3..0b544581 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java @@ -683,7 +683,7 @@ public class MessageAdapter extends ArrayAdapter<Message> { viewHolder.darkBackground = (type == RECEIVED && !isInValidSession); this.displayStatus(viewHolder, message, type); - if (null != message.getTransferable() || message.hasFileAttached()) { + if (null != message.getTransferable() || message.hasFileAttached() || MessageUtil.hasDownloadableLink(message)) { if (!(message.trusted() && MessageUtil.needsDownload(message) && ConversationsPlusPreferences.autoAcceptFileSize() > 0 diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java b/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java index 5e629485..fa403cc5 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java @@ -9,6 +9,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import de.thedevstack.conversationsplus.ConversationsPlusApplication; +import de.thedevstack.conversationsplus.ConversationsPlusPreferences; import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.DownloadableFile; import de.thedevstack.conversationsplus.entities.FileParams; @@ -172,11 +173,18 @@ public final class MessageUtil { public static boolean needsDownload(Message message) { FileStatus fileStatus = (null != message.getFileParams()) ? message.getFileParams().getFileStatus() : null; - return (null == fileStatus - || (null != fileStatus && (fileStatus == FileStatus.NEEDS_DOWNLOAD || fileStatus == FileStatus.UNDEFINED))) + return (message.hasFileAttached() || MessageUtil.hasDownloadableLink(message)) + &&(null == fileStatus + || (null != fileStatus && (fileStatus == FileStatus.NEEDS_DOWNLOAD || fileStatus == FileStatus.UNDEFINED))) && message.treatAsDownloadable() != Message.Decision.NEVER; } + public static boolean hasDownloadableLink(Message message) { + String url = (null != message.getFileParams()) ? message.getFileParams().getUrl() : null; + return ConversationsPlusPreferences.autoDownloadFileLink() + && null != url; + } + public static boolean isMessageSent(Message message) { switch (message.getStatus()) { case Message.STATUS_SEND: |