From d8a33f81d7a9655285bf7c60ae80144b0e47af13 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 26 Jun 2018 22:37:49 +0200 Subject: [PATCH] add a settings toggle for toggling recycle bin usage --- .../gallery/activities/SettingsActivity.kt | 11 ++++- .../gallery/helpers/Config.kt | 4 ++ .../gallery/helpers/Constants.kt | 1 + app/src/main/res/layout/activity_settings.xml | 41 +++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) 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 197d2071a..2fdf38049 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -70,12 +70,13 @@ class SettingsActivity : SimpleActivity() { setupSkipDeleteConfirmation() updateTextColors(settings_holder) setupSectionColors() + setupUseRecycleBin() } private fun setupSectionColors() { val adjustedPrimaryColor = getAdjustedPrimaryColor() arrayListOf(visibility_label, videos_label, thumbnails_label, scrolling_label, fullscreen_media_label, security_label, - file_operations_label, extended_details_label).forEach { + file_operations_label, extended_details_label, recycle_bin_label).forEach { it.setTextColor(adjustedPrimaryColor) } } @@ -409,4 +410,12 @@ class SettingsActivity : SimpleActivity() { ROTATE_BY_DEVICE_ROTATION -> R.string.screen_rotation_device_rotation else -> R.string.screen_rotation_aspect_ratio }) + + private fun setupUseRecycleBin() { + 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 + } + } } 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 2af6c7bd7..2a1fd92f5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -356,4 +356,8 @@ class Config(context: Context) : BaseConfig(context) { var groupBy: Int get() = prefs.getInt(GROUP_BY, GROUP_BY_NONE) set(groupBy) = prefs.edit().putInt(GROUP_BY, groupBy).apply() + + var useRecycleBin: Boolean + get() = prefs.getBoolean(USE_RECYCLE_BIN, true) + set(useRecycleBin) = prefs.edit().putBoolean(USE_RECYCLE_BIN, useRecycleBin).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 97773caca..68a5df3de 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -52,6 +52,7 @@ const val TEMP_SKIP_DELETE_CONFIRMATION = "temp_skip_delete_confirmation" const val BOTTOM_ACTIONS = "bottom_actions" const val WERE_FAVORITES_PINNED = "were_favorites_pinned" const val WAS_RECYCLE_BIN_PINNED = "was_recycle_bin_pinned" +const val USE_RECYCLE_BIN = "use_recycle_bin" const val GROUP_BY = "group_by" // slideshow diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 94cc6ea57..7717c996d 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -941,5 +941,46 @@ android:text="@string/skip_delete_confirmation"/> + + + + + + + + + +