diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-05-02 21:31:16 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-05-02 21:31:16 +0200 |
commit | 218f3d0ed3c65eb16bae6e189a3cc2c46fdaff31 (patch) | |
tree | 0b572e7a08cbec16e01e7c4d7267884aa95b8bce /src/main/java/de/pixart/messenger/persistance | |
parent | 7d65aa994166f5f13f405279e4600a9c0c2b3bcb (diff) |
hard code ogg + audio/ mime type to oga
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index 3613802aa..4e959a868 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -351,10 +351,11 @@ public class FileBackend { Log.d(Config.LOGTAG, "copy " + uri.toString() + " to private storage (mime=" + mime + ")"); String extension = MimeUtils.guessExtensionFromMimeType(mime); if (extension == null) { + Log.d(Config.LOGTAG, "extension from mime type was null"); extension = getExtensionFromUri(uri); } - if (extension == null) { - extension = MimeUtils.guessExtensionFromMimeType(mime); + if ("ogg".equals(extension) && type != null && type.startsWith("audio/")) { + extension = "oga"; } String filename = fileDateFormat.format(new Date(message.getTimeSent())) + "_" + message.getUuid().substring(0, 4); message.setRelativeFilePath(filename + "." + extension); @@ -376,6 +377,12 @@ public class FileBackend { cursor.close(); } } + if (filename == null) { + final List<String> segments = uri.getPathSegments(); + if (segments.size() > 0) { + filename = segments.get(segments.size() - 1); + } + } int pos = filename == null ? -1 : filename.lastIndexOf('.'); return pos > 0 ? filename.substring(pos + 1) : null; } |