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 2fdf38049..b05be05b9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -16,6 +16,7 @@ import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.dialogs.ManageExtendedDetailsDialog import com.simplemobiletools.gallery.extensions.config +import com.simplemobiletools.gallery.extensions.emptyTheRecycleBin 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 @@ -71,6 +72,7 @@ class SettingsActivity : SimpleActivity() { updateTextColors(settings_holder) setupSectionColors() setupUseRecycleBin() + setupEmptyRecycleBin() } private fun setupSectionColors() { @@ -412,10 +414,18 @@ class SettingsActivity : SimpleActivity() { }) private fun setupUseRecycleBin() { + settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin) 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) + } + } + + private fun setupEmptyRecycleBin() { + settings_empty_recycle_bin_holder.setOnClickListener { + emptyTheRecycleBin() } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt index a6d92712a..4d4938fb6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Activity.kt @@ -205,13 +205,13 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList, callback: }.start() } -fun BaseSimpleActivity.emptyTheRecycleBin(callback: () -> Unit) { +fun BaseSimpleActivity.emptyTheRecycleBin(callback: (() -> Unit)? = null) { Thread { filesDir.deleteRecursively() galleryDB.MediumDao().clearRecycleBin() galleryDB.DirectoryDao().deleteRecycleBin() toast(R.string.recycle_bin_emptied) - callback() + callback?.invoke() }.start() } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 883731009..04c410cd5 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -982,5 +982,27 @@ android:text="@string/move_items_into_recycle_bin"/> + + + + + +