diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index d2bb50de1..b4434fc41 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -749,7 +749,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val foldersToScan = mediaFetcher.getFoldersToScan() foldersToScan.add(FAVORITES) - foldersToScan.add(RECYCLE_BIN) + if (config.showRecycleBinAtFolders) { + foldersToScan.add(RECYCLE_BIN) + } else { + foldersToScan.remove(RECYCLE_BIN) + } + dirs.forEach { foldersToScan.remove(it.path) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt index 17f13cf52..13a79370e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -75,6 +75,7 @@ class SettingsActivity : SimpleActivity() { setupSkipDeleteConfirmation() setupManageBottomActions() setupUseRecycleBin() + setupShowRecycleBin() setupEmptyRecycleBin() updateTextColors(settings_holder) setupSectionColors() @@ -441,6 +442,7 @@ class SettingsActivity : SimpleActivity() { private fun setupUseRecycleBin() { settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin) + settings_show_recycle_bin_holder.beVisibleIf(config.useRecycleBin) settings_use_recycle_bin.isChecked = config.useRecycleBin settings_use_recycle_bin_holder.setOnClickListener { settings_use_recycle_bin.toggle() @@ -449,6 +451,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupShowRecycleBin() { + settings_show_recycle_bin.isChecked = config.showRecycleBinAtFolders + settings_show_recycle_bin_holder.setOnClickListener { + settings_show_recycle_bin.toggle() + config.showRecycleBinAtFolders = settings_show_recycle_bin.isChecked + } + } + private fun setupEmptyRecycleBin() { Thread { mRecycleBinContentSize = galleryDB.MediumDao().getDeletedMedia().sumByLong { it.size } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt index beae8a757..5fc78e20e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt @@ -288,6 +288,11 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: } catch (e: SQLiteException) { ArrayList() } + + if (!config.showRecycleBinAtFolders) { + directories.removeAll { it.isRecycleBin() } + } + val shouldShowHidden = config.shouldShowHidden val excludedPaths = config.excludedFolders val includedPaths = config.includedFolders 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 93d0608df..ff80bbe58 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -376,4 +376,8 @@ class Config(context: Context) : BaseConfig(context) { Environment.DIRECTORY_DCIM, Environment.DIRECTORY_PICTURES ) + + var showRecycleBinAtFolders: Boolean + get() = prefs.getBoolean(SHOW_RECYCLE_BIN_AT_FOLDERS, true) + set(showRecycleBinAtFolders) = prefs.edit().putBoolean(SHOW_RECYCLE_BIN_AT_FOLDERS, showRecycleBinAtFolders).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 53e17f4f2..0a74ddbd3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -58,6 +58,7 @@ const val WAS_RECYCLE_BIN_PINNED = "was_recycle_bin_pinned" const val USE_RECYCLE_BIN = "use_recycle_bin" const val GROUP_BY = "group_by" const val EVER_SHOWN_FOLDERS = "ever_shown_folders" +const val SHOW_RECYCLE_BIN_AT_FOLDERS = "show_recycle_bin_at_folders" // slideshow const val SLIDESHOW_INTERVAL = "slideshow_interval" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 6c70a99df..822fc4989 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1045,6 +1045,29 @@ + + + + + +