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 6a4dc9887..ac11c3169 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -768,7 +768,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { val foldersToScan = mediaFetcher.getFoldersToScan() foldersToScan.add(FAVORITES) - if (config.showRecycleBinAtFolders) { + if (config.useRecycleBin && config.showRecycleBinAtFolders) { foldersToScan.add(RECYCLE_BIN) } else { foldersToScan.remove(RECYCLE_BIN) 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 d6086baaf..9adc2cbb7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -18,10 +18,7 @@ import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.emptyTheRecycleBin import com.simplemobiletools.gallery.extensions.galleryDB import com.simplemobiletools.gallery.extensions.showRecycleBinEmptyingDialog -import com.simplemobiletools.gallery.helpers.DEFAULT_BOTTOM_ACTIONS -import com.simplemobiletools.gallery.helpers.ROTATE_BY_ASPECT_RATIO -import com.simplemobiletools.gallery.helpers.ROTATE_BY_DEVICE_ROTATION -import com.simplemobiletools.gallery.helpers.ROTATE_BY_SYSTEM_SETTING +import com.simplemobiletools.gallery.helpers.* import kotlinx.android.synthetic.main.activity_settings.* import java.util.* @@ -77,6 +74,7 @@ class SettingsActivity : SimpleActivity() { setupManageBottomActions() setupUseRecycleBin() setupShowRecycleBin() + setupShowRecycleBinLast() setupEmptyRecycleBin() updateTextColors(settings_holder) setupSectionColors() @@ -459,11 +457,14 @@ class SettingsActivity : SimpleActivity() { private fun setupUseRecycleBin() { settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin) settings_show_recycle_bin_holder.beVisibleIf(config.useRecycleBin) + settings_show_recycle_bin_last_holder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders) settings_use_recycle_bin.isChecked = config.useRecycleBin settings_use_recycle_bin_holder.setOnClickListener { settings_use_recycle_bin.toggle() config.useRecycleBin = settings_use_recycle_bin.isChecked settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin) + settings_show_recycle_bin_holder.beVisibleIf(config.useRecycleBin) + settings_show_recycle_bin_last_holder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders) } } @@ -472,6 +473,18 @@ class SettingsActivity : SimpleActivity() { settings_show_recycle_bin_holder.setOnClickListener { settings_show_recycle_bin.toggle() config.showRecycleBinAtFolders = settings_show_recycle_bin.isChecked + settings_show_recycle_bin_last_holder.beVisibleIf(config.useRecycleBin && config.showRecycleBinAtFolders) + } + } + + private fun setupShowRecycleBinLast() { + settings_show_recycle_bin_last.isChecked = config.showRecycleBinLast + settings_show_recycle_bin_last_holder.setOnClickListener { + settings_show_recycle_bin_last.toggle() + config.showRecycleBinLast = settings_show_recycle_bin_last.isChecked + if (config.showRecycleBinLast) { + config.removePinnedFolders(setOf(RECYCLE_BIN)) + } } } 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 45808d5a0..a00548a84 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt @@ -123,6 +123,14 @@ fun Context.movePinnedDirectoriesToFront(dirs: ArrayList): ArrayList< dirs.add(0, newFolder) } } + + if (config.useRecycleBin && config.showRecycleBinAtFolders && config.showRecycleBinLast) { + val binIndex = dirs.indexOfFirst { it.isRecycleBin() } + if (binIndex != -1) { + val bin = dirs.removeAt(binIndex) + dirs.add(bin) + } + } return dirs } @@ -334,7 +342,7 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: ArrayList() } - if (!config.showRecycleBinAtFolders) { + if (!config.showRecycleBinAtFolders || !config.useRecycleBin) { directories.removeAll { it.isRecycleBin() } } 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 11474c421..7333a1dd6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -89,6 +89,9 @@ class Config(context: Context) : BaseConfig(context) { val currPinnedFolders = HashSet(pinnedFolders) currPinnedFolders.addAll(paths) pinnedFolders = currPinnedFolders + if (paths.contains(RECYCLE_BIN)) { + showRecycleBinLast = false + } } fun removePinnedFolders(paths: Set) { @@ -392,4 +395,8 @@ class Config(context: Context) : BaseConfig(context) { var showHighestQuality: Boolean get() = prefs.getBoolean(SHOW_HIGHEST_QUALITY, false) set(showHighestQuality) = prefs.edit().putBoolean(SHOW_HIGHEST_QUALITY, showHighestQuality).apply() + + var showRecycleBinLast: Boolean + get() = prefs.getBoolean(SHOW_RECYCLE_BIN_LAST, false) + set(showRecycleBinLast) = prefs.edit().putBoolean(SHOW_RECYCLE_BIN_LAST, showRecycleBinLast).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 0db9f3129..8c0c7b15d 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 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" +const val SHOW_RECYCLE_BIN_LAST = "show_recycle_bin_last" const val ALLOW_ZOOMING_IMAGES = "allow_zooming_images" const val WAS_SVG_SHOWING_HANDLED = "was_svg_showing_handled" const val LAST_BIN_CHECK = "last_bin_check" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 41400e1cd..b631f301e 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -1141,6 +1141,30 @@ + + + + + +