diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java | 8 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/services/XmppConnectionService.java | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java index dc14fe636..780be831b 100644 --- a/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java +++ b/src/main/java/de/pixart/messenger/services/AttachFileToConversationRunnable.java @@ -31,17 +31,19 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod private final XmppConnectionService mXmppConnectionService; private final Message message; private final Uri uri; + private final String type; private final UiCallback<Message> callback; private final boolean isVideoMessage; private final long originalFileSize; private int currentProgress = -1; - public AttachFileToConversationRunnable(XmppConnectionService xmppConnectionService, Uri uri, Message message, UiCallback<Message> callback) { + public AttachFileToConversationRunnable(XmppConnectionService xmppConnectionService, Uri uri, String type, Message message, UiCallback<Message> callback) { this.uri = uri; + this.type = type; this.mXmppConnectionService = xmppConnectionService; this.message = message; this.callback = callback; - final String mimeType = MimeUtils.guessMimeTypeFromUri(mXmppConnectionService, uri); + final String mimeType = type != null ? type : MimeUtils.guessMimeTypeFromUri(mXmppConnectionService, uri); final int autoAcceptFileSize = Config.FILE_SIZE; this.originalFileSize = FileBackend.getFileSize(mXmppConnectionService, uri); this.isVideoMessage = !getFileBackend().useFileAsIs(uri) @@ -68,7 +70,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod } } else { try { - mXmppConnectionService.getFileBackend().copyFileToPrivateStorage(message, uri); + mXmppConnectionService.getFileBackend().copyFileToPrivateStorage(message, uri, type); mXmppConnectionService.getFileBackend().updateFileParams(message); if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { final PgpEngine pgpEngine = mXmppConnectionService.getPgpEngine(); diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 69b329dce..06311c441 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -491,9 +491,7 @@ public class XmppConnectionService extends Service { } } - public void attachFileToConversation(final Conversation conversation, - final Uri uri, - final UiCallback<Message> callback) { + public void attachFileToConversation(final Conversation conversation, final Uri uri, final String type, final UiCallback<Message> callback) { if (FileBackend.weOwnFile(this, uri)) { Log.d(Config.LOGTAG, "trying to attach file that belonged to us"); callback.error(R.string.security_error_invalid_file_access, null); @@ -507,7 +505,7 @@ public class XmppConnectionService extends Service { } message.setCounterpart(conversation.getNextCounterpart()); message.setType(Message.TYPE_FILE); - final AttachFileToConversationRunnable runnable = new AttachFileToConversationRunnable(this, uri, message, callback); + final AttachFileToConversationRunnable runnable = new AttachFileToConversationRunnable(this, uri, type, message, callback); if (runnable.isVideoMessage()) { mVideoCompressionExecutor.execute(runnable); } else { @@ -527,7 +525,7 @@ public class XmppConnectionService extends Service { || ("auto".equals(compressPictures) && getFileBackend().useImageAsIs(uri)) || (mimeType != null && mimeType.endsWith("/gif"))) { Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": not compressing picture. sending as file"); - attachFileToConversation(conversation, uri, callback); + attachFileToConversation(conversation, uri, mimeType, callback); return; } final Message message; |