From 6d802063b49e26039c96aa58bc1f9a456f5aaeec Mon Sep 17 00:00:00 2001 From: FourTOne5 <59261191+FourTOne5@users.noreply.github.com> Date: Wed, 4 May 2022 04:39:04 +0600 Subject: [PATCH] Reword and Fix library sort (#7068) --- .../main/java/eu/kanade/tachiyomi/Migrations.kt | 6 +++--- .../tachiyomi/ui/library/LibraryPresenter.kt | 15 +++++++++------ .../tachiyomi/ui/library/LibrarySettingsSheet.kt | 16 ++++++++-------- .../ui/library/setting/SortModeSetting.kt | 6 +++--- app/src/main/res/values/strings.xml | 5 +++-- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index 21470392cf..0674fc2433 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -204,11 +204,11 @@ object Migrations { val newSortingMode = when (oldSortingMode) { LibrarySort.ALPHA -> SortModeSetting.ALPHABETICAL LibrarySort.LAST_READ -> SortModeSetting.LAST_READ - LibrarySort.LAST_CHECKED -> SortModeSetting.LAST_CHECKED - LibrarySort.UNREAD -> SortModeSetting.UNREAD + LibrarySort.LAST_CHECKED -> SortModeSetting.LAST_MANGA_UPDATE + LibrarySort.UNREAD -> SortModeSetting.UNREAD_COUNT LibrarySort.TOTAL -> SortModeSetting.TOTAL_CHAPTERS LibrarySort.LATEST_CHAPTER -> SortModeSetting.LATEST_CHAPTER - LibrarySort.CHAPTER_FETCH_DATE -> SortModeSetting.DATE_FETCHED + LibrarySort.CHAPTER_FETCH_DATE -> SortModeSetting.CHAPTER_FETCH_DATE LibrarySort.DATE_ADDED -> SortModeSetting.DATE_ADDED else -> SortModeSetting.ALPHABETICAL } 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 562c68dbbd..41acf21751 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 @@ -252,15 +252,18 @@ class LibraryPresenter( private fun applySort(categories: List, map: LibraryMap): LibraryMap { val lastReadManga by lazy { var counter = 0 - db.getLastReadManga().executeAsBlocking().associate { it.id!! to counter++ } + // Result comes as newest to oldest so it's reversed + db.getLastReadManga().executeAsBlocking().reversed().associate { it.id!! to counter++ } } val latestChapterManga by lazy { var counter = 0 - db.getLatestChapterManga().executeAsBlocking().associate { it.id!! to counter++ } + // Result comes as newest to oldest so it's reversed + db.getLatestChapterManga().executeAsBlocking().reversed().associate { it.id!! to counter++ } } val chapterFetchDateManga by lazy { var counter = 0 - db.getChapterFetchDateManga().executeAsBlocking().associate { it.id!! to counter++ } + // Result comes as newest to oldest so it's reversed + db.getChapterFetchDateManga().executeAsBlocking().reversed().associate { it.id!! to counter++ } } val sortingModes = categories.associate { category -> @@ -287,10 +290,10 @@ class LibraryPresenter( val manga2LastRead = lastReadManga[i2.manga.id!!] ?: 0 manga1LastRead.compareTo(manga2LastRead) } - SortModeSetting.LAST_CHECKED -> { + SortModeSetting.LAST_MANGA_UPDATE -> { i1.manga.last_update.compareTo(i2.manga.last_update) } - SortModeSetting.UNREAD -> when { + SortModeSetting.UNREAD_COUNT -> when { // Ensure unread content comes first i1.manga.unreadCount == i2.manga.unreadCount -> 0 i1.manga.unreadCount == 0 -> if (sortAscending) 1 else -1 @@ -307,7 +310,7 @@ class LibraryPresenter( ?: latestChapterManga.size manga1latestChapter.compareTo(manga2latestChapter) } - SortModeSetting.DATE_FETCHED -> { + SortModeSetting.CHAPTER_FETCH_DATE -> { val manga1chapterFetchDate = chapterFetchDateManga[i1.manga.id!!] ?: 0 val manga2chapterFetchDate = chapterFetchDateManga[i2.manga.id!!] ?: 0 manga1chapterFetchDate.compareTo(manga2chapterFetchDate) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt index 2991a9729d..bd9ed749b4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibrarySettingsSheet.kt @@ -182,8 +182,8 @@ class LibrarySettingsSheet( private val alphabetically = Item.MultiSort(R.string.action_sort_alpha, this) private val total = Item.MultiSort(R.string.action_sort_total, this) private val lastRead = Item.MultiSort(R.string.action_sort_last_read, this) - private val lastChecked = Item.MultiSort(R.string.action_sort_last_checked, this) - private val unread = Item.MultiSort(R.string.action_filter_unread, this) + private val lastChecked = Item.MultiSort(R.string.action_sort_last_manga_update, this) + private val unread = Item.MultiSort(R.string.action_sort_unread_count, this) private val latestChapter = Item.MultiSort(R.string.action_sort_latest_chapter, this) private val chapterFetchDate = Item.MultiSort(R.string.action_sort_chapter_fetch_date, this) private val dateAdded = Item.MultiSort(R.string.action_sort_date_added, this) @@ -206,15 +206,15 @@ class LibrarySettingsSheet( lastRead.state = if (sorting == SortModeSetting.LAST_READ) order else Item.MultiSort.SORT_NONE lastChecked.state = - if (sorting == SortModeSetting.LAST_CHECKED) order else Item.MultiSort.SORT_NONE + if (sorting == SortModeSetting.LAST_MANGA_UPDATE) order else Item.MultiSort.SORT_NONE unread.state = - if (sorting == SortModeSetting.UNREAD) order else Item.MultiSort.SORT_NONE + if (sorting == SortModeSetting.UNREAD_COUNT) order else Item.MultiSort.SORT_NONE total.state = if (sorting == SortModeSetting.TOTAL_CHAPTERS) order else Item.MultiSort.SORT_NONE latestChapter.state = if (sorting == SortModeSetting.LATEST_CHAPTER) order else Item.MultiSort.SORT_NONE chapterFetchDate.state = - if (sorting == SortModeSetting.DATE_FETCHED) order else Item.MultiSort.SORT_NONE + if (sorting == SortModeSetting.CHAPTER_FETCH_DATE) order else Item.MultiSort.SORT_NONE dateAdded.state = if (sorting == SortModeSetting.DATE_ADDED) order else Item.MultiSort.SORT_NONE } @@ -261,11 +261,11 @@ class LibrarySettingsSheet( val flag = when (item) { alphabetically -> SortModeSetting.ALPHABETICAL lastRead -> SortModeSetting.LAST_READ - lastChecked -> SortModeSetting.LAST_CHECKED - unread -> SortModeSetting.UNREAD + lastChecked -> SortModeSetting.LAST_MANGA_UPDATE + unread -> SortModeSetting.UNREAD_COUNT total -> SortModeSetting.TOTAL_CHAPTERS latestChapter -> SortModeSetting.LATEST_CHAPTER - chapterFetchDate -> SortModeSetting.DATE_FETCHED + chapterFetchDate -> SortModeSetting.CHAPTER_FETCH_DATE dateAdded -> SortModeSetting.DATE_ADDED else -> throw NotImplementedError("Unknown display mode") } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/SortModeSetting.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/SortModeSetting.kt index 277bb8fb9e..8a0a758606 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/SortModeSetting.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/SortModeSetting.kt @@ -6,11 +6,11 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper enum class SortModeSetting(val flag: Int) { ALPHABETICAL(0b00000000), LAST_READ(0b00000100), - LAST_CHECKED(0b00001000), - UNREAD(0b00001100), + LAST_MANGA_UPDATE(0b00001000), + UNREAD_COUNT(0b00001100), TOTAL_CHAPTERS(0b00010000), LATEST_CHAPTER(0b00010100), - DATE_FETCHED(0b00011000), + CHAPTER_FETCH_DATE(0b00011000), DATE_ADDED(0b00011100); companion object { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b3668e6ae9..caf74d51d3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -44,9 +44,10 @@ Total manga Total chapters Last read - Last checked + Last manga update + Unread count Latest chapter - Date fetched + Chapter fetch date Date added Search Search settings