Reword and Fix library sort (#7068)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/library/setting/SortModeSetting.kt
This commit is contained in:
FourTOne5 2022-05-04 04:39:04 +06:00 committed by Jobobby04
parent 93a275cfc0
commit ea20b44865
6 changed files with 29 additions and 25 deletions

View File

@ -206,11 +206,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
}

View File

@ -332,15 +332,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++ }
}
// SY -->
@ -392,10 +395,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
@ -412,7 +415,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)

View File

@ -199,8 +199,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)
@ -229,15 +229,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
// SY -->
@ -306,11 +306,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
// SY -->
dragAndDrop -> SortModeSetting.DRAG_AND_DROP

View File

@ -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),
DRAG_AND_DROP(0b00100000),
TAG_LIST(0b00100100);

View File

@ -314,11 +314,11 @@ object EXHMigrations {
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
LibrarySort.DRAG_AND_DROP -> SortModeSetting.DRAG_AND_DROP
LibrarySort.TAG_LIST -> SortModeSetting.TAG_LIST

View File

@ -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>