show how many items are going to be deleted on the confirmation dialog

This commit is contained in:
tibbi 2018-04-12 20:19:21 +02:00
parent e67517dd4c
commit ce3ce0bec0
5 changed files with 10 additions and 5 deletions

View File

@ -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'

View File

@ -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()
}

View File

@ -301,7 +301,9 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
if (config.skipDeleteConfirmation) {
deleteFiles()
} else {
ConfirmationDialog(activity) {
val items = resources.getQuantityString(R.plurals.delete_items, selectedPositions.size, selectedPositions.size)
val question = String.format(resources.getString(R.string.deletion_confirmation), items)
ConfirmationDialog(activity, question) {
deleteFiles()
}
}

View File

@ -204,7 +204,9 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
}
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()
}

View File

@ -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)