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 deedb5eb7..2878d7d7b 100644 --- a/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt @@ -629,10 +629,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)) } } @@ -970,16 +970,23 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { return intent.action == Intent.ACTION_GET_CONTENT && intent.type != null } + private fun anyExtraMimeTypeStartingWith(intent: Intent, mimeTypePrefix: String): Boolean { + return intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES) + ?.any { it.startsWith(mimeTypePrefix) } == true + } + private fun isGetImageContentIntent(intent: Intent): Boolean { return isGetContentIntent(intent) && (intent.type!!.startsWith("image/") - || intent.type == Images.Media.CONTENT_TYPE) + || intent.type == Images.Media.CONTENT_TYPE + || anyExtraMimeTypeStartingWith(intent, "image/")) } private fun isGetVideoContentIntent(intent: Intent): Boolean { return isGetContentIntent(intent) && (intent.type!!.startsWith("video/") - || intent.type == Video.Media.CONTENT_TYPE) + || intent.type == Video.Media.CONTENT_TYPE + || anyExtraMimeTypeStartingWith(intent, "video/")) } private fun isGetAnyContentIntent(intent: Intent): Boolean { @@ -1116,8 +1123,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { // cached folders have been loaded, recheck folders one by one starting with the first displayed mLastMediaFetcher?.shouldStop = true mLastMediaFetcher = MediaFetcher(applicationContext) - val getImagesOnly = mIsPickImageIntent || mIsGetImageContentIntent - val getVideosOnly = mIsPickVideoIntent || mIsGetVideoContentIntent + val getImages = mIsPickImageIntent || mIsGetImageContentIntent + val getVideos = mIsPickVideoIntent || mIsGetVideoContentIntent + val getImagesOnly = getImages && !getVideos + val getVideosOnly = getVideos && !getImages val favoritePaths = getFavoritePaths() val hiddenString = getString(R.string.hidden) val albumCovers = config.parseAlbumCovers()