Merge pull request #1146 from vector-im/feature/workaround_crash_select_gif_keyboard

WorkAround / crash android 10 gif from keyboard
This commit is contained in:
Valere 2020-03-17 09:20:49 +01:00 committed by GitHub
commit 7664b716b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -8,7 +8,9 @@ Improvements 🙌:
- Implementation of /join command - Implementation of /join command
Bugfix 🐛: 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 🗣: Translations 🗣:
- -

View File

@ -177,19 +177,28 @@ class AttachmentsHelper private constructor(private val context: Context,
fun handleShareIntent(intent: Intent): Boolean { fun handleShareIntent(intent: Intent): Boolean {
val type = intent.resolveType(context) ?: return false val type = intent.resolveType(context) ?: return false
if (type.startsWith("image")) { if (type.startsWith("image")) {
imagePicker.submit(IntentUtils.getPickerIntentForSharing(intent)) imagePicker.submit(safeShareIntent(intent))
} else if (type.startsWith("video")) { } else if (type.startsWith("video")) {
videoPicker.submit(IntentUtils.getPickerIntentForSharing(intent)) videoPicker.submit(safeShareIntent(intent))
} else if (type.startsWith("audio")) { } else if (type.startsWith("audio")) {
videoPicker.submit(IntentUtils.getPickerIntentForSharing(intent)) videoPicker.submit(safeShareIntent(intent))
} else if (type.startsWith("application") || type.startsWith("file") || type.startsWith("*")) { } else if (type.startsWith("application") || type.startsWith("file") || type.startsWith("*")) {
filePicker.submit(IntentUtils.getPickerIntentForSharing(intent)) filePicker.submit(safeShareIntent(intent))
} else { } else {
return false return false
} }
return true 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? { private fun getPickerManagerForRequestCode(requestCode: Int): PickerManager? {
return when (requestCode) { return when (requestCode) {
PICK_IMAGE_DEVICE -> imagePicker PICK_IMAGE_DEVICE -> imagePicker