mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +02:00
fix voice message handling for messages sent from Android 4.X devices #916
This commit is contained in:
parent
0b99c90a33
commit
0cfd44990c
4 changed files with 20 additions and 6 deletions
|
@ -918,7 +918,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
String ext = "";
|
String ext = "";
|
||||||
if(filename==null) {
|
if(filename==null) {
|
||||||
filename = new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date());
|
filename = new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date());
|
||||||
ext = "."+MimeTypeMap.getSingleton().getExtensionFromMimeType(attachment.getContentType());
|
ext = "." + MediaUtil.getExtensionFromMimeType(attachment.getContentType());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i = filename.lastIndexOf(".");
|
int i = filename.lastIndexOf(".");
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.util.Log;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.util.FileProviderUtil;
|
import org.thoughtcrime.securesms.util.FileProviderUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -189,7 +190,7 @@ public class PersistentBlobProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NonNull String getExtensionFromMimeType(String mimeType) {
|
private static @NonNull String getExtensionFromMimeType(String mimeType) {
|
||||||
final String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
|
final String extension = MediaUtil.getExtensionFromMimeType(mimeType);
|
||||||
return extension != null ? extension : BLOB_EXTENSION;
|
return extension != null ? extension : BLOB_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package org.thoughtcrime.securesms.util;
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.media.MediaMetadataRetriever;
|
import android.media.MediaMetadataRetriever;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.WorkerThread;
|
import android.support.annotation.WorkerThread;
|
||||||
|
@ -281,4 +279,20 @@ public class MediaUtil {
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getExtensionFromMimeType(String contentType) {
|
||||||
|
String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(contentType);
|
||||||
|
if (extension != null) {
|
||||||
|
return extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
//custom handling needed for unsupported extensions on Android 4.X
|
||||||
|
switch (contentType) {
|
||||||
|
case AUDIO_AAC:
|
||||||
|
return "aac";
|
||||||
|
// TODO: add webp and other unsupported extensions here
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,8 +126,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateOutputFileName(@NonNull String contentType, long timestamp) {
|
private String generateOutputFileName(@NonNull String contentType, long timestamp) {
|
||||||
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
|
String extension = MediaUtil.getExtensionFromMimeType(contentType);
|
||||||
String extension = mimeTypeMap.getExtensionFromMimeType(contentType);
|
|
||||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd-HHmmss");
|
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd-HHmmss");
|
||||||
String base = "deltachat-" + dateFormatter.format(timestamp);
|
String base = "deltachat-" + dateFormatter.format(timestamp);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue