From ef54c61876a1139ddb7e1ba1757289e3c30e6ed5 Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 17 Nov 2019 00:15:46 -0800 Subject: [PATCH] New chapters notification now always says "mark as read" Sorting manga now ignores articles such as "a" "an" and "the" --- .../kanade/tachiyomi/data/library/LibraryUpdateService.kt | 4 +--- .../java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt | 6 +++++- app/src/main/res/values/strings.xml | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index f1036e30df..67a77078e5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -479,9 +479,7 @@ class LibraryUpdateService( this@LibraryUpdateService, manga, chapters.first() ) ) - addAction(R.drawable.ic_glasses_black_24dp, getString( - if (chapters.size > 1) R.string.action_mark_all_as_read else R.string - .action_mark_as_read), + addAction(R.drawable.ic_glasses_black_24dp, getString(R.string.action_mark_as_read), NotificationReceiver.markAsReadPendingBroadcast(this@LibraryUpdateService, manga, chapters, Notifications.GROUP_NEW_CHAPTERS)) addAction(R.drawable.ic_book_white_24dp, getString(R.string.action_view_chapters), 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 d990191968..c68c9d9430 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 @@ -190,7 +190,7 @@ class LibraryPresenter( val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 -> when (sortingMode) { - LibrarySort.ALPHA -> i1.manga.title.compareTo(i2.manga.title, true) + LibrarySort.ALPHA -> i1.manga.title.removeArticles().compareTo(i2.manga.title.removeArticles(), true) LibrarySort.LAST_READ -> { // Get index of manga, set equal to list if size unknown. val manga1LastRead = lastReadManga[i1.manga.id!!] ?: lastReadManga.size @@ -221,6 +221,10 @@ class LibraryPresenter( return map.mapValues { entry -> entry.value.sortedWith(comparator) } } + fun String.removeArticles(): String { + return this.replace(Regex("^(an|a|the) ", RegexOption.IGNORE_CASE), "") + } + /** * Get the categories and all its manga from the database. * diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4b04f2e2a9..cd9c659b00 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -45,7 +45,6 @@ Global search Select all Mark as read - Mark all as read Mark as unread Mark previous as read Download