mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
fix(compose): Handle different intents in provideSharedAttachments
Manage single and multiple URIs without throwing a class cast exception.
This commit is contained in:
@@ -86,9 +86,14 @@ class ComposeActivityModule {
|
|||||||
@Named("attachments")
|
@Named("attachments")
|
||||||
fun provideSharedAttachments(activity: ComposeActivity): List<Attachment> {
|
fun provideSharedAttachments(activity: ComposeActivity): List<Attachment> {
|
||||||
val uris = mutableListOf<Uri>()
|
val uris = mutableListOf<Uri>()
|
||||||
activity.intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::add)
|
when (activity.intent.action) {
|
||||||
activity.intent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::addAll)
|
Intent.ACTION_SEND -> {
|
||||||
|
activity.intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::add)
|
||||||
|
}
|
||||||
|
Intent.ACTION_SEND_MULTIPLE -> {
|
||||||
|
activity.intent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::addAll)
|
||||||
|
}
|
||||||
|
}
|
||||||
return uris.map { Attachment(activity, it) }
|
return uris.map { Attachment(activity, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user