[feat] Display item(s) size in delete dialog
This commit is contained in:
parent
87c106a950
commit
a368db9b87
|
@ -1104,7 +1104,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
}
|
||||
|
||||
private fun askConfirmDelete() {
|
||||
val filename = "\"${getCurrentPath().getFilenameFromPath()}\""
|
||||
val path = getCurrentPath()
|
||||
val fileDirItem = FileDirItem(path, path.getFilenameFromPath(), getIsPathDirectory(path))
|
||||
val size = fileDirItem.getProperSize(this, countHidden = true).formatSize()
|
||||
val filename = "\"${path.getFilenameFromPath()}\""
|
||||
val filenameAndSize = "$filename ($size)"
|
||||
|
||||
val baseString = if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) {
|
||||
R.string.move_to_recycle_bin_confirmation
|
||||
|
@ -1112,7 +1116,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()
|
||||
|
|
|
@ -593,11 +593,21 @@ class DirectoryAdapter(
|
|||
return
|
||||
}
|
||||
|
||||
val items = if (itemsCnt == 1) {
|
||||
val itemsAndSize = if (itemsCnt == 1) {
|
||||
val path = getSelectedPaths().first()
|
||||
val fileDirItem = FileDirItem(path, path.getFilenameFromPath(), activity.getIsPathDirectory(path))
|
||||
val size = fileDirItem.getProperSize(activity, countHidden = true).formatSize()
|
||||
val folder = getSelectedPaths().first().getFilenameFromPath()
|
||||
"\"$folder\""
|
||||
"\"$folder\" ($size)"
|
||||
} else {
|
||||
resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)
|
||||
val paths = getSelectedPaths()
|
||||
val fileDirItems = ArrayList<FileDirItem>(paths.size)
|
||||
paths.forEach {
|
||||
val fileDirItem = FileDirItem(it, it.getFilenameFromPath(), activity.getIsPathDirectory(it))
|
||||
fileDirItems.add(fileDirItem)
|
||||
}
|
||||
val size = fileDirItems.sumByLong { it.getProperSize(activity, countHidden = true) }.formatSize()
|
||||
"${resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)} ($size)"
|
||||
}
|
||||
|
||||
val fileDirItem = getFirstSelectedItem() ?: return
|
||||
|
@ -607,7 +617,7 @@ class DirectoryAdapter(
|
|||
R.string.move_to_recycle_bin_confirmation
|
||||
}
|
||||
|
||||
val question = String.format(resources.getString(baseString), items)
|
||||
val question = String.format(resources.getString(baseString), itemsAndSize)
|
||||
val warning = resources.getQuantityString(R.plurals.delete_warning, itemsCnt, itemsCnt)
|
||||
ConfirmDeleteFolderDialog(activity, question, warning) {
|
||||
deleteFolders()
|
||||
|
|
|
@ -462,15 +462,24 @@ class MediaAdapter(
|
|||
private fun askConfirmDelete() {
|
||||
val itemsCnt = selectedKeys.size
|
||||
val firstPath = getSelectedPaths().first()
|
||||
val items = if (itemsCnt == 1) {
|
||||
"\"${firstPath.getFilenameFromPath()}\""
|
||||
val fileDirItem = FileDirItem(firstPath, firstPath.getFilenameFromPath(), activity.getIsPathDirectory(firstPath))
|
||||
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 = java.util.ArrayList<FileDirItem>(paths.size)
|
||||
paths.forEach {
|
||||
val fileDirItem = FileDirItem(it, it.getFilenameFromPath(), activity.getIsPathDirectory(it))
|
||||
fileDirItems.add(fileDirItem)
|
||||
}
|
||||
val size = fileDirItems.sumByLong { it.getProperSize(activity, countHidden = true) }.formatSize()
|
||||
"${resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)} ($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 New Issue