hard code ogg + audio/ mime type to oga
This commit is contained in:
parent
936e6f4cb2
commit
287c416dac
|
@ -332,8 +332,12 @@ public class FileBackend {
|
||||||
Log.d(Config.LOGTAG, "copy " + uri.toString() + " to private storage (mime=" + mime + ")");
|
Log.d(Config.LOGTAG, "copy " + uri.toString() + " to private storage (mime=" + mime + ")");
|
||||||
String extension = MimeUtils.guessExtensionFromMimeType(mime);
|
String extension = MimeUtils.guessExtensionFromMimeType(mime);
|
||||||
if (extension == null) {
|
if (extension == null) {
|
||||||
|
Log.d(Config.LOGTAG,"extension from mime type was null");
|
||||||
extension = getExtensionFromUri(uri);
|
extension = getExtensionFromUri(uri);
|
||||||
}
|
}
|
||||||
|
if ("ogg".equals(extension) && type != null && type.startsWith("audio/")) {
|
||||||
|
extension = "oga";
|
||||||
|
}
|
||||||
message.setRelativeFilePath(message.getUuid() + "." + extension);
|
message.setRelativeFilePath(message.getUuid() + "." + extension);
|
||||||
copyFileToPrivateStorage(mXmppConnectionService.getFileBackend().getFile(message), uri);
|
copyFileToPrivateStorage(mXmppConnectionService.getFileBackend().getFile(message), uri);
|
||||||
}
|
}
|
||||||
|
@ -353,6 +357,12 @@ public class FileBackend {
|
||||||
cursor.close();
|
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('.');
|
int pos = filename == null ? -1 : filename.lastIndexOf('.');
|
||||||
return pos > 0 ? filename.substring(pos + 1) : null;
|
return pos > 0 ? filename.substring(pos + 1) : null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod
|
||||||
final String mimeType = type != null ? type : MimeUtils.guessMimeTypeFromUri(mXmppConnectionService, uri);
|
final String mimeType = type != null ? type : MimeUtils.guessMimeTypeFromUri(mXmppConnectionService, uri);
|
||||||
final int autoAcceptFileSize = mXmppConnectionService.getResources().getInteger(R.integer.auto_accept_filesize);
|
final int autoAcceptFileSize = mXmppConnectionService.getResources().getInteger(R.integer.auto_accept_filesize);
|
||||||
this.originalFileSize = FileBackend.getFileSize(mXmppConnectionService,uri);
|
this.originalFileSize = FileBackend.getFileSize(mXmppConnectionService,uri);
|
||||||
this.isVideoMessage = (mimeType != null && mimeType.startsWith("video/")
|
this.isVideoMessage = (mimeType != null && mimeType.startsWith("video/")) && originalFileSize > autoAcceptFileSize;
|
||||||
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
|
|
||||||
&& originalFileSize > autoAcceptFileSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVideoMessage() {
|
public boolean isVideoMessage() {
|
||||||
|
|
|
@ -33,8 +33,8 @@ import eu.siacs.conversations.entities.Transferable;
|
||||||
* Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
|
* Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
|
||||||
*/
|
*/
|
||||||
public final class MimeUtils {
|
public final class MimeUtils {
|
||||||
private static final Map<String, String> mimeTypeToExtensionMap = new HashMap<String, String>();
|
private static final Map<String, String> mimeTypeToExtensionMap = new HashMap<>();
|
||||||
private static final Map<String, String> extensionToMimeTypeMap = new HashMap<String, String>();
|
private static final Map<String, String> extensionToMimeTypeMap = new HashMap<>();
|
||||||
static {
|
static {
|
||||||
// The following table is based on /etc/mime.types data minus
|
// The following table is based on /etc/mime.types data minus
|
||||||
// chemical/* MIME types and MIME types that don't map to any
|
// chemical/* MIME types and MIME types that don't map to any
|
||||||
|
|
Loading…
Reference in a new issue