From a03ee4943f94ff5ebce454370f45b4e9259044a3 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 18 May 2020 17:46:58 -0400 Subject: [PATCH] when grouping by tags, tags with different casing will be grouped together --- .../java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt | 3 ++- .../java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index aa606f8707..7940f86ab9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -25,6 +25,7 @@ import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet.Companion.STATE_EXCLUDE import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet.Companion.STATE_IGNORE import eu.kanade.tachiyomi.ui.library.filter.FilterBottomSheet.Companion.STATE_INCLUDE +import eu.kanade.tachiyomi.util.lang.capitalizeWords import eu.kanade.tachiyomi.util.lang.removeArticles import eu.kanade.tachiyomi.util.system.executeOnIO import kotlinx.coroutines.CoroutineScope @@ -536,7 +537,7 @@ class LibraryPresenter( listOf("Unknown") } else { manga.genre?.split(",")?.mapNotNull { - val tag = it.trim() + val tag = it.trim().capitalizeWords() if (tag.isBlank()) null else tag } ?: listOf("Unknown") } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt index 52a6713fff..ed901e2cd4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/lang/StringExtensions.kt @@ -35,6 +35,11 @@ fun String.truncateCenter(count: Int, replacement: String = "..."): String { return "${take(pieceLength)}$replacement${takeLast(pieceLength)}" } +fun String.capitalizeWords(): String { + val firstReplace = split(" ").joinToString(" ") { it.capitalize() } + return firstReplace.split("-").joinToString("-") { it.capitalize() } +} + /** * Case-insensitive natural comparator for strings. */