mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
add the exclusion functionality
This commit is contained in:
parent
f354818b66
commit
4572295698
5 changed files with 27 additions and 2 deletions
|
@ -179,7 +179,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
|
||||
private fun excludeFolder() {
|
||||
|
||||
config.addExcludedFolder(mPath)
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun deleteDirectoryIfEmpty() {
|
||||
|
|
|
@ -197,7 +197,9 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
}
|
||||
|
||||
private fun excludeFolder() {
|
||||
|
||||
activity.config.addExcludedFolders(getSelectedPaths())
|
||||
listener?.refreshItems()
|
||||
actMode?.finish()
|
||||
}
|
||||
|
||||
private fun noMediaHandled() {
|
||||
|
|
|
@ -23,6 +23,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
|||
val showMedia = config.showMedia
|
||||
val fileSorting = config.fileSorting
|
||||
val parents = context.getParents()
|
||||
removeExcludedFolders(parents)
|
||||
|
||||
parents.forEach {
|
||||
val filenames = File(it).list()
|
||||
|
@ -92,6 +93,12 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
|||
return directories
|
||||
}
|
||||
|
||||
private fun removeExcludedFolders(paths: MutableList<String>) {
|
||||
val excludedPaths = config.excludedFolders
|
||||
val ignorePaths = paths.filter { excludedPaths.contains(it) }
|
||||
paths.removeAll(ignorePaths)
|
||||
}
|
||||
|
||||
private fun movePinnedToFront(dirs: ArrayList<Directory>): ArrayList<Directory> {
|
||||
val foundFolders = ArrayList<Directory>()
|
||||
val pinnedFolders = config.pinnedFolders
|
||||
|
|
|
@ -54,6 +54,20 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
pinnedFolders = currPinnedFolders
|
||||
}
|
||||
|
||||
fun addExcludedFolder(path: String) {
|
||||
addExcludedFolders(HashSet<String>(Arrays.asList(path)))
|
||||
}
|
||||
|
||||
fun addExcludedFolders(paths: Set<String>) {
|
||||
val currExcludedFolders = HashSet<String>(excludedFolders)
|
||||
currExcludedFolders.addAll(paths)
|
||||
excludedFolders = currExcludedFolders
|
||||
}
|
||||
|
||||
var excludedFolders: MutableSet<String>
|
||||
get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet<String>())
|
||||
set(excludedFolders) = prefs.edit().remove(EXCLUDED_FOLDERS).putStringSet(EXCLUDED_FOLDERS, excludedFolders).apply()
|
||||
|
||||
fun saveFolderMedia(path: String, json: String) {
|
||||
prefs.edit().putString(SAVE_FOLDER_PREFIX + path, json).apply()
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ val SHOW_MEDIA = "show_media"
|
|||
val SAVE_FOLDER_PREFIX = "folder_"
|
||||
val HIDE_FOLDER_TOOLTIP_SHOWN = "hide_folder_tooltip_shown"
|
||||
val EXCLUDE_FOLDER_TOOLTIP_SHOWN = "exclude_folder_tooltip_shown"
|
||||
val EXCLUDED_FOLDERS = "excluded_folders"
|
||||
|
||||
val NOMEDIA = ".nomedia"
|
||||
|
||||
|
|
Loading…
Reference in a new issue