explicitly set type=images for all media with an image mime type

this is in preperation to be able to query the database for all images
This commit is contained in:
Daniel Gultsch 2019-01-12 09:01:32 +01:00
parent 9efb3c6dc6
commit e9bf2b464c
5 changed files with 8 additions and 16 deletions

View file

@ -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);

View file

@ -184,7 +184,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;
}
}

View file

@ -1169,9 +1169,9 @@ 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/");
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 StringBuilder body = new StringBuilder();
if (url != null) {
body.append(url.toString());
@ -1192,17 +1192,9 @@ public class FileBackend {
}
message.setBody(body.toString());
message.setDeleted(false);
message.setType(image ? Message.TYPE_IMAGE : Message.TYPE_FILE);
}
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;
}
}
private int getMediaRuntime(File file) {
try {

View file

@ -217,7 +217,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.5 * 1024 * 1024)) {
filesize = Math.round(params.size * 1f / (1024 * 1024)) + " MiB";

View file

@ -469,7 +469,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_AXOLOTL) {