Skip to content

Fix generic mime type used when externally sharing several files #4715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
* Use this function to retrieve files which are shared from another application or internally
* by using android.intent.action.SEND or android.intent.action.SEND_MULTIPLE actions.
*/
private fun getIncomingUris(intent: Intent, type: String): List<ShareIntentHandler.UriToShare> {
private fun getIncomingUris(intent: Intent, fallbackMimeType: String): List<ShareIntentHandler.UriToShare> {
val uriList = mutableListOf<Uri>()
if (intent.action == Intent.ACTION_SEND) {
IntentCompat.getParcelableExtra(intent, Intent.EXTRA_STREAM, Uri::class.java)
Expand All @@ -115,9 +115,12 @@
}
}
return uriList.map { uri ->
// The value in fallbackMimeType can be wrong, especially if several uris were received
// in the same intent (i.e. 'image/*'). We need to check the mime type of each uri.
val mimeType = context.contentResolver.getType(uri) ?: fallbackMimeType
ShareIntentHandler.UriToShare(
uri = uri,
mimeType = type
mimeType = mimeType,

Check warning on line 123 in features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareIntentHandler.kt

View check run for this annotation

Codecov / codecov/patch

features/share/impl/src/main/kotlin/io/element/android/features/share/impl/ShareIntentHandler.kt#L123

Added line #L123 was not covered by tests
)
}
}
Expand Down
Loading