diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index c4bc687b5..46211993b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -395,6 +395,26 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { override fun deleteFolders(folders: ArrayList) { val fileDirItems = folders.map { FileDirItem(it.absolutePath, it.name, true) } as ArrayList + if (config.useRecycleBin) { + val pathsToDelete = ArrayList() + fileDirItems.filter { it.isDirectory }.forEach { + val files = File(it.path).listFiles() + files?.filter { it.absolutePath.isImageVideoGif() }?.mapTo(pathsToDelete) { it.absolutePath } + } + + movePathsInRecycleBin(pathsToDelete) { + if (it) { + deleteFilteredFolders(fileDirItems, folders) + } else { + toast(R.string.unknown_error_occurred) + } + } + } else { + deleteFilteredFolders(fileDirItems, folders) + } + } + + private fun deleteFilteredFolders(fileDirItems: ArrayList, folders: ArrayList) { deleteFolders(fileDirItems) { runOnUiThread { refreshItems()