mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 01:55:04 +08:00
Fix issue on Android 21
This commit is contained in:
parent
bfc70be5bb
commit
343ea42ef5
@ -31,6 +31,8 @@ object MimeTypes {
|
|||||||
const val Jpeg = "image/jpeg"
|
const val Jpeg = "image/jpeg"
|
||||||
const val Gif = "image/gif"
|
const val Gif = "image/gif"
|
||||||
|
|
||||||
|
const val Ogg = "audio/ogg"
|
||||||
|
|
||||||
fun String?.normalizeMimeType() = if (this == BadJpg) Jpeg else this
|
fun String?.normalizeMimeType() = if (this == BadJpg) Jpeg else this
|
||||||
|
|
||||||
fun String?.isMimeTypeImage() = this?.startsWith("image/").orFalse()
|
fun String?.isMimeTypeImage() = this?.startsWith("image/").orFalse()
|
||||||
|
@ -141,7 +141,7 @@ fun Uri.toMultiPickerAudioType(context: Context): MultiPickerAudioType? {
|
|||||||
MultiPickerAudioType(
|
MultiPickerAudioType(
|
||||||
name,
|
name,
|
||||||
size,
|
size,
|
||||||
context.contentResolver.getType(this),
|
sanitize(context.contentResolver.getType(this)),
|
||||||
this,
|
this,
|
||||||
duration
|
duration
|
||||||
)
|
)
|
||||||
@ -150,3 +150,11 @@ fun Uri.toMultiPickerAudioType(context: Context): MultiPickerAudioType? {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun sanitize(type: String?): String? {
|
||||||
|
if (type == "application/ogg") {
|
||||||
|
// Not supported on old system
|
||||||
|
return "audio/ogg"
|
||||||
|
}
|
||||||
|
return type
|
||||||
|
}
|
||||||
|
@ -74,7 +74,6 @@ class VoiceMessageHelper @Inject constructor(
|
|||||||
voiceRecorder.getVoiceMessageFile()
|
voiceRecorder.getVoiceMessageFile()
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// TODO Improve this
|
|
||||||
voiceMessageFile?.let {
|
voiceMessageFile?.let {
|
||||||
val outputFileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", it)
|
val outputFileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", it)
|
||||||
return outputFileUri
|
return outputFileUri
|
||||||
|
Loading…
Reference in New Issue
Block a user