From f137f3db067391f22be2cb0d900fc97deb663bc5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 26 Apr 2017 19:54:47 +0200 Subject: [PATCH] show hidden files only when should --- .../gallery/asynctasks/GetDirectoriesAsynctask.kt | 5 ++++- .../gallery/asynctasks/GetMediaAsynctask.kt | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index 29d39b91a..af61ac9bd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -18,6 +18,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val callback: (dirs: ArrayList) -> Unit) : AsyncTask>() { var config = context.config var shouldStop = false + val showHidden = config.shouldShowHidden override fun doInBackground(vararg params: Void): ArrayList { if (!context.hasWriteStoragePermission()) @@ -48,6 +49,9 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va if (isImage && (isPickVideo || showMedia == VIDEOS)) continue + if (!showHidden && filename.startsWith('.')) + continue + val file = File(it, filename) val size = file.length() if (size == 0L) @@ -74,7 +78,6 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va private fun groupDirectories(media: ArrayList): Map { val hidden = context.resources.getString(R.string.hidden) val directories = LinkedHashMap() - val showHidden = config.shouldShowHidden for ((name, path, isVideo, dateModified, dateTaken, size) in media) { if (shouldStop) cancel(true) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt index 0eb31c6c6..d03628bea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt @@ -22,6 +22,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo var fileSorting = 0 var shouldStop = false var media = ArrayList() + val showHidden = config.shouldShowHidden override fun onPreExecute() { super.onPreExecute() @@ -63,6 +64,9 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo if (isImage && (isPickVideo || showMedia == VIDEOS)) continue + if (!showHidden && filename.startsWith('.')) + continue + val file = File(path, filename) val size = file.length() if (size == 0L)