Merge branch 'ref/delete-animation' of https://github.com/KryptKode/Simple-Gallery

This commit is contained in:
tibbi 2022-02-25 23:04:24 +01:00
commit 8cb4b9bc3b
3 changed files with 54 additions and 39 deletions

View file

@ -626,6 +626,11 @@ class DirectoryAdapter(
return@handleSAFDialog
}
activity.handleSAFDeleteSdk30Dialog(SAFPath){
if (!it) {
return@handleSAFDeleteSdk30Dialog
}
var foldersToDelete = ArrayList<File>(selectedKeys.size)
selectedDirs.forEach {
if (it.areFavorites() || it.isRecycleBin()) {
@ -659,6 +664,7 @@ class DirectoryAdapter(
}
}
}
}
private fun tryChangeAlbumCover(useDefault: Boolean) {
activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") { success ->

View file

@ -459,17 +459,25 @@ class MediaAdapter(
return
}
val SAFPath = getSelectedPaths().firstOrNull { activity.needsStupidWritePermissions(it) } ?: getFirstSelectedItemPath() ?: return
val selectedItems = getSelectedItems()
val selectedPaths = selectedItems.map { it.path } as ArrayList<String>
val SAFPath = selectedPaths.firstOrNull { activity.needsStupidWritePermissions(it) } ?: getFirstSelectedItemPath() ?: return
activity.handleSAFDialog(SAFPath) {
if (!it) {
return@handleSAFDialog
}
val sdk30SafPath = selectedPaths.firstOrNull { activity.isAccessibleWithSAFSdk30(it) } ?: getFirstSelectedItemPath() ?: return@handleSAFDialog
activity.handleSAFDeleteSdk30Dialog(sdk30SafPath){
if (!it) {
return@handleSAFDeleteSdk30Dialog
}
val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
val removeMedia = ArrayList<Medium>(selectedKeys.size)
val positions = getSelectedItemPositions()
getSelectedItems().forEach {
selectedItems.forEach {
fileDirItems.add(FileDirItem(it.path, it.name))
removeMedia.add(it)
}
@ -481,6 +489,7 @@ class MediaAdapter(
currentMediaHash = media.hashCode()
}
}
}
private fun getSelectedItems() = selectedKeys.mapNotNull { getItemWithKey(it) } as ArrayList<Medium>

View file

@ -259,7 +259,7 @@ fun BaseSimpleActivity.tryDeleteFileDirItem(
fileDirItem: FileDirItem, allowDeleteFolder: Boolean = false, deleteFromDatabase: Boolean,
callback: ((wasSuccess: Boolean) -> Unit)? = null
) {
deleteFile(fileDirItem, allowDeleteFolder) {
deleteFile(fileDirItem, allowDeleteFolder, isDeletingMultipleFiles = false) {
if (deleteFromDatabase) {
ensureBackgroundThread {
deleteDBPath(fileDirItem.path)