adding a confirmation dialog at recycle bin emptying

This commit is contained in:
tibbi 2018-06-27 19:45:47 +02:00
parent 2dacf695fe
commit e57a8d60eb
2 changed files with 13 additions and 5 deletions

View file

@ -47,7 +47,7 @@ ext {
} }
dependencies { 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.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'com.android.support:multidex:1.0.3' implementation 'com.android.support:multidex:1.0.3'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'

View file

@ -24,6 +24,7 @@ import java.util.*
class SettingsActivity : SimpleActivity() { class SettingsActivity : SimpleActivity() {
lateinit var res: Resources lateinit var res: Resources
private var mRecycleBinContentSize = 0L
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -424,15 +425,22 @@ class SettingsActivity : SimpleActivity() {
private fun setupEmptyRecycleBin() { private fun setupEmptyRecycleBin() {
Thread { Thread {
val size = galleryDB.MediumDao().getDeletedMedia().sumByLong { it.size } mRecycleBinContentSize = galleryDB.MediumDao().getDeletedMedia().sumByLong { it.size }
runOnUiThread { runOnUiThread {
settings_empty_recycle_bin_size.text = size.formatSize() settings_empty_recycle_bin_size.text = mRecycleBinContentSize.formatSize()
} }
}.start() }.start()
settings_empty_recycle_bin_holder.setOnClickListener { settings_empty_recycle_bin_holder.setOnClickListener {
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() emptyTheRecycleBin()
mRecycleBinContentSize = 0L
settings_empty_recycle_bin_size.text = 0L.formatSize() settings_empty_recycle_bin_size.text = 0L.formatSize()
} }
} }
}
}
} }