diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index c9400fa73..6d9fcf2ee 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -179,7 +179,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun excludeFolder() { - + config.addExcludedFolder(mPath) + finish() } private fun deleteDirectoryIfEmpty() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index fee67945e..009cdc287 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -197,7 +197,9 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList) { + val excludedPaths = config.excludedFolders + val ignorePaths = paths.filter { excludedPaths.contains(it) } + paths.removeAll(ignorePaths) + } + private fun movePinnedToFront(dirs: ArrayList): ArrayList { val foundFolders = ArrayList() val pinnedFolders = config.pinnedFolders diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt index 4392c4bd6..864cd40ca 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -54,6 +54,20 @@ class Config(context: Context) : BaseConfig(context) { pinnedFolders = currPinnedFolders } + fun addExcludedFolder(path: String) { + addExcludedFolders(HashSet(Arrays.asList(path))) + } + + fun addExcludedFolders(paths: Set) { + val currExcludedFolders = HashSet(excludedFolders) + currExcludedFolders.addAll(paths) + excludedFolders = currExcludedFolders + } + + var excludedFolders: MutableSet + get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet()) + 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() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index d43d85ef8..85e5dec97 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -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"