Skip to content

Commit

Permalink
ACTION_GET_CONTENT with multiple mime types
Browse files Browse the repository at this point in the history
Some apps provide multiple mime types separated by either comma or pipe.

Without this, image/*,video/* only shows videos.
  • Loading branch information
moffatman committed Feb 8, 2025
1 parent a948355 commit ff8158c
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down Expand Up @@ -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 == "*/*"

Expand Down

0 comments on commit ff8158c

Please sign in to comment.