Skip to content
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
23 changes: 16 additions & 7 deletions app/src/main/kotlin/org/fossify/gallery/activities/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down
Loading