mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 02:39:16 +01:00
Reword and Fix library sort (#7068)
This commit is contained in:
parent
55a1cdb1c7
commit
6d802063b4
@ -204,11 +204,11 @@ object Migrations {
|
|||||||
val newSortingMode = when (oldSortingMode) {
|
val newSortingMode = when (oldSortingMode) {
|
||||||
LibrarySort.ALPHA -> SortModeSetting.ALPHABETICAL
|
LibrarySort.ALPHA -> SortModeSetting.ALPHABETICAL
|
||||||
LibrarySort.LAST_READ -> SortModeSetting.LAST_READ
|
LibrarySort.LAST_READ -> SortModeSetting.LAST_READ
|
||||||
LibrarySort.LAST_CHECKED -> SortModeSetting.LAST_CHECKED
|
LibrarySort.LAST_CHECKED -> SortModeSetting.LAST_MANGA_UPDATE
|
||||||
LibrarySort.UNREAD -> SortModeSetting.UNREAD
|
LibrarySort.UNREAD -> SortModeSetting.UNREAD_COUNT
|
||||||
LibrarySort.TOTAL -> SortModeSetting.TOTAL_CHAPTERS
|
LibrarySort.TOTAL -> SortModeSetting.TOTAL_CHAPTERS
|
||||||
LibrarySort.LATEST_CHAPTER -> SortModeSetting.LATEST_CHAPTER
|
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.DATE_ADDED -> SortModeSetting.DATE_ADDED
|
||||||
else -> SortModeSetting.ALPHABETICAL
|
else -> SortModeSetting.ALPHABETICAL
|
||||||
}
|
}
|
||||||
|
@ -252,15 +252,18 @@ class LibraryPresenter(
|
|||||||
private fun applySort(categories: List<Category>, map: LibraryMap): LibraryMap {
|
private fun applySort(categories: List<Category>, map: LibraryMap): LibraryMap {
|
||||||
val lastReadManga by lazy {
|
val lastReadManga by lazy {
|
||||||
var counter = 0
|
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 {
|
val latestChapterManga by lazy {
|
||||||
var counter = 0
|
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 {
|
val chapterFetchDateManga by lazy {
|
||||||
var counter = 0
|
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 ->
|
val sortingModes = categories.associate { category ->
|
||||||
@ -287,10 +290,10 @@ class LibraryPresenter(
|
|||||||
val manga2LastRead = lastReadManga[i2.manga.id!!] ?: 0
|
val manga2LastRead = lastReadManga[i2.manga.id!!] ?: 0
|
||||||
manga1LastRead.compareTo(manga2LastRead)
|
manga1LastRead.compareTo(manga2LastRead)
|
||||||
}
|
}
|
||||||
SortModeSetting.LAST_CHECKED -> {
|
SortModeSetting.LAST_MANGA_UPDATE -> {
|
||||||
i1.manga.last_update.compareTo(i2.manga.last_update)
|
i1.manga.last_update.compareTo(i2.manga.last_update)
|
||||||
}
|
}
|
||||||
SortModeSetting.UNREAD -> when {
|
SortModeSetting.UNREAD_COUNT -> when {
|
||||||
// Ensure unread content comes first
|
// Ensure unread content comes first
|
||||||
i1.manga.unreadCount == i2.manga.unreadCount -> 0
|
i1.manga.unreadCount == i2.manga.unreadCount -> 0
|
||||||
i1.manga.unreadCount == 0 -> if (sortAscending) 1 else -1
|
i1.manga.unreadCount == 0 -> if (sortAscending) 1 else -1
|
||||||
@ -307,7 +310,7 @@ class LibraryPresenter(
|
|||||||
?: latestChapterManga.size
|
?: latestChapterManga.size
|
||||||
manga1latestChapter.compareTo(manga2latestChapter)
|
manga1latestChapter.compareTo(manga2latestChapter)
|
||||||
}
|
}
|
||||||
SortModeSetting.DATE_FETCHED -> {
|
SortModeSetting.CHAPTER_FETCH_DATE -> {
|
||||||
val manga1chapterFetchDate = chapterFetchDateManga[i1.manga.id!!] ?: 0
|
val manga1chapterFetchDate = chapterFetchDateManga[i1.manga.id!!] ?: 0
|
||||||
val manga2chapterFetchDate = chapterFetchDateManga[i2.manga.id!!] ?: 0
|
val manga2chapterFetchDate = chapterFetchDateManga[i2.manga.id!!] ?: 0
|
||||||
manga1chapterFetchDate.compareTo(manga2chapterFetchDate)
|
manga1chapterFetchDate.compareTo(manga2chapterFetchDate)
|
||||||
|
@ -182,8 +182,8 @@ class LibrarySettingsSheet(
|
|||||||
private val alphabetically = Item.MultiSort(R.string.action_sort_alpha, this)
|
private val alphabetically = Item.MultiSort(R.string.action_sort_alpha, this)
|
||||||
private val total = Item.MultiSort(R.string.action_sort_total, 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 lastRead = Item.MultiSort(R.string.action_sort_last_read, this)
|
||||||
private val lastChecked = Item.MultiSort(R.string.action_sort_last_checked, this)
|
private val lastChecked = Item.MultiSort(R.string.action_sort_last_manga_update, this)
|
||||||
private val unread = Item.MultiSort(R.string.action_filter_unread, 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 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 chapterFetchDate = Item.MultiSort(R.string.action_sort_chapter_fetch_date, this)
|
||||||
private val dateAdded = Item.MultiSort(R.string.action_sort_date_added, this)
|
private val dateAdded = Item.MultiSort(R.string.action_sort_date_added, this)
|
||||||
@ -206,15 +206,15 @@ class LibrarySettingsSheet(
|
|||||||
lastRead.state =
|
lastRead.state =
|
||||||
if (sorting == SortModeSetting.LAST_READ) order else Item.MultiSort.SORT_NONE
|
if (sorting == SortModeSetting.LAST_READ) order else Item.MultiSort.SORT_NONE
|
||||||
lastChecked.state =
|
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 =
|
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 =
|
total.state =
|
||||||
if (sorting == SortModeSetting.TOTAL_CHAPTERS) order else Item.MultiSort.SORT_NONE
|
if (sorting == SortModeSetting.TOTAL_CHAPTERS) order else Item.MultiSort.SORT_NONE
|
||||||
latestChapter.state =
|
latestChapter.state =
|
||||||
if (sorting == SortModeSetting.LATEST_CHAPTER) order else Item.MultiSort.SORT_NONE
|
if (sorting == SortModeSetting.LATEST_CHAPTER) order else Item.MultiSort.SORT_NONE
|
||||||
chapterFetchDate.state =
|
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 =
|
dateAdded.state =
|
||||||
if (sorting == SortModeSetting.DATE_ADDED) order else Item.MultiSort.SORT_NONE
|
if (sorting == SortModeSetting.DATE_ADDED) order else Item.MultiSort.SORT_NONE
|
||||||
}
|
}
|
||||||
@ -261,11 +261,11 @@ class LibrarySettingsSheet(
|
|||||||
val flag = when (item) {
|
val flag = when (item) {
|
||||||
alphabetically -> SortModeSetting.ALPHABETICAL
|
alphabetically -> SortModeSetting.ALPHABETICAL
|
||||||
lastRead -> SortModeSetting.LAST_READ
|
lastRead -> SortModeSetting.LAST_READ
|
||||||
lastChecked -> SortModeSetting.LAST_CHECKED
|
lastChecked -> SortModeSetting.LAST_MANGA_UPDATE
|
||||||
unread -> SortModeSetting.UNREAD
|
unread -> SortModeSetting.UNREAD_COUNT
|
||||||
total -> SortModeSetting.TOTAL_CHAPTERS
|
total -> SortModeSetting.TOTAL_CHAPTERS
|
||||||
latestChapter -> SortModeSetting.LATEST_CHAPTER
|
latestChapter -> SortModeSetting.LATEST_CHAPTER
|
||||||
chapterFetchDate -> SortModeSetting.DATE_FETCHED
|
chapterFetchDate -> SortModeSetting.CHAPTER_FETCH_DATE
|
||||||
dateAdded -> SortModeSetting.DATE_ADDED
|
dateAdded -> SortModeSetting.DATE_ADDED
|
||||||
else -> throw NotImplementedError("Unknown display mode")
|
else -> throw NotImplementedError("Unknown display mode")
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||||||
enum class SortModeSetting(val flag: Int) {
|
enum class SortModeSetting(val flag: Int) {
|
||||||
ALPHABETICAL(0b00000000),
|
ALPHABETICAL(0b00000000),
|
||||||
LAST_READ(0b00000100),
|
LAST_READ(0b00000100),
|
||||||
LAST_CHECKED(0b00001000),
|
LAST_MANGA_UPDATE(0b00001000),
|
||||||
UNREAD(0b00001100),
|
UNREAD_COUNT(0b00001100),
|
||||||
TOTAL_CHAPTERS(0b00010000),
|
TOTAL_CHAPTERS(0b00010000),
|
||||||
LATEST_CHAPTER(0b00010100),
|
LATEST_CHAPTER(0b00010100),
|
||||||
DATE_FETCHED(0b00011000),
|
CHAPTER_FETCH_DATE(0b00011000),
|
||||||
DATE_ADDED(0b00011100);
|
DATE_ADDED(0b00011100);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -44,9 +44,10 @@
|
|||||||
<string name="action_sort_count">Total manga</string>
|
<string name="action_sort_count">Total manga</string>
|
||||||
<string name="action_sort_total">Total chapters</string>
|
<string name="action_sort_total">Total chapters</string>
|
||||||
<string name="action_sort_last_read">Last read</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_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_sort_date_added">Date added</string>
|
||||||
<string name="action_search">Search</string>
|
<string name="action_search">Search</string>
|
||||||
<string name="action_search_settings">Search settings</string>
|
<string name="action_search_settings">Search settings</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user