mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
rely on noMedia files from MediaStore on a couple more places
This commit is contained in:
parent
eb9ca5df77
commit
4ef159e912
5 changed files with 22 additions and 21 deletions
|
@ -77,7 +77,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.31.8'
|
implementation 'com.simplemobiletools:commons:5.31.13'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
|
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'
|
||||||
|
|
|
@ -23,7 +23,6 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog
|
import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.dialogs.NewAppsIconsDialog
|
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
|
@ -903,6 +902,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
val hiddenString = getString(R.string.hidden)
|
val hiddenString = getString(R.string.hidden)
|
||||||
val albumCovers = config.parseAlbumCovers()
|
val albumCovers = config.parseAlbumCovers()
|
||||||
val includedFolders = config.includedFolders
|
val includedFolders = config.includedFolders
|
||||||
|
val noMediaFolders = getNoMediaFoldersSync()
|
||||||
val tempFolderPath = config.tempFolderPath
|
val tempFolderPath = config.tempFolderPath
|
||||||
val getProperFileSize = config.directorySorting and SORT_BY_SIZE != 0
|
val getProperFileSize = config.directorySorting and SORT_BY_SIZE != 0
|
||||||
val favoritePaths = getFavoritePaths()
|
val favoritePaths = getFavoritePaths()
|
||||||
|
@ -937,7 +937,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
directory
|
directory
|
||||||
} else {
|
} else {
|
||||||
createDirectoryFromMedia(directory.path, curMedia, albumCovers, hiddenString, includedFolders, getProperFileSize)
|
createDirectoryFromMedia(directory.path, curMedia, albumCovers, hiddenString, includedFolders, getProperFileSize, noMediaFolders)
|
||||||
}
|
}
|
||||||
|
|
||||||
// we are looping through the already displayed folders looking for changes, do not do anything if nothing changed
|
// we are looping through the already displayed folders looking for changes, do not do anything if nothing changed
|
||||||
|
@ -1043,7 +1043,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val newDir = createDirectoryFromMedia(folder, newMedia, albumCovers, hiddenString, includedFolders, getProperFileSize)
|
val newDir = createDirectoryFromMedia(folder, newMedia, albumCovers, hiddenString, includedFolders, getProperFileSize, noMediaFolders)
|
||||||
dirs.add(newDir)
|
dirs.add(newDir)
|
||||||
setupAdapter(dirs)
|
setupAdapter(dirs)
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
val includedFolders = activity.config.includedFolders
|
val includedFolders = activity.config.includedFolders
|
||||||
val hidden = activity.getString(R.string.hidden)
|
val hidden = activity.getString(R.string.hidden)
|
||||||
dirs.forEach {
|
dirs.forEach {
|
||||||
it.name = activity.checkAppendingHidden(it.path, hidden, includedFolders)
|
it.name = activity.checkAppendingHidden(it.path, hidden, includedFolders, ArrayList())
|
||||||
}
|
}
|
||||||
listener?.updateDirectories(dirs.toMutableList() as ArrayList)
|
listener?.updateDirectories(dirs.toMutableList() as ArrayList)
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
|
|
|
@ -374,9 +374,9 @@ fun Context.storeDirectoryItems(items: ArrayList<Directory>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders: MutableSet<String>): String {
|
fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders: MutableSet<String>, noMediaFolders: ArrayList<String>): String {
|
||||||
val dirName = getFolderNameFromPath(path)
|
val dirName = getFolderNameFromPath(path)
|
||||||
return if (path.doesThisOrParentHaveNoMedia() && !path.isThisOrParentIncluded(includedFolders)) {
|
return if (path.doesThisOrParentHaveNoMedia(noMediaFolders) && !path.isThisOrParentIncluded(includedFolders)) {
|
||||||
"$dirName $hidden"
|
"$dirName $hidden"
|
||||||
} else {
|
} else {
|
||||||
dirName
|
dirName
|
||||||
|
@ -524,10 +524,10 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
|
||||||
val includedPaths = config.includedFolders
|
val includedPaths = config.includedFolders
|
||||||
|
|
||||||
val noMediaFolders = getNoMediaFoldersSync()
|
val noMediaFolders = getNoMediaFoldersSync()
|
||||||
val folderNomediaStatuses = HashMap<String, Boolean>()
|
val folderNoMediaStatuses = HashMap<String, Boolean>()
|
||||||
var filteredDirectories = directories.filter {
|
var filteredDirectories = directories.filter {
|
||||||
it.path.shouldFolderBeVisible(excludedPaths, includedPaths, shouldShowHidden, folderNomediaStatuses, noMediaFolders) { path, hasNoMedia ->
|
it.path.shouldFolderBeVisible(excludedPaths, includedPaths, shouldShowHidden, folderNoMediaStatuses, noMediaFolders) { path, hasNoMedia ->
|
||||||
folderNomediaStatuses[path] = hasNoMedia
|
folderNoMediaStatuses[path] = hasNoMedia
|
||||||
}
|
}
|
||||||
} as ArrayList<Directory>
|
} as ArrayList<Directory>
|
||||||
val filterMedia = config.filterMedia
|
val filterMedia = config.filterMedia
|
||||||
|
@ -547,7 +547,7 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
|
||||||
|
|
||||||
val hiddenString = resources.getString(R.string.hidden)
|
val hiddenString = resources.getString(R.string.hidden)
|
||||||
filteredDirectories.forEach {
|
filteredDirectories.forEach {
|
||||||
it.name = if (it.path.doesThisOrParentHaveNoMedia() && !it.path.isThisOrParentIncluded(includedPaths)) {
|
it.name = if (it.path.doesThisOrParentHaveNoMedia(noMediaFolders) && !it.path.isThisOrParentIncluded(includedPaths)) {
|
||||||
"${it.name.removeSuffix(hiddenString).trim()} $hiddenString"
|
"${it.name.removeSuffix(hiddenString).trim()} $hiddenString"
|
||||||
} else {
|
} else {
|
||||||
it.name.removeSuffix(hiddenString).trim()
|
it.name.removeSuffix(hiddenString).trim()
|
||||||
|
@ -813,7 +813,7 @@ fun Context.addPathToDB(path: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.createDirectoryFromMedia(path: String, curMedia: ArrayList<Medium>, albumCovers: ArrayList<AlbumCover>, hiddenString: String,
|
fun Context.createDirectoryFromMedia(path: String, curMedia: ArrayList<Medium>, albumCovers: ArrayList<AlbumCover>, hiddenString: String,
|
||||||
includedFolders: MutableSet<String>, getProperFileSize: Boolean): Directory {
|
includedFolders: MutableSet<String>, getProperFileSize: Boolean, noMediaFolders: ArrayList<String>): Directory {
|
||||||
val OTGPath = config.OTGPath
|
val OTGPath = config.OTGPath
|
||||||
val grouped = MediaFetcher(this).groupMedia(curMedia, path)
|
val grouped = MediaFetcher(this).groupMedia(curMedia, path)
|
||||||
var thumbnail: String? = null
|
var thumbnail: String? = null
|
||||||
|
@ -837,7 +837,7 @@ fun Context.createDirectoryFromMedia(path: String, curMedia: ArrayList<Medium>,
|
||||||
val defaultMedium = Medium(0, "", "", "", 0L, 0L, 0L, 0, 0, false, 0L)
|
val defaultMedium = Medium(0, "", "", "", 0L, 0L, 0L, 0, 0, false, 0L)
|
||||||
val firstItem = curMedia.firstOrNull() ?: defaultMedium
|
val firstItem = curMedia.firstOrNull() ?: defaultMedium
|
||||||
val lastItem = curMedia.lastOrNull() ?: defaultMedium
|
val lastItem = curMedia.lastOrNull() ?: defaultMedium
|
||||||
val dirName = checkAppendingHidden(path, hiddenString, includedFolders)
|
val dirName = checkAppendingHidden(path, hiddenString, includedFolders, noMediaFolders)
|
||||||
val lastModified = if (isSortingAscending) Math.min(firstItem.modified, lastItem.modified) else Math.max(firstItem.modified, lastItem.modified)
|
val lastModified = if (isSortingAscending) Math.min(firstItem.modified, lastItem.modified) else Math.max(firstItem.modified, lastItem.modified)
|
||||||
val dateTaken = if (isSortingAscending) Math.min(firstItem.taken, lastItem.taken) else Math.max(firstItem.taken, lastItem.taken)
|
val dateTaken = if (isSortingAscending) Math.min(firstItem.taken, lastItem.taken) else Math.max(firstItem.taken, lastItem.taken)
|
||||||
val size = if (getProperFileSize) curMedia.sumByLong { it.size } else 0L
|
val size = if (getProperFileSize) curMedia.sumByLong { it.size } else 0L
|
||||||
|
@ -879,6 +879,7 @@ fun Context.updateDirectoryPath(path: String) {
|
||||||
val hiddenString = getString(R.string.hidden)
|
val hiddenString = getString(R.string.hidden)
|
||||||
val albumCovers = config.parseAlbumCovers()
|
val albumCovers = config.parseAlbumCovers()
|
||||||
val includedFolders = config.includedFolders
|
val includedFolders = config.includedFolders
|
||||||
|
val noMediaFolders = getNoMediaFoldersSync()
|
||||||
|
|
||||||
val sorting = config.getFolderSorting(path)
|
val sorting = config.getFolderSorting(path)
|
||||||
val grouping = config.getFolderGrouping(path)
|
val grouping = config.getFolderGrouping(path)
|
||||||
|
@ -899,7 +900,7 @@ fun Context.updateDirectoryPath(path: String) {
|
||||||
val favoritePaths = getFavoritePaths()
|
val favoritePaths = getFavoritePaths()
|
||||||
val curMedia = mediaFetcher.getFilesFrom(path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, getProperFileSize,
|
val curMedia = mediaFetcher.getFilesFrom(path, getImagesOnly, getVideosOnly, getProperDateTaken, getProperLastModified, getProperFileSize,
|
||||||
favoritePaths, false, lastModifieds, dateTakens)
|
favoritePaths, false, lastModifieds, dateTakens)
|
||||||
val directory = createDirectoryFromMedia(path, curMedia, albumCovers, hiddenString, includedFolders, getProperFileSize)
|
val directory = createDirectoryFromMedia(path, curMedia, albumCovers, hiddenString, includedFolders, getProperFileSize, noMediaFolders)
|
||||||
updateDBDirectory(directory)
|
updateDBDirectory(directory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ fun String.isThisOrParentExcluded(excludedPaths: MutableSet<String>) = excludedP
|
||||||
|
|
||||||
// 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(excludedPaths: MutableSet<String>, includedPaths: MutableSet<String>, showHidden: Boolean,
|
||||||
folderNomediaStatuses: HashMap<String, Boolean>, noMediaFolders: ArrayList<String> = ArrayList(),
|
folderNoMediaStatuses: HashMap<String, Boolean>, noMediaFolders: ArrayList<String> = ArrayList(),
|
||||||
callback: (path: String, hasNoMedia: Boolean) -> Unit): Boolean {
|
callback: (path: String, hasNoMedia: Boolean) -> Unit): Boolean {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
return false
|
return false
|
||||||
|
@ -55,8 +55,8 @@ fun String.shouldFolderBeVisible(excludedPaths: MutableSet<String>, includedPath
|
||||||
for (i in 0 until count { it == '/' } - 1) {
|
for (i in 0 until count { it == '/' } - 1) {
|
||||||
curPath = curPath.substringBeforeLast('/')
|
curPath = curPath.substringBeforeLast('/')
|
||||||
val pathToCheck = "$curPath/${NOMEDIA}"
|
val pathToCheck = "$curPath/${NOMEDIA}"
|
||||||
if (folderNomediaStatuses.contains(pathToCheck)) {
|
if (folderNoMediaStatuses.contains(pathToCheck)) {
|
||||||
if (folderNomediaStatuses[pathToCheck] == true) {
|
if (folderNoMediaStatuses[pathToCheck] == true) {
|
||||||
containsNoMediaOrDot = true
|
containsNoMediaOrDot = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue