From 97a6c82ff90650816b103616f3cbe1e585eb1721 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 25 Nov 2017 22:37:58 +0100 Subject: don't return null for opus file extensions --- src/main/java/de/pixart/messenger/persistance/FileBackend.java | 3 +++ src/main/java/de/pixart/messenger/utils/MimeUtils.java | 3 +++ 2 files changed, 6 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index ce8219f6e..3a53d31b9 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -341,6 +341,9 @@ public class FileBackend { if (extension == null) { extension = getExtensionFromUri(uri); } + if (extension == null) { + extension = MimeUtils.guessExtensionFromMimeType(mime); + } String filename = fileDateFormat.format(new Date(message.getTimeSent())) + "_" + message.getUuid().substring(0, 4); message.setRelativeFilePath(filename + "." + extension); copyFileToPrivateStorage(mXmppConnectionService.getFileBackend().getFile(message), uri); diff --git a/src/main/java/de/pixart/messenger/utils/MimeUtils.java b/src/main/java/de/pixart/messenger/utils/MimeUtils.java index d2ce21b72..bfcf71c6e 100644 --- a/src/main/java/de/pixart/messenger/utils/MimeUtils.java +++ b/src/main/java/de/pixart/messenger/utils/MimeUtils.java @@ -509,6 +509,9 @@ public final class MimeUtils { String mimeType; try { mimeType = context.getContentResolver().getType(uri); + if (mimeType != null && mimeType.equals("application/octet-stream")) { + mimeType = null; + } } catch (Throwable throwable) { mimeType = null; } -- cgit v1.2.3