mirror of
https://github.com/mihonapp/mihon.git
synced 2025-02-15 03:28:56 +01:00
Merge f702839932d451ea444e08a52ef224f146aaa009 into 6b2bba4e5495274552787adc20db390a89d783b6
This commit is contained in:
commit
8f28f52175
@ -178,6 +178,7 @@ private fun ColumnScope.SortPage(
|
|||||||
MR.strings.action_sort_latest_chapter to LibrarySort.Type.LatestChapter,
|
MR.strings.action_sort_latest_chapter to LibrarySort.Type.LatestChapter,
|
||||||
MR.strings.action_sort_chapter_fetch_date to LibrarySort.Type.ChapterFetchDate,
|
MR.strings.action_sort_chapter_fetch_date to LibrarySort.Type.ChapterFetchDate,
|
||||||
MR.strings.action_sort_date_added to LibrarySort.Type.DateAdded,
|
MR.strings.action_sort_date_added to LibrarySort.Type.DateAdded,
|
||||||
|
MR.strings.action_sort_download_count to LibrarySort.Type.DownloadCount,
|
||||||
).plus(trackerSortOption).map { (titleRes, mode) ->
|
).plus(trackerSortOption).map { (titleRes, mode) ->
|
||||||
SortItem(
|
SortItem(
|
||||||
label = stringResource(titleRes),
|
label = stringResource(titleRes),
|
||||||
|
@ -300,6 +300,9 @@ class LibraryScreenModel(
|
|||||||
val item2Score = trackerScores[i2.libraryManga.id] ?: defaultTrackerScoreSortValue
|
val item2Score = trackerScores[i2.libraryManga.id] ?: defaultTrackerScoreSortValue
|
||||||
item1Score.compareTo(item2Score)
|
item1Score.compareTo(item2Score)
|
||||||
}
|
}
|
||||||
|
LibrarySort.Type.DownloadCount -> {
|
||||||
|
i1.downloadCount.compareTo(i2.downloadCount)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ data class LibrarySort(
|
|||||||
val isAscending: Boolean
|
val isAscending: Boolean
|
||||||
get() = direction == Direction.Ascending
|
get() = direction == Direction.Ascending
|
||||||
|
|
||||||
|
@Suppress("MagicNumber")
|
||||||
sealed class Type(
|
sealed class Type(
|
||||||
override val flag: Long,
|
override val flag: Long,
|
||||||
) : FlagWithMask {
|
) : FlagWithMask {
|
||||||
@ -31,6 +32,7 @@ data class LibrarySort(
|
|||||||
data object ChapterFetchDate : Type(0b00011000)
|
data object ChapterFetchDate : Type(0b00011000)
|
||||||
data object DateAdded : Type(0b00011100)
|
data object DateAdded : Type(0b00011100)
|
||||||
data object TrackerMean : Type(0b000100000)
|
data object TrackerMean : Type(0b000100000)
|
||||||
|
data object DownloadCount : Type(0b000100100)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun valueOf(flag: Long): Type {
|
fun valueOf(flag: Long): Type {
|
||||||
@ -77,6 +79,7 @@ data class LibrarySort(
|
|||||||
Type.ChapterFetchDate,
|
Type.ChapterFetchDate,
|
||||||
Type.DateAdded,
|
Type.DateAdded,
|
||||||
Type.TrackerMean,
|
Type.TrackerMean,
|
||||||
|
Type.DownloadCount,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val directions by lazy { setOf(Direction.Ascending, Direction.Descending) }
|
val directions by lazy { setOf(Direction.Ascending, Direction.Descending) }
|
||||||
@ -90,6 +93,7 @@ data class LibrarySort(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("CyclomaticComplexMethod")
|
||||||
fun deserialize(serialized: String): LibrarySort {
|
fun deserialize(serialized: String): LibrarySort {
|
||||||
if (serialized.isEmpty()) return default
|
if (serialized.isEmpty()) return default
|
||||||
return try {
|
return try {
|
||||||
@ -104,6 +108,7 @@ data class LibrarySort(
|
|||||||
"CHAPTER_FETCH_DATE" -> Type.ChapterFetchDate
|
"CHAPTER_FETCH_DATE" -> Type.ChapterFetchDate
|
||||||
"DATE_ADDED" -> Type.DateAdded
|
"DATE_ADDED" -> Type.DateAdded
|
||||||
"TRACKER_MEAN" -> Type.TrackerMean
|
"TRACKER_MEAN" -> Type.TrackerMean
|
||||||
|
"DOWNLOAD_COUNT" -> Type.DownloadCount
|
||||||
else -> Type.Alphabetical
|
else -> Type.Alphabetical
|
||||||
}
|
}
|
||||||
val ascending = if (values[1] == "ASCENDING") Direction.Ascending else Direction.Descending
|
val ascending = if (values[1] == "ASCENDING") Direction.Ascending else Direction.Descending
|
||||||
@ -125,6 +130,7 @@ data class LibrarySort(
|
|||||||
Type.ChapterFetchDate -> "CHAPTER_FETCH_DATE"
|
Type.ChapterFetchDate -> "CHAPTER_FETCH_DATE"
|
||||||
Type.DateAdded -> "DATE_ADDED"
|
Type.DateAdded -> "DATE_ADDED"
|
||||||
Type.TrackerMean -> "TRACKER_MEAN"
|
Type.TrackerMean -> "TRACKER_MEAN"
|
||||||
|
Type.DownloadCount -> "DOWNLOAD_COUNT"
|
||||||
}
|
}
|
||||||
val direction = if (direction == Direction.Ascending) "ASCENDING" else "DESCENDING"
|
val direction = if (direction == Direction.Ascending) "ASCENDING" else "DESCENDING"
|
||||||
return "$type,$direction"
|
return "$type,$direction"
|
||||||
|
@ -12,7 +12,7 @@ class LibraryFlagsTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `Check the amount of flags`() {
|
fun `Check the amount of flags`() {
|
||||||
LibraryDisplayMode.values.size shouldBe 4
|
LibraryDisplayMode.values.size shouldBe 4
|
||||||
LibrarySort.types.size shouldBe 9
|
LibrarySort.types.size shouldBe 10
|
||||||
LibrarySort.directions.size shouldBe 2
|
LibrarySort.directions.size shouldBe 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
<string name="action_sort_chapter_fetch_date">Chapter fetch date</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_sort_tracker_score">Tracker score</string>
|
<string name="action_sort_tracker_score">Tracker score</string>
|
||||||
|
<string name="action_sort_download_count">Download count</string>
|
||||||
<string name="action_search">Search</string>
|
<string name="action_search">Search</string>
|
||||||
<string name="action_search_hint">Search…</string>
|
<string name="action_search_hint">Search…</string>
|
||||||
<string name="action_search_settings">Search settings</string>
|
<string name="action_search_settings">Search settings</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user