From 16e5529375661505e693d4e8a93fd2d71d399659 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 29 Apr 2018 09:24:20 +0200 Subject: [PATCH 1/2] improve folder Distinction to avoid showing duplicate folders --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 2 +- .../com/simplemobiletools/gallery/extensions/Context.kt | 2 +- .../kotlin/com/simplemobiletools/gallery/extensions/String.kt | 4 ++++ .../com/simplemobiletools/gallery/helpers/MediaFetcher.kt | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 33c1ab8f8..76e45fc22 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -680,7 +680,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun showSortedDirs(dirs: ArrayList) { var sortedDirs = getSortedDirectories(dirs).clone() as ArrayList - sortedDirs = sortedDirs.distinctBy { it.path.toLowerCase() } as ArrayList + sortedDirs = sortedDirs.distinctBy { it.path.getDistinctPath() } as ArrayList runOnUiThread { (directories_grid.adapter as DirectoryAdapter).updateDirs(sortedDirs) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt index 8ef8e068c..c465a9c5e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt @@ -276,7 +276,7 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: } }) as ArrayList - callback(filteredDirectories.distinctBy { it.path.toLowerCase() } as ArrayList) + callback(filteredDirectories.distinctBy { it.path.getDistinctPath() } as ArrayList) removeInvalidDBDirectories(directories, directoryDao) }.start() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/String.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/String.kt index dd28e208b..a8f4a9f57 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/String.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/String.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.gallery.extensions import com.bumptech.glide.signature.ObjectKey +import com.simplemobiletools.commons.helpers.OTG_PATH import java.io.File fun String.getFileSignature(): ObjectKey { @@ -32,3 +33,6 @@ fun String.shouldFolderBeVisible(excludedPaths: MutableSet, includedPath true } } + +// recognize /sdcard/DCIM as the same folder as /storage/emulated/0/DCIM +fun String.getDistinctPath() = if (startsWith(OTG_PATH)) toLowerCase() else File(this).canonicalPath.toLowerCase() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index 41d876701..3b04c9598 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -9,6 +9,7 @@ import com.simplemobiletools.commons.helpers.OTG_PATH import com.simplemobiletools.commons.helpers.photoExtensions import com.simplemobiletools.commons.helpers.videoExtensions import com.simplemobiletools.gallery.extensions.config +import com.simplemobiletools.gallery.extensions.getDistinctPath import com.simplemobiletools.gallery.extensions.getOTGFolderChildren import com.simplemobiletools.gallery.extensions.shouldFolderBeVisible import com.simplemobiletools.gallery.models.Medium @@ -139,7 +140,7 @@ class MediaFetcher(val context: Context) { foldersToScan.add(curPath) } - return foldersToScan.distinctBy { it.toLowerCase() } as ArrayList + return foldersToScan.distinctBy { it.getDistinctPath() } as ArrayList } private fun addFolder(curFolders: ArrayList, folder: String) { From 9d24a69596196bf140ff8638e617c9933429737d Mon Sep 17 00:00:00 2001 From: 10cents Date: Sun, 29 Apr 2018 23:40:27 +0200 Subject: [PATCH 2/2] Corrections & new strings --- app/src/main/res/values-da/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 3e07fbbae..5281e91a3 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -9,7 +9,7 @@ Pin folder Unpin folder Pin to the top - Vis indholdet af alle mappert + Vis indholdet af alle mapper Alle mapper Skift til mappevisning Anden mappe @@ -102,7 +102,7 @@ Tilfældig rækkefølge Use fade animations Kør baglæns - Loop slideshow + Endeløs kørsel Slideshowet endte Der blev ikke funket nogen mediefiler til slideshowet @@ -134,14 +134,14 @@ Manage extended details Tillad zoom med en finger når medier er i fuldskærm Tillad skift af medie ved klik på skærmens sider - RErstat stærkt zoombare billeder med nogle i bedre kvalitet + Erstat stærkt zoombare billeder med nogle i bedre kvalitet Skjul udvidede oplysninger når statuslinjen er skjult Tjek en ekstra gang for at undgå visning af ugyldige filer Thumbnails Fullscreen media - Extended details + Flere oplysninger How can I make Simple Gallery the default device gallery?