add a confirmation dialog before deleting from folders page and viewpager

This commit is contained in:
tibbi 2016-11-19 13:52:54 +01:00
parent 701a4c2641
commit 4b5063a1b0
2 changed files with 21 additions and 3 deletions

View File

@ -14,6 +14,7 @@ import android.view.View
import android.webkit.MimeTypeMap import android.webkit.MimeTypeMap
import android.widget.RelativeLayout import android.widget.RelativeLayout
import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask
import com.simplemobiletools.filepicker.dialogs.ConfirmationDialog
import com.simplemobiletools.filepicker.extensions.* import com.simplemobiletools.filepicker.extensions.*
import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog import com.simplemobiletools.fileproperties.dialogs.PropertiesDialog
import com.simplemobiletools.gallery.Constants import com.simplemobiletools.gallery.Constants
@ -145,7 +146,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
true true
} }
R.id.menu_delete -> { R.id.menu_delete -> {
notifyDeletion() askConfirmDelete()
true true
} }
R.id.menu_rename -> { R.id.menu_rename -> {
@ -257,6 +258,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
Utils.shareMedium(getCurrentMedium(), this) Utils.shareMedium(getCurrentMedium(), this)
} }
private fun askConfirmDelete() {
ConfirmationDialog(this, listener = object : ConfirmationDialog.OnConfirmedListener {
override fun onConfirmed() {
notifyDeletion()
}
})
}
private fun notifyDeletion() { private fun notifyDeletion() {
if (isShowingPermDialog(File(mPath))) if (isShowingPermDialog(File(mPath)))
return return

View File

@ -11,6 +11,7 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.signature.StringSignature import com.bumptech.glide.signature.StringSignature
import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask
import com.simplemobiletools.filepicker.dialogs.ConfirmationDialog
import com.simplemobiletools.filepicker.extensions.isAStorageRootFolder import com.simplemobiletools.filepicker.extensions.isAStorageRootFolder
import com.simplemobiletools.filepicker.extensions.scanPaths import com.simplemobiletools.filepicker.extensions.scanPaths
import com.simplemobiletools.filepicker.extensions.toast import com.simplemobiletools.filepicker.extensions.toast
@ -70,8 +71,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
true true
} }
R.id.cab_delete -> { R.id.cab_delete -> {
prepareForDeleting() askConfirmDelete()
mode.finish()
true true
} }
else -> false else -> false
@ -175,6 +175,15 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
}) })
} }
private fun askConfirmDelete() {
ConfirmationDialog(activity, listener = object : ConfirmationDialog.OnConfirmedListener {
override fun onConfirmed() {
actMode?.finish()
prepareForDeleting()
}
})
}
private fun prepareForDeleting() { private fun prepareForDeleting() {
val selections = multiSelector.selectedPositions val selections = multiSelector.selectedPositions
val paths = ArrayList<String>() val paths = ArrayList<String>()