From ce3ce0bec00835441423dc32b43a2874d1189547 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 12 Apr 2018 20:19:21 +0200 Subject: [PATCH] show how many items are going to be deleted on the confirmation dialog --- app/build.gradle | 2 +- .../simplemobiletools/gallery/activities/ViewPagerActivity.kt | 2 +- .../simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 4 +++- .../com/simplemobiletools/gallery/adapters/MediaAdapter.kt | 4 +++- .../gallery/dialogs/DeleteWithRememberDialog.kt | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 65587b934..d81faa2f8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -46,7 +46,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.18.17' + implementation 'com.simplemobiletools:commons:3.18.21' implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.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/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index c6ffb4ab0..ab5e68d4a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -728,7 +728,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun askConfirmDelete() { - DeleteWithRememberDialog(this) { + DeleteWithRememberDialog(this, getString(R.string.proceed_with_deletion)) { mSkipConfirmationDialog = it deleteConfirmed() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index f7a67256a..f290cdc87 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -301,7 +301,9 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList, } private fun askConfirmDelete() { - DeleteWithRememberDialog(activity) { + val items = resources.getQuantityString(R.plurals.delete_items, selectedPositions.size, selectedPositions.size) + val question = String.format(resources.getString(R.string.deletion_confirmation), items) + DeleteWithRememberDialog(activity, question) { skipConfirmationDialog = it deleteFiles() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt index b506b894f..1948339c3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt @@ -6,11 +6,12 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.gallery.R import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.* -class DeleteWithRememberDialog(val activity: Activity, val callback: (remember: Boolean) -> Unit) { +class DeleteWithRememberDialog(val activity: Activity, val message: String, val callback: (remember: Boolean) -> Unit) { private var dialog: AlertDialog val view = activity.layoutInflater.inflate(R.layout.dialog_delete_with_remember, null)!! init { + view.delete_remember_title.text = message val builder = AlertDialog.Builder(activity) .setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed() }) .setNegativeButton(R.string.no, null)