Add fix for m4a mapping to audio/mpeg.

This commit is contained in:
Clark
2023-04-03 09:58:09 -04:00
committed by Alex Hart
parent f9548dcffe
commit 83b0963533
2 changed files with 41 additions and 10 deletions

View File

@@ -48,7 +48,9 @@ class ShareRepository(context: Context) {
}
val uri = multiShareExternal.uri
val mimeType = getMimeType(appContext, uri, multiShareExternal.mimeType)
val size = getSize(appContext, uri)
val name = getFileName(appContext, uri)
val mimeType = getMimeType(appContext, uri, multiShareExternal.mimeType, name?.substringAfterLast('.', ""))
val stream: InputStream = try {
appContext.contentResolver.openInputStream(uri)
@@ -57,9 +59,6 @@ class ShareRepository(context: Context) {
null
} ?: return ResolvedShareData.Failure
val size = getSize(appContext, uri)
val name = getFileName(appContext, uri)
val blobUri: Uri = try {
BlobProvider.getInstance()
.forData(stream, size)
@@ -142,8 +141,8 @@ class ShareRepository(context: Context) {
companion object {
private val TAG = Log.tag(ShareRepository::class.java)
private fun getMimeType(context: Context, uri: Uri, mimeType: String?): String {
var updatedMimeType = MediaUtil.getMimeType(context, uri)
private fun getMimeType(context: Context, uri: Uri, mimeType: String?, fileExtension: String? = null): String {
var updatedMimeType = MediaUtil.getMimeType(context, uri, fileExtension)
if (updatedMimeType == null) {
updatedMimeType = MediaUtil.getCorrectedMimeType(mimeType)
}