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 5ef151d91..412dd9c6b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -202,7 +202,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { val document = getFileDocument(file.absolutePath, mConfig.treeUri) // double check we have the uri to the proper file path, not some parent folder - if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath())) + if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory) document.delete() } } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 2c6437264..ed5b65e7f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -219,7 +219,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { val document = getFileDocument(file.absolutePath, mConfig.treeUri) // double check we have the uri to the proper file path, not some parent folder - if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath())) { + if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory) { if (document.delete()) { wereFilesDeleted = true } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index fda440ae3..dda08bee0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -287,9 +287,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View if (needsStupidWritePermissions(mToBeDeleted)) { if (!isShowingPermDialog(file)) { val document = getFileDocument(mToBeDeleted, mConfig.treeUri) - if (document.canWrite()) { + if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory) mWasFileDeleted = document.delete() - } } } else { mWasFileDeleted = file.delete()