From c801a8c7d1292daf0ccf5ca42a904d3399264319 Mon Sep 17 00:00:00 2001 From: Cuong-Tran Date: Thu, 7 Nov 2024 14:48:32 +0700 Subject: [PATCH] support comma (,) delimiter when searching library --- .../tachiyomi/ui/library/LibraryItem.kt | 75 +++++++++---------- app/src/main/java/exh/search/SearchEngine.kt | 2 +- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt index 9bf9a85b2..6ba49a43a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt @@ -1,6 +1,5 @@ package eu.kanade.tachiyomi.ui.library -import eu.kanade.tachiyomi.source.getNameForMangaInfo import tachiyomi.domain.library.model.LibraryManga import tachiyomi.domain.source.model.Source import tachiyomi.domain.source.service.SourceManager @@ -19,42 +18,42 @@ data class LibraryItem( // KMK <-- private val sourceManager: SourceManager = Injekt.get(), ) { - /** - * Checks if a query matches the manga - * - * @param constraint the query to check. - * @return true if the manga matches the query, false otherwise. - */ - fun matches(constraint: String): Boolean { - val sourceName by lazy { sourceManager.getOrStub(libraryManga.manga.source).getNameForMangaInfo() } - return libraryManga.manga.title.contains(constraint, true) || - (libraryManga.manga.author?.contains(constraint, true) ?: false) || - (libraryManga.manga.artist?.contains(constraint, true) ?: false) || - (libraryManga.manga.description?.contains(constraint, true) ?: false) || - constraint.split(",").map { it.trim() }.all { subconstraint -> - checkNegatableConstraint(subconstraint) { - sourceName.contains(it, true) || - (libraryManga.manga.genre?.any { genre -> genre.equals(it, true) } ?: false) - } - } - } + // /** + // * Checks if a query matches the manga + // * + // * @param constraint the query to check. + // * @return true if the manga matches the query, false otherwise. + // */ + // fun matches(constraint: String): Boolean { + // val sourceName by lazy { sourceManager.getOrStub(libraryManga.manga.source).getNameForMangaInfo() } + // return libraryManga.manga.title.contains(constraint, true) || + // (libraryManga.manga.author?.contains(constraint, true) ?: false) || + // (libraryManga.manga.artist?.contains(constraint, true) ?: false) || + // (libraryManga.manga.description?.contains(constraint, true) ?: false) || + // constraint.split(",").map { it.trim() }.all { subconstraint -> + // checkNegatableConstraint(subconstraint) { + // sourceName.contains(it, true) || + // (libraryManga.manga.genre?.any { genre -> genre.equals(it, true) } ?: false) + // } + // } + // } - /** - * Checks a predicate on a negatable constraint. If the constraint starts with a minus character, - * the minus is stripped and the result of the predicate is inverted. - * - * @param constraint the argument to the predicate. Inverts the predicate if it starts with '-'. - * @param predicate the check to be run against the constraint. - * @return !predicate(x) if constraint = "-x", otherwise predicate(constraint) - */ - private fun checkNegatableConstraint( - constraint: String, - predicate: (String) -> Boolean, - ): Boolean { - return if (constraint.startsWith("-")) { - !predicate(constraint.substringAfter("-").trimStart()) - } else { - predicate(constraint) - } - } + // /** + // * Checks a predicate on a negatable constraint. If the constraint starts with a minus character, + // * the minus is stripped and the result of the predicate is inverted. + // * + // * @param constraint the argument to the predicate. Inverts the predicate if it starts with '-'. + // * @param predicate the check to be run against the constraint. + // * @return !predicate(x) if constraint = "-x", otherwise predicate(constraint) + // */ + // private fun checkNegatableConstraint( + // constraint: String, + // predicate: (String) -> Boolean, + // ): Boolean { + // return if (constraint.startsWith("-")) { + // !predicate(constraint.substringAfter("-").trimStart()) + // } else { + // predicate(constraint) + // } + // } } diff --git a/app/src/main/java/exh/search/SearchEngine.kt b/app/src/main/java/exh/search/SearchEngine.kt index 1f4a36a62..9fba17bd4 100644 --- a/app/src/main/java/exh/search/SearchEngine.kt +++ b/app/src/main/java/exh/search/SearchEngine.kt @@ -191,7 +191,7 @@ class SearchEngine { else -> flushed } namespace = Namespace(flushed, null) - } else if (char == ' ' && !inQuotes) { + } else if (arrayOf(' ', ',').contains(char) && !inQuotes) { flushAll() } else { queuedRawText.append(char)