From ff8158c25db29ea503e1927db431d15726e44684 Mon Sep 17 00:00:00 2001 From: Callum Moffat Date: Fri, 7 Feb 2025 19:50:14 -0500 Subject: [PATCH] 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. --- .../org/fossify/gallery/activities/MainActivity.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt b/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt index f9b1fda01..af5b57c7a 100644 --- a/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt @@ -599,10 +599,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { mShouldStopFetching = true mIsGettingDirs = true - val getImagesOnly = mIsPickImageIntent || mIsGetImageContentIntent - val getVideosOnly = mIsPickVideoIntent || mIsGetVideoContentIntent + val getImages = mIsPickImageIntent || mIsGetImageContentIntent + val getVideos = mIsPickVideoIntent || mIsGetVideoContentIntent - getCachedDirectories(getVideosOnly, getImagesOnly) { + getCachedDirectories(getVideos && !getImages, getImages && !getVideos) { 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 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) && - (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 == "*/*"