File tree 1 file changed +5
-2
lines changed
features/share/impl/src/main/kotlin/io/element/android/features/share/impl 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ class DefaultShareIntentHandler @Inject constructor(
89
89
* Use this function to retrieve files which are shared from another application or internally
90
90
* by using android.intent.action.SEND or android.intent.action.SEND_MULTIPLE actions.
91
91
*/
92
- private fun getIncomingUris (intent : Intent , type : String ): List <ShareIntentHandler .UriToShare > {
92
+ private fun getIncomingUris (intent : Intent , fallbackMimeType : String ): List <ShareIntentHandler .UriToShare > {
93
93
val uriList = mutableListOf<Uri >()
94
94
if (intent.action == Intent .ACTION_SEND ) {
95
95
IntentCompat .getParcelableExtra(intent, Intent .EXTRA_STREAM , Uri ::class .java)
@@ -115,9 +115,12 @@ class DefaultShareIntentHandler @Inject constructor(
115
115
}
116
116
}
117
117
return uriList.map { uri ->
118
+ // The value in fallbackMimeType can be wrong, especially if several uris were received
119
+ // in the same intent (i.e. 'image/*'). We need to check the mime type of each uri.
120
+ val mimeType = context.contentResolver.getType(uri) ? : fallbackMimeType
118
121
ShareIntentHandler .UriToShare (
119
122
uri = uri,
120
- mimeType = type
123
+ mimeType = mimeType,
121
124
)
122
125
}
123
126
}
You can’t perform that action at this time.
0 commit comments