Check parent folders too when displaying unhide warning

This commit is contained in:
Ensar Sarajčić 2023-07-25 10:44:57 +02:00
parent b9f762e1e4
commit 669a0b5a96
2 changed files with 16 additions and 1 deletions

View file

@ -305,7 +305,7 @@ class DirectoryAdapter(
} }
} }
} else { } else {
if (selectedPaths.any { File(it).isHidden }) { if (selectedPaths.any { it.isThisOrParentFolderHidden() }) {
ConfirmationDialog(activity, "", R.string.cant_unhide_folder, R.string.ok, 0) {} ConfirmationDialog(activity, "", R.string.cant_unhide_folder, R.string.ok, 0) {}
return return
} }

View file

@ -91,3 +91,18 @@ fun String.getDistinctPath(): String {
} }
fun String.isDownloadsFolder() = equals(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString(), true) 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
}