aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java2
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java2
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java21
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java2
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java2
5 files changed, 10 insertions, 19 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java b/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java
index 74025eef3..cc5e3fe70 100644
--- a/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java
+++ b/src/main/java/de/pixart/messenger/crypto/PgpDecryptionService.java
@@ -177,7 +177,7 @@ public class PgpDecryptionService {
mXmppConnectionService.updateMessage(message);
break;
}
- } else if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE) {
+ } else if (message.isFileOrImage()) {
try {
final DownloadableFile inputFile = mXmppConnectionService.getFileBackend().getFile(message, false);
final DownloadableFile outputFile = mXmppConnectionService.getFileBackend().getFile(message, true);
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index c375aafa1..523e02b77 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -228,7 +228,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
for (final Message message : this.messages) {
if (message.getUuid().equals(uuid)
&& message.getEncryption() != Message.ENCRYPTION_PGP
- && (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE || message.treatAsDownloadable())) {
+ && (message.isFileOrImage() || message.treatAsDownloadable())) {
return message;
}
}
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 2a809f5bb..fae15dbda 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -1022,11 +1022,11 @@ public class FileBackend {
public void updateFileParams(Message message, URL url) {
DownloadableFile file = getFile(message);
final String mime = file.getMimeType();
- boolean image = message.getType() == Message.TYPE_IMAGE || (mime != null && mime.startsWith("image/"));
- boolean video = mime != null && mime.startsWith("video/");
- boolean audio = mime != null && mime.startsWith("audio/");
- boolean vcard = mime != null && mime.contains("vcard");
- boolean apk = mime != null && mime.equals("application/vnd.android.package-archive");
+ final boolean image = message.getType() == Message.TYPE_IMAGE || (mime != null && mime.startsWith("image/"));
+ final boolean video = mime != null && mime.startsWith("video/");
+ final boolean audio = mime != null && mime.startsWith("audio/");
+ final boolean vcard = mime != null && mime.contains("vcard");
+ final boolean apk = mime != null && mime.equals("application/vnd.android.package-archive");
final StringBuilder body = new StringBuilder();
if (url != null) {
body.append(url.toString());
@@ -1051,16 +1051,7 @@ public class FileBackend {
}
message.setBody(body.toString());
message.setFileDeleted(false);
- }
-
- public int getMediaRuntime(Uri uri) {
- try {
- MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
- mediaMetadataRetriever.setDataSource(mXmppConnectionService, uri);
- return Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));
- } catch (RuntimeException e) {
- return 0;
- }
+ message.setType(image ? Message.TYPE_IMAGE : Message.TYPE_FILE);
}
private int getMediaRuntime(File file) {
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 ba0f5e991..f579df82f 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java
@@ -246,7 +246,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
final Transferable transferable = message.getTransferable();
boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI
&& message.getMergedStatus() <= Message.STATUS_RECEIVED;
- if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE || transferable != null) {
+ if (message.isFileOrImage() || transferable != null) {
FileParams params = message.getFileParams();
if (params.size > (1 * 1024 * 1024)) {
filesize = Math.round(params.size * 1f / (1024 * 1024)) + " MiB";
diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
index 85fdc536f..d4c6c7eba 100644
--- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleConnection.java
@@ -485,7 +485,7 @@ public class JingleConnection implements Transferable {
private void sendInitRequest() {
JinglePacket packet = this.bootstrapPacket("session-initiate");
Content content = new Content(this.contentCreator, this.contentName);
- if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE) {
+ if (message.isFileOrImage()) {
content.setTransportId(this.transportId);
this.file = this.mXmppConnectionService.getFileBackend().getFile(message, false);
if (message.getEncryption() == Message.ENCRYPTION_OTR) {