WorkAround / crash android 10 gif from keyboard

fixes #1136
This commit is contained in:
Valere 2020-03-16 16:00:22 +01:00
parent eb74523905
commit 067a22883c
2 changed files with 16 additions and 5 deletions

View File

@ -8,7 +8,9 @@ Improvements 🙌:
- Implementation of /join command
Bugfix 🐛:
- Message transitions in encrypted rooms are jarring #518
- Message transitions in encrypted rooms are jarring #518
- Images that failed to send are waiting to be sent forever #1145
- Fix / Crashed when trying to send a gif from the Gboard #1136
Translations 🗣:
-

View File

@ -177,19 +177,28 @@ class AttachmentsHelper private constructor(private val context: Context,
fun handleShareIntent(intent: Intent): Boolean {
val type = intent.resolveType(context) ?: return false
if (type.startsWith("image")) {
imagePicker.submit(IntentUtils.getPickerIntentForSharing(intent))
imagePicker.submit(safeShareIntent(intent))
} else if (type.startsWith("video")) {
videoPicker.submit(IntentUtils.getPickerIntentForSharing(intent))
videoPicker.submit(safeShareIntent(intent))
} else if (type.startsWith("audio")) {
videoPicker.submit(IntentUtils.getPickerIntentForSharing(intent))
videoPicker.submit(safeShareIntent(intent))
} else if (type.startsWith("application") || type.startsWith("file") || type.startsWith("*")) {
filePicker.submit(IntentUtils.getPickerIntentForSharing(intent))
filePicker.submit(safeShareIntent(intent))
} else {
return false
}
return true
}
private fun safeShareIntent(intent: Intent): Intent {
// Work around for getPickerIntentForSharing doing NPE in android 10
return try {
IntentUtils.getPickerIntentForSharing(intent)
} catch (failure: Throwable) {
intent
}
}
private fun getPickerManagerForRequestCode(requestCode: Int): PickerManager? {
return when (requestCode) {
PICK_IMAGE_DEVICE -> imagePicker