Skip to content

Commit 5b278f6

Browse files
authored
fix: filter out files from hidden folders in recents (#279)
* fix catch files in hidden folders in recent tab Signed-off-by: Jan Guegel <[email protected]> * adjust changelog Signed-off-by: Jan Guegel <[email protected]> * include getDoesFilePathExist check, just to be sure Signed-off-by: Jan Guegel <[email protected]> * apply Code Review suggestions --------- Signed-off-by: Jan Guegel <[email protected]> Co-authored-by: Jan Guegel <[email protected]> Refs: #217
1 parent fec28af commit 5b278f6

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
- Fixed error when saving files with unsupported characters ([#250])
1111
- Fixed missing permission prompt on initial "Save as" launch ([#85])
1212
- Fixed printing text files containing a "#" ([#104])
13+
- Fixed files in hidden folders showing up in recent tab ([#217])
1314

1415
### Added
1516
- 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
8990
[#95]: https://github.com/FossifyOrg/File-Manager/issues/95
9091
[#104]: https://github.com/FossifyOrg/File-Manager/issues/104
9192
[#224]: https://github.com/FossifyOrg/File-Manager/issues/224
93+
[#217]: https://github.com/FossifyOrg/File-Manager/issues/217
9294

9395
[Unreleased]: https://github.com/FossifyOrg/File-Manager/compare/1.2.3...HEAD
9496
[1.2.3]: https://github.com/FossifyOrg/File-Manager/compare/1.2.2...1.2.3

app/src/main/kotlin/org/fossify/filemanager/fragments/RecentsFragment.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,11 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
179179
val name = cursor.getStringValue(FileColumns.DISPLAY_NAME) ?: path.getFilenameFromPath()
180180
val size = cursor.getLongValue(FileColumns.SIZE)
181181
val modified = cursor.getLongValue(FileColumns.DATE_MODIFIED) * 1000
182-
val fileDirItem = ListItem(path, name, false, 0, size, modified, false, false)
183-
if ((showHidden || !name.startsWith(".")) && activity?.getDoesFilePathExist(path) == true) {
182+
val isHiddenFile = name.startsWith(".")
183+
val shouldShow = showHidden || (!isHiddenFile && !isPathInHiddenFolder(path))
184+
if (shouldShow && activity?.getDoesFilePathExist(path) == true) {
184185
if (wantedMimeTypes.any { isProperMimeType(it, path, false) }) {
186+
val fileDirItem = ListItem(path, name, false, 0, size, modified, false, false)
185187
listItems.add(fileDirItem)
186188
}
187189
}
@@ -197,6 +199,18 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
197199
}
198200
}
199201

202+
private fun isPathInHiddenFolder(path: String): Boolean {
203+
val parts = path.split("/")
204+
for (i in 1 until parts.size - 1) {
205+
val part = parts[i]
206+
val isHidden = part.startsWith(".") && part != "." && part != ".." && part.isNotEmpty()
207+
if (isHidden) {
208+
return true
209+
}
210+
}
211+
return false
212+
}
213+
200214
private fun getRecyclerAdapter() = binding.recentsList.adapter as? ItemsAdapter
201215

202216
override fun toggleFilenameVisibility() {

0 commit comments

Comments
 (0)