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:
parent
9efb3c6dc6
commit
e9bf2b464c
|
@ -177,7 +177,7 @@ public class PgpDecryptionService {
|
||||||
mXmppConnectionService.updateMessage(message);
|
mXmppConnectionService.updateMessage(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE) {
|
} else if (message.isFileOrImage()) {
|
||||||
try {
|
try {
|
||||||
final DownloadableFile inputFile = mXmppConnectionService.getFileBackend().getFile(message, false);
|
final DownloadableFile inputFile = mXmppConnectionService.getFileBackend().getFile(message, false);
|
||||||
final DownloadableFile outputFile = mXmppConnectionService.getFileBackend().getFile(message, true);
|
final DownloadableFile outputFile = mXmppConnectionService.getFileBackend().getFile(message, true);
|
||||||
|
|
|
@ -184,7 +184,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
||||||
for (final Message message : this.messages) {
|
for (final Message message : this.messages) {
|
||||||
if (message.getUuid().equals(uuid)
|
if (message.getUuid().equals(uuid)
|
||||||
&& message.getEncryption() != Message.ENCRYPTION_PGP
|
&& message.getEncryption() != Message.ENCRYPTION_PGP
|
||||||
&& (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE || message.treatAsDownloadable())) {
|
&& (message.isFileOrImage() || message.treatAsDownloadable())) {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1169,9 +1169,9 @@ public class FileBackend {
|
||||||
public void updateFileParams(Message message, URL url) {
|
public void updateFileParams(Message message, URL url) {
|
||||||
DownloadableFile file = getFile(message);
|
DownloadableFile file = getFile(message);
|
||||||
final String mime = file.getMimeType();
|
final String mime = file.getMimeType();
|
||||||
boolean image = message.getType() == Message.TYPE_IMAGE || (mime != null && mime.startsWith("image/"));
|
final boolean image = message.getType() == Message.TYPE_IMAGE || (mime != null && mime.startsWith("image/"));
|
||||||
boolean video = mime != null && mime.startsWith("video/");
|
final boolean video = mime != null && mime.startsWith("video/");
|
||||||
boolean audio = mime != null && mime.startsWith("audio/");
|
final boolean audio = mime != null && mime.startsWith("audio/");
|
||||||
final StringBuilder body = new StringBuilder();
|
final StringBuilder body = new StringBuilder();
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
body.append(url.toString());
|
body.append(url.toString());
|
||||||
|
@ -1192,17 +1192,9 @@ public class FileBackend {
|
||||||
}
|
}
|
||||||
message.setBody(body.toString());
|
message.setBody(body.toString());
|
||||||
message.setDeleted(false);
|
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) {
|
private int getMediaRuntime(File file) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -217,7 +217,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
|
||||||
final Transferable transferable = message.getTransferable();
|
final Transferable transferable = message.getTransferable();
|
||||||
boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI
|
boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI
|
||||||
&& message.getMergedStatus() <= Message.STATUS_RECEIVED;
|
&& 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();
|
FileParams params = message.getFileParams();
|
||||||
if (params.size > (1.5 * 1024 * 1024)) {
|
if (params.size > (1.5 * 1024 * 1024)) {
|
||||||
filesize = Math.round(params.size * 1f / (1024 * 1024)) + " MiB";
|
filesize = Math.round(params.size * 1f / (1024 * 1024)) + " MiB";
|
||||||
|
|
|
@ -469,7 +469,7 @@ public class JingleConnection implements Transferable {
|
||||||
private void sendInitRequest() {
|
private void sendInitRequest() {
|
||||||
JinglePacket packet = this.bootstrapPacket("session-initiate");
|
JinglePacket packet = this.bootstrapPacket("session-initiate");
|
||||||
Content content = new Content(this.contentCreator, this.contentName);
|
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);
|
content.setTransportId(this.transportId);
|
||||||
this.file = this.mXmppConnectionService.getFileBackend().getFile(message, false);
|
this.file = this.mXmppConnectionService.getFileBackend().getFile(message, false);
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
|
if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
|
||||||
|
|
Loading…
Reference in New Issue