diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 9dd69ccaa..83410e998 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -305,7 +305,7 @@ class DirectoryAdapter( } } } else { - if (selectedPaths.any { File(it).isHidden }) { + if (selectedPaths.any { it.isThisOrParentFolderHidden() }) { ConfirmationDialog(activity, "", R.string.cant_unhide_folder, R.string.ok, 0) {} return } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/String.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/String.kt index 569b383e5..dee1aef64 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/String.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/String.kt @@ -91,3 +91,18 @@ fun String.getDistinctPath(): String { } fun String.isDownloadsFolder() = equals(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString(), true) + +fun String.isThisOrParentFolderHidden(): Boolean { + var curFile = File(this) + while (true) { + if (curFile.isHidden) { + return true + } + + curFile = curFile.parentFile ?: break + if (curFile.absolutePath == "/") { + break + } + } + return false +}