Merge pull request #2471 from DoozyDoz/feat_size_at_deletion
[feat] Display item(s) size in delete dialog
This commit is contained in:
commit
32a20df49b
2 changed files with 19 additions and 5 deletions
|
@ -1104,7 +1104,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
val fileDirItem = File(getCurrentPath()).toFileDirItem(this)
|
||||
val size = fileDirItem.getProperSize(this, countHidden = true).formatSize()
|
||||
val filename = "\"${getCurrentPath().getFilenameFromPath()}\""
|
||||
val filenameAndSize = "$filename ($size)"
|
||||
|
||||
val baseString = if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) {
|
||||
R.string.move_to_recycle_bin_confirmation
|
||||
|
@ -1112,7 +1115,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
R.string.deletion_confirmation
|
||||
}
|
||||
|
||||
val message = String.format(resources.getString(baseString), filename)
|
||||
val message = String.format(resources.getString(baseString), filenameAndSize)
|
||||
DeleteWithRememberDialog(this, message) {
|
||||
config.tempSkipDeleteConfirmation = it
|
||||
deleteConfirmed()
|
||||
|
|
|
@ -38,6 +38,7 @@ import kotlinx.android.synthetic.main.video_item_grid.view.media_item_holder
|
|||
import kotlinx.android.synthetic.main.video_item_grid.view.medium_check
|
||||
import kotlinx.android.synthetic.main.video_item_grid.view.medium_name
|
||||
import kotlinx.android.synthetic.main.video_item_grid.view.medium_thumbnail
|
||||
import java.io.File
|
||||
|
||||
class MediaAdapter(
|
||||
activity: BaseSimpleActivity, var media: ArrayList<ThumbnailItem>, val listener: MediaOperationsListener?, val isAGetIntent: Boolean,
|
||||
|
@ -462,15 +463,25 @@ class MediaAdapter(
|
|||
private fun askConfirmDelete() {
|
||||
val itemsCnt = selectedKeys.size
|
||||
val firstPath = getSelectedPaths().first()
|
||||
val items = if (itemsCnt == 1) {
|
||||
"\"${firstPath.getFilenameFromPath()}\""
|
||||
val fileDirItem = File(firstPath).toFileDirItem(activity)
|
||||
val size = fileDirItem.getProperSize(activity, countHidden = true).formatSize()
|
||||
val itemsAndSize = if (itemsCnt == 1) {
|
||||
"\"${firstPath.getFilenameFromPath()}\" ($size)"
|
||||
} else {
|
||||
resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)
|
||||
val paths = getSelectedPaths()
|
||||
val fileDirItems = ArrayList<FileDirItem>(paths.size)
|
||||
paths.forEach {
|
||||
val fileDirItem = File(it).toFileDirItem(activity)
|
||||
fileDirItems.add(fileDirItem)
|
||||
}
|
||||
val size = fileDirItems.sumByLong { it.getProperSize(activity, countHidden = true) }.formatSize()
|
||||
val deleteItemsString = resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)
|
||||
"$deleteItemsString ($size)"
|
||||
}
|
||||
|
||||
val isRecycleBin = firstPath.startsWith(activity.recycleBinPath)
|
||||
val baseString = if (config.useRecycleBin && !isRecycleBin) R.string.move_to_recycle_bin_confirmation else R.string.deletion_confirmation
|
||||
val question = String.format(resources.getString(baseString), items)
|
||||
val question = String.format(resources.getString(baseString), itemsAndSize)
|
||||
DeleteWithRememberDialog(activity, question) {
|
||||
config.tempSkipDeleteConfirmation = it
|
||||
deleteFiles()
|
||||
|
|
Loading…
Reference in a new issue