Compare commits

...

6 Commits

Author SHA1 Message Date
Jack Hamilton
dae7a00b41 Whoops spotlessed again 2024-10-12 16:34:40 -05:00
Jack Hamilton
c3adf103d7 Sorted error, spotless'd 2024-10-12 16:33:30 -05:00
Jack Hamilton
945ae821fb
Update domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
2024-10-12 16:28:42 -05:00
Jack Hamilton
aefce87650
Update app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
2024-10-12 16:28:27 -05:00
Jack Hamilton
c70685584f Update random item bitmask 2024-10-12 15:17:17 -05:00
Jack Hamilton
36c864d873
Update app/src/main/java/eu/kanade/presentation/library/LibrarySettingsDialog.kt
Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
2024-10-12 15:13:53 -05:00
6 changed files with 9 additions and 15 deletions

View File

@ -184,14 +184,10 @@ private fun ColumnScope.SortPage(
MR.strings.action_sort_random to LibrarySort.Type.Random,
).plus(trackerSortOption).map { (titleRes, mode) ->
if (mode == LibrarySort.Type.Random) {
val enabledIcon = if (sortingMode == LibrarySort.Type.Random) {
Icons.Default.Refresh
} else {
null
}
BaseSortItem(
label = stringResource(titleRes),
icon = enabledIcon,
icon = Icons.Default.Refresh
.takeIf { sortingMode == LibrarySort.Type.Random },
onClick = {
screenModel.setSort(category, mode, LibrarySort.Direction.Ascending)
},

View File

@ -302,16 +302,15 @@ class LibraryScreenModel(
item1Score.compareTo(item2Score)
}
LibrarySort.Type.Random -> {
error("A comparator should not be requested for the random sort style. Instead, intercept this " +
"case and call .shuffle()")
error("Why Are We Still Here? Just To Suffer?")
}
}
}
return mapValues { (key, value) ->
if (key.sort.type == LibrarySort.Type.Random) {
return@mapValues value.shuffled(Random(libraryPreferences.currentRandomSortSeed().get()))
}
if (key.sort.type == LibrarySort.Type.Random) {
return@mapValues value.shuffled(Random(libraryPreferences.randomSortSeed().get()))
}
val comparator = key.sort.comparator()
.let { if (key.sort.isAscending) it else it.reversed() }

View File

@ -17,7 +17,7 @@ class SetSortModeForCategory(
val category = categoryId?.let { categoryRepository.get(it) }
val flags = (category?.flags ?: 0) + type + direction
if (type == LibrarySort.Type.Random) {
preferences.currentRandomSortSeed().set(Random.nextInt())
preferences.randomSortSeed().set(Random.nextInt())
}
if (category != null && preferences.categorizedDisplaySettings().get()) {
categoryRepository.updatePartial(

View File

@ -31,7 +31,7 @@ data class LibrarySort(
data object ChapterFetchDate : Type(0b00011000)
data object DateAdded : Type(0b00011100)
data object TrackerMean : Type(0b00100000)
data object Random : Type(0b00100100)
data object Random : Type(0b00111100)
companion object {
fun valueOf(flag: Long): Type {

View File

@ -26,7 +26,7 @@ class LibraryPreferences(
LibrarySort.Serializer::deserialize,
)
fun currentRandomSortSeed() = preferenceStore.getInt("library_random_sort_seed", 0)
fun randomSortSeed() = preferenceStore.getInt("library_random_sort_seed", 0)
fun portraitColumns() = preferenceStore.getInt("pref_library_columns_portrait_key", 0)

View File

@ -17,7 +17,6 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDownward
import androidx.compose.material.icons.filled.ArrowUpward
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.rounded.CheckBox
import androidx.compose.material.icons.rounded.CheckBoxOutlineBlank
import androidx.compose.material.icons.rounded.DisabledByDefault