ACTION_GET_CONTENT with multiple mime types

Some apps provide multiple mime types separated by either comma or pipe.

Without this, image/*,video/* only shows videos.
This commit is contained in:
Callum Moffat 2025-02-07 19:50:14 -05:00
parent a948355d2e
commit ff8158c25d

View file

@ -599,10 +599,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
mShouldStopFetching = true mShouldStopFetching = true
mIsGettingDirs = true mIsGettingDirs = true
val getImagesOnly = mIsPickImageIntent || mIsGetImageContentIntent val getImages = mIsPickImageIntent || mIsGetImageContentIntent
val getVideosOnly = mIsPickVideoIntent || mIsGetVideoContentIntent val getVideos = mIsPickVideoIntent || mIsGetVideoContentIntent
getCachedDirectories(getVideosOnly, getImagesOnly) { getCachedDirectories(getVideos && !getImages, getImages && !getVideos) {
gotDirectories(addTempFolderIfNeeded(it)) gotDirectories(addTempFolderIfNeeded(it))
} }
} }
@ -890,10 +890,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun isGetContentIntent(intent: Intent) = intent.action == Intent.ACTION_GET_CONTENT && intent.type != null private fun isGetContentIntent(intent: Intent) = intent.action == Intent.ACTION_GET_CONTENT && intent.type != null
private fun isGetImageContentIntent(intent: Intent) = isGetContentIntent(intent) && private fun isGetImageContentIntent(intent: Intent) = isGetContentIntent(intent) &&
(intent.type!!.startsWith("image/") || intent.type == Images.Media.CONTENT_TYPE) (intent.type!!.split(",", "|").any { it.startsWith("image/") } || intent.type == Images.Media.CONTENT_TYPE)
private fun isGetVideoContentIntent(intent: Intent) = isGetContentIntent(intent) && private fun isGetVideoContentIntent(intent: Intent) = isGetContentIntent(intent) &&
(intent.type!!.startsWith("video/") || intent.type == Video.Media.CONTENT_TYPE) (intent.type!!.split(",", "|").any { it.startsWith("video/") } || intent.type == Video.Media.CONTENT_TYPE)
private fun isGetAnyContentIntent(intent: Intent) = isGetContentIntent(intent) && intent.type == "*/*" private fun isGetAnyContentIntent(intent: Intent) = isGetContentIntent(intent) && intent.type == "*/*"