From d83df54a41afed0eeec4b19cf6dd064371795c7d Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 26 Apr 2018 15:11:28 +0200 Subject: [PATCH] copy hidden files only when they are visible --- .../gallery/adapters/DirectoryAdapter.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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") }