aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2018-01-31 19:52:50 +0100
committersteckbrief <steckbrief@chefmail.de>2018-01-31 19:52:50 +0100
commit84a2f8e41ac4d5a7ebc24f4eb5b99e9bc3029f1f (patch)
tree6874e094a44251bf5cb10f47577e0910f1456c2f /src
parent622412fc723fb402035ce2600f980806952709b8 (diff)
properly handle downloadable links0.0.8-beta2
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/download/HttpDownloadFileTransferService.java3
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java2
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/MessageUtil.java12
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: