瀏覽代碼

Reword and Fix library sort (#7068)

FourTOne5 2 年之前
父節點
當前提交
6d802063b4

+ 3 - 3
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
                 }

+ 9 - 6
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt

@@ -252,15 +252,18 @@ class LibraryPresenter(
     private fun applySort(categories: List<Category>, 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)

+ 8 - 8
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")
                 }

+ 3 - 3
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 {

+ 3 - 2
app/src/main/res/values/strings.xml

@@ -44,9 +44,10 @@
     <string name="action_sort_count">Total manga</string>
     <string name="action_sort_total">Total chapters</string>
     <string name="action_sort_last_read">Last read</string>
-    <string name="action_sort_last_checked">Last checked</string>
+    <string name="action_sort_last_manga_update">Last manga update</string>
+    <string name="action_sort_unread_count">Unread count</string>
     <string name="action_sort_latest_chapter">Latest chapter</string>
-    <string name="action_sort_chapter_fetch_date">Date fetched</string>
+    <string name="action_sort_chapter_fetch_date">Chapter fetch date</string>
     <string name="action_sort_date_added">Date added</string>
     <string name="action_search">Search</string>
     <string name="action_search_settings">Search settings</string>