fix: filter out files from hidden folders in recents (#279)

* fix catch files in hidden folders in recent tab

Signed-off-by: Jan Guegel <jan@guegel.eu>

* adjust changelog

Signed-off-by: Jan Guegel <jan@guegel.eu>

* include getDoesFilePathExist check, just to be sure

Signed-off-by: Jan Guegel <jan@guegel.eu>

* apply Code Review suggestions

---------

Signed-off-by: Jan Guegel <jan@guegel.eu>
Co-authored-by: Jan Guegel <jan@guegel.eu>

Refs: https://github.com/FossifyOrg/File-Manager/issues/217
This commit is contained in:
Jan
2025-09-30 11:28:54 +02:00
committed by GitHub
parent fec28af74f
commit 5b278f6e4a
2 changed files with 18 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed error when saving files with unsupported characters ([#250])
- Fixed missing permission prompt on initial "Save as" launch ([#85])
- Fixed printing text files containing a "#" ([#104])
- Fixed files in hidden folders showing up in recent tab ([#217])
### Added
- Added a separate "Save as" option in the text editor ([#224])
@@ -89,6 +90,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#95]: https://github.com/FossifyOrg/File-Manager/issues/95
[#104]: https://github.com/FossifyOrg/File-Manager/issues/104
[#224]: https://github.com/FossifyOrg/File-Manager/issues/224
[#217]: https://github.com/FossifyOrg/File-Manager/issues/217
[Unreleased]: https://github.com/FossifyOrg/File-Manager/compare/1.2.3...HEAD
[1.2.3]: https://github.com/FossifyOrg/File-Manager/compare/1.2.2...1.2.3

View File

@@ -179,9 +179,11 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
val name = cursor.getStringValue(FileColumns.DISPLAY_NAME) ?: path.getFilenameFromPath()
val size = cursor.getLongValue(FileColumns.SIZE)
val modified = cursor.getLongValue(FileColumns.DATE_MODIFIED) * 1000
val fileDirItem = ListItem(path, name, false, 0, size, modified, false, false)
if ((showHidden || !name.startsWith(".")) && activity?.getDoesFilePathExist(path) == true) {
val isHiddenFile = name.startsWith(".")
val shouldShow = showHidden || (!isHiddenFile && !isPathInHiddenFolder(path))
if (shouldShow && activity?.getDoesFilePathExist(path) == true) {
if (wantedMimeTypes.any { isProperMimeType(it, path, false) }) {
val fileDirItem = ListItem(path, name, false, 0, size, modified, false, false)
listItems.add(fileDirItem)
}
}
@@ -197,6 +199,18 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
}
}
private fun isPathInHiddenFolder(path: String): Boolean {
val parts = path.split("/")
for (i in 1 until parts.size - 1) {
val part = parts[i]
val isHidden = part.startsWith(".") && part != "." && part != ".." && part.isNotEmpty()
if (isHidden) {
return true
}
}
return false
}
private fun getRecyclerAdapter() = binding.recentsList.adapter as? ItemsAdapter
override fun toggleFilenameVisibility() {