check noMedia file existence only below Android 11 in some cases
This commit is contained in:
parent
0b2f0da4be
commit
969f0334f3
2 changed files with 10 additions and 11 deletions
|
@ -1,6 +1,5 @@
|
||||||
package com.simplemobiletools.gallery.pro.extensions
|
package com.simplemobiletools.gallery.pro.extensions
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.appwidget.AppWidgetManager
|
import android.appwidget.AppWidgetManager
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -30,7 +29,6 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.views.MySquareImageView
|
import com.simplemobiletools.commons.views.MySquareImageView
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.activities.SettingsActivity
|
|
||||||
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
||||||
import com.simplemobiletools.gallery.pro.databases.GalleryDatabase
|
import com.simplemobiletools.gallery.pro.databases.GalleryDatabase
|
||||||
import com.simplemobiletools.gallery.pro.helpers.*
|
import com.simplemobiletools.gallery.pro.helpers.*
|
||||||
|
@ -43,10 +41,6 @@ import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.nio.channels.FileChannel
|
import java.nio.channels.FileChannel
|
||||||
import java.util.*
|
|
||||||
import kotlin.Comparator
|
|
||||||
import kotlin.collections.ArrayList
|
|
||||||
import kotlin.collections.HashMap
|
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
|
||||||
val Context.audioManager get() = getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
val Context.audioManager get() = getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||||
|
|
|
@ -2,16 +2,21 @@ package com.simplemobiletools.gallery.pro.extensions
|
||||||
|
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import com.simplemobiletools.commons.helpers.NOMEDIA
|
import com.simplemobiletools.commons.helpers.NOMEDIA
|
||||||
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
fun String.isThisOrParentIncluded(includedPaths: MutableSet<String>) = includedPaths.any { equals(it, true) } || includedPaths.any { "$this/".startsWith("$it/", true) }
|
fun String.isThisOrParentIncluded(includedPaths: MutableSet<String>) =
|
||||||
|
includedPaths.any { equals(it, true) } || includedPaths.any { "$this/".startsWith("$it/", true) }
|
||||||
|
|
||||||
fun String.isThisOrParentExcluded(excludedPaths: MutableSet<String>) = excludedPaths.any { equals(it, true) } || excludedPaths.any { "$this/".startsWith("$it/", true) }
|
fun String.isThisOrParentExcluded(excludedPaths: MutableSet<String>) =
|
||||||
|
excludedPaths.any { equals(it, true) } || excludedPaths.any { "$this/".startsWith("$it/", true) }
|
||||||
|
|
||||||
// cache which folders contain .nomedia files to avoid checking them over and over again
|
// cache which folders contain .nomedia files to avoid checking them over and over again
|
||||||
fun String.shouldFolderBeVisible(excludedPaths: MutableSet<String>, includedPaths: MutableSet<String>, showHidden: Boolean,
|
fun String.shouldFolderBeVisible(
|
||||||
folderNoMediaStatuses: HashMap<String, Boolean>, callback: (path: String, hasNoMedia: Boolean) -> Unit): Boolean {
|
excludedPaths: MutableSet<String>, includedPaths: MutableSet<String>, showHidden: Boolean,
|
||||||
|
folderNoMediaStatuses: HashMap<String, Boolean>, callback: (path: String, hasNoMedia: Boolean) -> Unit
|
||||||
|
): Boolean {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -36,7 +41,7 @@ fun String.shouldFolderBeVisible(excludedPaths: MutableSet<String>, includedPath
|
||||||
val containsNoMedia = if (showHidden) {
|
val containsNoMedia = if (showHidden) {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
folderNoMediaStatuses.getOrElse("$this/$NOMEDIA", { false }) || File(this, NOMEDIA).exists()
|
folderNoMediaStatuses.getOrElse("$this/$NOMEDIA", { false }) || (!isRPlus() && File(this, NOMEDIA).exists())
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (!showHidden && containsNoMedia) {
|
return if (!showHidden && containsNoMedia) {
|
||||||
|
|
Loading…
Reference in a new issue