hard code ogg + audio/ mime type to oga

This commit is contained in:
Daniel Gultsch 2018-04-29 15:19:13 +02:00
parent 936e6f4cb2
commit 287c416dac
3 changed files with 13 additions and 5 deletions

View file

@ -332,8 +332,12 @@ 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 ("ogg".equals(extension) && type != null && type.startsWith("audio/")) {
extension = "oga";
}
message.setRelativeFilePath(message.getUuid() + "." + extension);
copyFileToPrivateStorage(mXmppConnectionService.getFileBackend().getFile(message), uri);
}
@ -353,6 +357,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;
}

View file

@ -45,9 +45,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod
final String mimeType = type != null ? type : MimeUtils.guessMimeTypeFromUri(mXmppConnectionService, uri);
final int autoAcceptFileSize = mXmppConnectionService.getResources().getInteger(R.integer.auto_accept_filesize);
this.originalFileSize = FileBackend.getFileSize(mXmppConnectionService,uri);
this.isVideoMessage = (mimeType != null && mimeType.startsWith("video/")
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
&& originalFileSize > autoAcceptFileSize;
this.isVideoMessage = (mimeType != null && mimeType.startsWith("video/")) && originalFileSize > autoAcceptFileSize;
}
public boolean isVideoMessage() {

View file

@ -33,8 +33,8 @@ import eu.siacs.conversations.entities.Transferable;
* Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
*/
public final class MimeUtils {
private static final Map<String, String> mimeTypeToExtensionMap = new HashMap<String, String>();
private static final Map<String, String> extensionToMimeTypeMap = new HashMap<String, String>();
private static final Map<String, String> mimeTypeToExtensionMap = new HashMap<>();
private static final Map<String, String> extensionToMimeTypeMap = new HashMap<>();
static {
// The following table is based on /etc/mime.types data minus
// chemical/* MIME types and MIME types that don't map to any