From e57a8d60ebb9b5bb2ecc7a02fb91b1177a1742af Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 27 Jun 2018 19:45:47 +0200 Subject: [PATCH] adding a confirmation dialog at recycle bin emptying --- app/build.gradle | 2 +- .../gallery/activities/SettingsActivity.kt | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2ffaa0bb4..5cba5e444 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -47,7 +47,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:4.3.6' + implementation 'com.simplemobiletools:commons:4.3.7' implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0' implementation 'com.android.support:multidex:1.0.3' implementation 'it.sephiroth.android.exif:library:1.0.1' 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 e88b921d9..7eaf6c5d7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -24,6 +24,7 @@ import java.util.* class SettingsActivity : SimpleActivity() { lateinit var res: Resources + private var mRecycleBinContentSize = 0L override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -424,15 +425,22 @@ class SettingsActivity : SimpleActivity() { private fun setupEmptyRecycleBin() { Thread { - val size = galleryDB.MediumDao().getDeletedMedia().sumByLong { it.size } + mRecycleBinContentSize = galleryDB.MediumDao().getDeletedMedia().sumByLong { it.size } runOnUiThread { - settings_empty_recycle_bin_size.text = size.formatSize() + settings_empty_recycle_bin_size.text = mRecycleBinContentSize.formatSize() } }.start() settings_empty_recycle_bin_holder.setOnClickListener { - emptyTheRecycleBin() - settings_empty_recycle_bin_size.text = 0L.formatSize() + if (mRecycleBinContentSize == 0L) { + toast(R.string.recycle_bin_empty) + } else { + ConfirmationDialog(this, "", R.string.empty_recycle_bin_confirmation, R.string.yes, R.string.no) { + emptyTheRecycleBin() + mRecycleBinContentSize = 0L + settings_empty_recycle_bin_size.text = 0L.formatSize() + } + } } } }