diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index dc37d0e49..06d14443c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -279,15 +279,16 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList() + val showHidden = activity.config.shouldShowHidden selectedPositions.forEach { - val childrenPaths = ArrayList() val path = dirs[it].path if (path.startsWith(OTG_PATH)) { - paths.addAll(getOTGFilePaths(path)) + paths.addAll(getOTGFilePaths(path, showHidden)) } else { - File(path).list()?.filter { !activity.getIsPathDirectory(it) && it.isImageVideoGif() }?.mapTo(childrenPaths, { it }) + File(path).listFiles()?.filter { + !activity.getIsPathDirectory(it.absolutePath) && it.isImageVideoGif() && (showHidden || !it.name.startsWith('.')) + }?.mapTo(paths, { it.absolutePath }) } - paths.addAll(childrenPaths) } val fileDirItems = paths.map { FileDirItem(it, it.getFilenameFromPath()) } as ArrayList @@ -298,10 +299,10 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList { + private fun getOTGFilePaths(path: String, showHidden: Boolean): ArrayList { val paths = ArrayList() activity.getOTGFolderChildren(path)?.forEach { - if (!it.isDirectory && it.name.isImageVideoGif()) { + if (!it.isDirectory && it.name.isImageVideoGif() && (showHidden || !it.name.startsWith('.'))) { val relativePath = it.uri.path.substringAfterLast("${activity.config.OTGPartition}:") paths.add("$OTG_PATH$relativePath") }