mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-29 09:53:19 -05:00
Clean up reading mode / orientation enum classes
Categorizing the reading modes so we can implement a better selection UI.
This commit is contained in:
parent
5f34539525
commit
4502902fb0
16 changed files with 156 additions and 118 deletions
|
@ -1,7 +1,7 @@
|
||||||
package eu.kanade.domain.manga.interactor
|
package eu.kanade.domain.manga.interactor
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
import tachiyomi.domain.manga.model.MangaUpdate
|
import tachiyomi.domain.manga.model.MangaUpdate
|
||||||
import tachiyomi.domain.manga.repository.MangaRepository
|
import tachiyomi.domain.manga.repository.MangaRepository
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class SetMangaViewerFlags(
|
||||||
mangaRepository.update(
|
mangaRepository.update(
|
||||||
MangaUpdate(
|
MangaUpdate(
|
||||||
id = id,
|
id = id,
|
||||||
viewerFlags = manga.viewerFlags.setFlag(flag, ReadingModeType.MASK.toLong()),
|
viewerFlags = manga.viewerFlags.setFlag(flag, ReadingMode.MASK.toLong()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class SetMangaViewerFlags(
|
||||||
mangaRepository.update(
|
mangaRepository.update(
|
||||||
MangaUpdate(
|
MangaUpdate(
|
||||||
id = id,
|
id = id,
|
||||||
viewerFlags = manga.viewerFlags.setFlag(flag, OrientationType.MASK.toLong()),
|
viewerFlags = manga.viewerFlags.setFlag(flag, ReaderOrientation.MASK.toLong()),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package eu.kanade.domain.manga.model
|
||||||
import eu.kanade.domain.base.BasePreferences
|
import eu.kanade.domain.base.BasePreferences
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
import tachiyomi.core.metadata.comicinfo.ComicInfo
|
import tachiyomi.core.metadata.comicinfo.ComicInfo
|
||||||
import tachiyomi.core.metadata.comicinfo.ComicInfoPublishingStatus
|
import tachiyomi.core.metadata.comicinfo.ComicInfoPublishingStatus
|
||||||
import tachiyomi.core.preference.TriState
|
import tachiyomi.core.preference.TriState
|
||||||
|
@ -14,11 +14,11 @@ import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
// TODO: move these into the domain model
|
// TODO: move these into the domain model
|
||||||
val Manga.readingModeType: Long
|
val Manga.readingMode: Long
|
||||||
get() = viewerFlags and ReadingModeType.MASK.toLong()
|
get() = viewerFlags and ReadingMode.MASK.toLong()
|
||||||
|
|
||||||
val Manga.orientationType: Long
|
val Manga.readerOrientation: Long
|
||||||
get() = viewerFlags and OrientationType.MASK.toLong()
|
get() = viewerFlags and ReaderOrientation.MASK.toLong()
|
||||||
|
|
||||||
val Manga.downloadedFilter: TriState
|
val Manga.downloadedFilter: TriState
|
||||||
get() {
|
get() {
|
||||||
|
|
|
@ -10,9 +10,9 @@ import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.kanade.presentation.more.settings.Preference
|
import eu.kanade.presentation.more.settings.Preference
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
import tachiyomi.presentation.core.util.collectAsState
|
import tachiyomi.presentation.core.util.collectAsState
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
@ -32,7 +32,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = readerPref.defaultReadingMode(),
|
pref = readerPref.defaultReadingMode(),
|
||||||
title = stringResource(R.string.pref_viewer_type),
|
title = stringResource(R.string.pref_viewer_type),
|
||||||
entries = ReadingModeType.entries.drop(1)
|
entries = ReadingMode.entries.drop(1)
|
||||||
.associate { it.flagValue to stringResource(it.stringRes) },
|
.associate { it.flagValue to stringResource(it.stringRes) },
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
|
@ -88,7 +88,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
pref = readerPreferences.defaultOrientationType(),
|
pref = readerPreferences.defaultOrientationType(),
|
||||||
title = stringResource(R.string.pref_rotation_type),
|
title = stringResource(R.string.pref_rotation_type),
|
||||||
entries = OrientationType.entries.drop(1)
|
entries = ReaderOrientation.entries.drop(1)
|
||||||
.associate { it.flagValue to stringResource(it.stringRes) },
|
.associate { it.flagValue to stringResource(it.stringRes) },
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
|
|
|
@ -13,28 +13,28 @@ import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.domain.manga.model.orientationType
|
import eu.kanade.domain.manga.model.readerOrientation
|
||||||
import eu.kanade.presentation.components.AdaptiveSheet
|
import eu.kanade.presentation.components.AdaptiveSheet
|
||||||
import eu.kanade.presentation.theme.TachiyomiTheme
|
import eu.kanade.presentation.theme.TachiyomiTheme
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
||||||
import tachiyomi.presentation.core.components.SettingsIconGrid
|
import tachiyomi.presentation.core.components.SettingsIconGrid
|
||||||
import tachiyomi.presentation.core.components.material.IconToggleButton
|
import tachiyomi.presentation.core.components.material.IconToggleButton
|
||||||
import tachiyomi.presentation.core.util.ThemePreviews
|
import tachiyomi.presentation.core.util.ThemePreviews
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun OrientationModeSelectDialog(
|
fun OrientationSelectDialog(
|
||||||
onDismissRequest: () -> Unit,
|
onDismissRequest: () -> Unit,
|
||||||
screenModel: ReaderSettingsScreenModel,
|
screenModel: ReaderSettingsScreenModel,
|
||||||
onChange: (Int) -> Unit,
|
onChange: (Int) -> Unit,
|
||||||
) {
|
) {
|
||||||
val manga by screenModel.mangaFlow.collectAsState()
|
val manga by screenModel.mangaFlow.collectAsState()
|
||||||
val orientationType = remember(manga) { OrientationType.fromPreference(manga?.orientationType?.toInt()) }
|
val orientation = remember(manga) { ReaderOrientation.fromPreference(manga?.readerOrientation?.toInt()) }
|
||||||
|
|
||||||
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
||||||
DialogContent(
|
DialogContent(
|
||||||
orientationType = orientationType,
|
orientation = orientation,
|
||||||
onChangeOrientation = {
|
onChangeOrientation = {
|
||||||
screenModel.onChangeOrientation(it)
|
screenModel.onChangeOrientation(it)
|
||||||
onChange(it.stringRes)
|
onChange(it.stringRes)
|
||||||
|
@ -46,14 +46,14 @@ fun OrientationModeSelectDialog(
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DialogContent(
|
private fun DialogContent(
|
||||||
orientationType: OrientationType,
|
orientation: ReaderOrientation,
|
||||||
onChangeOrientation: (OrientationType) -> Unit,
|
onChangeOrientation: (ReaderOrientation) -> Unit,
|
||||||
) {
|
) {
|
||||||
Box(modifier = Modifier.padding(vertical = 16.dp)) {
|
Box(modifier = Modifier.padding(vertical = 16.dp)) {
|
||||||
SettingsIconGrid(R.string.rotation_type) {
|
SettingsIconGrid(R.string.rotation_type) {
|
||||||
items(OrientationType.entries) { mode ->
|
items(ReaderOrientation.entries) { mode ->
|
||||||
IconToggleButton(
|
IconToggleButton(
|
||||||
checked = mode == orientationType,
|
checked = mode == orientation,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
onChangeOrientation(mode)
|
onChangeOrientation(mode)
|
||||||
},
|
},
|
||||||
|
@ -71,7 +71,7 @@ private fun DialogContent(
|
||||||
private fun DialogContentPreview() {
|
private fun DialogContentPreview() {
|
||||||
TachiyomiTheme {
|
TachiyomiTheme {
|
||||||
DialogContent(
|
DialogContent(
|
||||||
orientationType = OrientationType.DEFAULT,
|
orientation = ReaderOrientation.DEFAULT,
|
||||||
onChangeOrientation = {},
|
onChangeOrientation = {},
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -13,12 +13,12 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
import eu.kanade.domain.manga.model.readingModeType
|
import eu.kanade.domain.manga.model.readingMode
|
||||||
import eu.kanade.presentation.components.AdaptiveSheet
|
import eu.kanade.presentation.components.AdaptiveSheet
|
||||||
import eu.kanade.presentation.theme.TachiyomiTheme
|
import eu.kanade.presentation.theme.TachiyomiTheme
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
import tachiyomi.presentation.core.components.SettingsIconGrid
|
import tachiyomi.presentation.core.components.SettingsIconGrid
|
||||||
import tachiyomi.presentation.core.components.material.IconToggleButton
|
import tachiyomi.presentation.core.components.material.IconToggleButton
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
|
@ -31,7 +31,7 @@ fun ReadingModeSelectDialog(
|
||||||
onChange: (Int) -> Unit,
|
onChange: (Int) -> Unit,
|
||||||
) {
|
) {
|
||||||
val manga by screenModel.mangaFlow.collectAsState()
|
val manga by screenModel.mangaFlow.collectAsState()
|
||||||
val readingMode = remember(manga) { ReadingModeType.fromPreference(manga?.readingModeType?.toInt()) }
|
val readingMode = remember(manga) { ReadingMode.fromPreference(manga?.readingMode?.toInt()) }
|
||||||
|
|
||||||
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
AdaptiveSheet(onDismissRequest = onDismissRequest) {
|
||||||
DialogContent(
|
DialogContent(
|
||||||
|
@ -47,12 +47,12 @@ fun ReadingModeSelectDialog(
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DialogContent(
|
private fun DialogContent(
|
||||||
readingMode: ReadingModeType,
|
readingMode: ReadingMode,
|
||||||
onChangeReadingMode: (ReadingModeType) -> Unit,
|
onChangeReadingMode: (ReadingMode) -> Unit,
|
||||||
) {
|
) {
|
||||||
Box(modifier = Modifier.padding(vertical = MaterialTheme.padding.medium)) {
|
Box(modifier = Modifier.padding(vertical = MaterialTheme.padding.medium)) {
|
||||||
SettingsIconGrid(R.string.pref_category_reading_mode) {
|
SettingsIconGrid(R.string.pref_category_reading_mode) {
|
||||||
items(ReadingModeType.entries) { mode ->
|
items(ReadingMode.entries) { mode ->
|
||||||
IconToggleButton(
|
IconToggleButton(
|
||||||
checked = mode == readingMode,
|
checked = mode == readingMode,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
|
@ -72,7 +72,7 @@ private fun DialogContent(
|
||||||
private fun DialogContentPreview() {
|
private fun DialogContentPreview() {
|
||||||
TachiyomiTheme {
|
TachiyomiTheme {
|
||||||
DialogContent(
|
DialogContent(
|
||||||
readingMode = ReadingModeType.DEFAULT,
|
readingMode = ReadingMode.DEFAULT,
|
||||||
onChangeReadingMode = {},
|
onChangeReadingMode = {},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,16 +17,16 @@ import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BottomReaderBar(
|
fun BottomReaderBar(
|
||||||
backgroundColor: Color,
|
backgroundColor: Color,
|
||||||
readingMode: ReadingModeType,
|
readingMode: ReadingMode,
|
||||||
onClickReadingMode: () -> Unit,
|
onClickReadingMode: () -> Unit,
|
||||||
orientationMode: OrientationType,
|
orientation: ReaderOrientation,
|
||||||
onClickOrientationMode: () -> Unit,
|
onClickOrientation: () -> Unit,
|
||||||
cropEnabled: Boolean,
|
cropEnabled: Boolean,
|
||||||
onClickCropBorder: () -> Unit,
|
onClickCropBorder: () -> Unit,
|
||||||
onClickSettings: () -> Unit,
|
onClickSettings: () -> Unit,
|
||||||
|
@ -53,9 +53,9 @@ fun BottomReaderBar(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
IconButton(onClick = onClickOrientationMode) {
|
IconButton(onClick = onClickOrientation) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterResource(orientationMode.iconRes),
|
painter = painterResource(orientation.iconRes),
|
||||||
contentDescription = stringResource(R.string.pref_rotation_type),
|
contentDescription = stringResource(R.string.pref_rotation_type),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.presentation.components.AppBar
|
import eu.kanade.presentation.components.AppBar
|
||||||
import eu.kanade.presentation.components.AppBarActions
|
import eu.kanade.presentation.components.AppBarActions
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.Viewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.Viewer
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
||||||
|
|
||||||
|
@ -54,10 +54,10 @@ fun ReaderAppBars(
|
||||||
totalPages: Int,
|
totalPages: Int,
|
||||||
onSliderValueChange: (Int) -> Unit,
|
onSliderValueChange: (Int) -> Unit,
|
||||||
|
|
||||||
readingMode: ReadingModeType,
|
readingMode: ReadingMode,
|
||||||
onClickReadingMode: () -> Unit,
|
onClickReadingMode: () -> Unit,
|
||||||
orientationMode: OrientationType,
|
orientation: ReaderOrientation,
|
||||||
onClickOrientationMode: () -> Unit,
|
onClickOrientation: () -> Unit,
|
||||||
cropEnabled: Boolean,
|
cropEnabled: Boolean,
|
||||||
onClickCropBorder: () -> Unit,
|
onClickCropBorder: () -> Unit,
|
||||||
onClickSettings: () -> Unit,
|
onClickSettings: () -> Unit,
|
||||||
|
@ -155,8 +155,8 @@ fun ReaderAppBars(
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
readingMode = readingMode,
|
readingMode = readingMode,
|
||||||
onClickReadingMode = onClickReadingMode,
|
onClickReadingMode = onClickReadingMode,
|
||||||
orientationMode = orientationMode,
|
orientation = orientation,
|
||||||
onClickOrientationMode = onClickOrientationMode,
|
onClickOrientation = onClickOrientation,
|
||||||
cropEnabled = cropEnabled,
|
cropEnabled = cropEnabled,
|
||||||
onClickCropBorder = onClickCropBorder,
|
onClickCropBorder = onClickCropBorder,
|
||||||
onClickSettings = onClickSettings,
|
onClickSettings = onClickSettings,
|
||||||
|
|
|
@ -8,13 +8,13 @@ import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.kanade.domain.manga.model.orientationType
|
import eu.kanade.domain.manga.model.readerOrientation
|
||||||
import eu.kanade.domain.manga.model.readingModeType
|
import eu.kanade.domain.manga.model.readingMode
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
||||||
import tachiyomi.presentation.core.components.CheckboxItem
|
import tachiyomi.presentation.core.components.CheckboxItem
|
||||||
import tachiyomi.presentation.core.components.HeadingItem
|
import tachiyomi.presentation.core.components.HeadingItem
|
||||||
|
@ -23,33 +23,29 @@ import tachiyomi.presentation.core.components.SliderItem
|
||||||
import tachiyomi.presentation.core.util.collectAsState
|
import tachiyomi.presentation.core.util.collectAsState
|
||||||
import java.text.NumberFormat
|
import java.text.NumberFormat
|
||||||
|
|
||||||
private val readingModeOptions = ReadingModeType.entries.map { it.stringRes to it }
|
|
||||||
private val orientationTypeOptions = OrientationType.entries.map { it.stringRes to it }
|
|
||||||
private val tappingInvertModeOptions = ReaderPreferences.TappingInvertMode.entries.map { it.titleResId to it }
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) {
|
internal fun ColumnScope.ReadingModePage(screenModel: ReaderSettingsScreenModel) {
|
||||||
HeadingItem(R.string.pref_category_for_this_series)
|
HeadingItem(R.string.pref_category_for_this_series)
|
||||||
val manga by screenModel.mangaFlow.collectAsState()
|
val manga by screenModel.mangaFlow.collectAsState()
|
||||||
|
|
||||||
val readingMode = remember(manga) { ReadingModeType.fromPreference(manga?.readingModeType?.toInt()) }
|
val readingMode = remember(manga) { ReadingMode.fromPreference(manga?.readingMode?.toInt()) }
|
||||||
SettingsChipRow(R.string.pref_category_reading_mode) {
|
SettingsChipRow(R.string.pref_category_reading_mode) {
|
||||||
readingModeOptions.map { (stringRes, it) ->
|
ReadingMode.entries.map {
|
||||||
FilterChip(
|
FilterChip(
|
||||||
selected = it == readingMode,
|
selected = it == readingMode,
|
||||||
onClick = { screenModel.onChangeReadingMode(it) },
|
onClick = { screenModel.onChangeReadingMode(it) },
|
||||||
label = { Text(stringResource(stringRes)) },
|
label = { Text(stringResource(it.stringRes)) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val orientationType = remember(manga) { OrientationType.fromPreference(manga?.orientationType?.toInt()) }
|
val orientation = remember(manga) { ReaderOrientation.fromPreference(manga?.readerOrientation?.toInt()) }
|
||||||
SettingsChipRow(R.string.rotation_type) {
|
SettingsChipRow(R.string.rotation_type) {
|
||||||
orientationTypeOptions.map { (stringRes, it) ->
|
ReaderOrientation.entries.map {
|
||||||
FilterChip(
|
FilterChip(
|
||||||
selected = it == orientationType,
|
selected = it == orientation,
|
||||||
onClick = { screenModel.onChangeOrientation(it) },
|
onClick = { screenModel.onChangeOrientation(it) },
|
||||||
label = { Text(stringResource(stringRes)) },
|
label = { Text(stringResource(it.stringRes)) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,11 +205,11 @@ private fun ColumnScope.TapZonesItems(
|
||||||
|
|
||||||
if (selected != 5) {
|
if (selected != 5) {
|
||||||
SettingsChipRow(R.string.pref_read_with_tapping_inverted) {
|
SettingsChipRow(R.string.pref_read_with_tapping_inverted) {
|
||||||
tappingInvertModeOptions.map { (stringRes, mode) ->
|
ReaderPreferences.TappingInvertMode.entries.map {
|
||||||
FilterChip(
|
FilterChip(
|
||||||
selected = mode == invertMode,
|
selected = it == invertMode,
|
||||||
onClick = { onSelectInvertMode(mode) },
|
onClick = { onSelectInvertMode(it) },
|
||||||
label = { Text(stringResource(stringRes)) },
|
label = { Text(stringResource(it.titleResId)) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.track.TrackerManager
|
import eu.kanade.tachiyomi.data.track.TrackerManager
|
||||||
import eu.kanade.tachiyomi.network.NetworkPreferences
|
import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||||
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
@ -170,12 +170,12 @@ object Migrations {
|
||||||
if (oldVersion < 60) {
|
if (oldVersion < 60) {
|
||||||
// Migrate Rotation and Viewer values to default values for viewer_flags
|
// Migrate Rotation and Viewer values to default values for viewer_flags
|
||||||
val newOrientation = when (prefs.getInt("pref_rotation_type_key", 1)) {
|
val newOrientation = when (prefs.getInt("pref_rotation_type_key", 1)) {
|
||||||
1 -> OrientationType.FREE.flagValue
|
1 -> ReaderOrientation.FREE.flagValue
|
||||||
2 -> OrientationType.PORTRAIT.flagValue
|
2 -> ReaderOrientation.PORTRAIT.flagValue
|
||||||
3 -> OrientationType.LANDSCAPE.flagValue
|
3 -> ReaderOrientation.LANDSCAPE.flagValue
|
||||||
4 -> OrientationType.LOCKED_PORTRAIT.flagValue
|
4 -> ReaderOrientation.LOCKED_PORTRAIT.flagValue
|
||||||
5 -> OrientationType.LOCKED_LANDSCAPE.flagValue
|
5 -> ReaderOrientation.LOCKED_LANDSCAPE.flagValue
|
||||||
else -> OrientationType.FREE.flagValue
|
else -> ReaderOrientation.FREE.flagValue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reading mode flag and prefValue is the same value
|
// Reading mode flag and prefValue is the same value
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.kanade.tachiyomi.data.backup.models
|
package eu.kanade.tachiyomi.data.backup.models
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.protobuf.ProtoNumber
|
import kotlinx.serialization.protobuf.ProtoNumber
|
||||||
import tachiyomi.domain.chapter.model.Chapter
|
import tachiyomi.domain.chapter.model.Chapter
|
||||||
|
@ -89,7 +89,7 @@ data class BackupManga(
|
||||||
favorite = manga.favorite,
|
favorite = manga.favorite,
|
||||||
source = manga.source,
|
source = manga.source,
|
||||||
dateAdded = manga.dateAdded,
|
dateAdded = manga.dateAdded,
|
||||||
viewer = (manga.viewerFlags.toInt() and ReadingModeType.MASK),
|
viewer = (manga.viewerFlags.toInt() and ReadingMode.MASK),
|
||||||
viewer_flags = manga.viewerFlags.toInt(),
|
viewer_flags = manga.viewerFlags.toInt(),
|
||||||
chapterFlags = manga.chapterFlags.toInt(),
|
chapterFlags = manga.chapterFlags.toInt(),
|
||||||
updateStrategy = manga.updateStrategy,
|
updateStrategy = manga.updateStrategy,
|
||||||
|
|
|
@ -44,7 +44,7 @@ import dev.chrisbanes.insetter.applyInsetter
|
||||||
import eu.kanade.domain.base.BasePreferences
|
import eu.kanade.domain.base.BasePreferences
|
||||||
import eu.kanade.presentation.reader.BrightnessOverlay
|
import eu.kanade.presentation.reader.BrightnessOverlay
|
||||||
import eu.kanade.presentation.reader.DisplayRefreshHost
|
import eu.kanade.presentation.reader.DisplayRefreshHost
|
||||||
import eu.kanade.presentation.reader.OrientationModeSelectDialog
|
import eu.kanade.presentation.reader.OrientationSelectDialog
|
||||||
import eu.kanade.presentation.reader.PageIndicatorText
|
import eu.kanade.presentation.reader.PageIndicatorText
|
||||||
import eu.kanade.presentation.reader.ReaderPageActionsDialog
|
import eu.kanade.presentation.reader.ReaderPageActionsDialog
|
||||||
import eu.kanade.presentation.reader.ReadingModeSelectDialog
|
import eu.kanade.presentation.reader.ReadingModeSelectDialog
|
||||||
|
@ -63,10 +63,10 @@ import eu.kanade.tachiyomi.ui.reader.ReaderViewModel.SetAsCoverResult.Success
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderSettingsScreenModel
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator
|
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressIndicator
|
||||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||||
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
import eu.kanade.tachiyomi.util.system.hasDisplayCutout
|
||||||
|
@ -332,7 +332,7 @@ class ReaderActivity : BaseActivity() {
|
||||||
|
|
||||||
val cropBorderPaged by readerPreferences.cropBorders().collectAsState()
|
val cropBorderPaged by readerPreferences.cropBorders().collectAsState()
|
||||||
val cropBorderWebtoon by readerPreferences.cropBordersWebtoon().collectAsState()
|
val cropBorderWebtoon by readerPreferences.cropBordersWebtoon().collectAsState()
|
||||||
val isPagerType = ReadingModeType.isPagerType(viewModel.getMangaReadingMode())
|
val isPagerType = ReadingMode.isPagerType(viewModel.getMangaReadingMode())
|
||||||
val cropEnabled = if (isPagerType) cropBorderPaged else cropBorderWebtoon
|
val cropEnabled = if (isPagerType) cropBorderPaged else cropBorderWebtoon
|
||||||
|
|
||||||
ReaderAppBars(
|
ReaderAppBars(
|
||||||
|
@ -360,14 +360,14 @@ class ReaderActivity : BaseActivity() {
|
||||||
moveToPageIndex(it)
|
moveToPageIndex(it)
|
||||||
},
|
},
|
||||||
|
|
||||||
readingMode = ReadingModeType.fromPreference(
|
readingMode = ReadingMode.fromPreference(
|
||||||
viewModel.getMangaReadingMode(resolveDefault = false),
|
viewModel.getMangaReadingMode(resolveDefault = false),
|
||||||
),
|
),
|
||||||
onClickReadingMode = viewModel::openReadingModeSelectDialog,
|
onClickReadingMode = viewModel::openReadingModeSelectDialog,
|
||||||
orientationMode = OrientationType.fromPreference(
|
orientation = ReaderOrientation.fromPreference(
|
||||||
viewModel.getMangaOrientationType(resolveDefault = false),
|
viewModel.getMangaOrientation(resolveDefault = false),
|
||||||
),
|
),
|
||||||
onClickOrientationMode = viewModel::openOrientationModeSelectDialog,
|
onClickOrientation = viewModel::openOrientationModeSelectDialog,
|
||||||
cropEnabled = cropEnabled,
|
cropEnabled = cropEnabled,
|
||||||
onClickCropBorder = {
|
onClickCropBorder = {
|
||||||
val enabled = viewModel.toggleCropBorders()
|
val enabled = viewModel.toggleCropBorders()
|
||||||
|
@ -425,7 +425,7 @@ class ReaderActivity : BaseActivity() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is ReaderViewModel.Dialog.OrientationModeSelect -> {
|
is ReaderViewModel.Dialog.OrientationModeSelect -> {
|
||||||
OrientationModeSelectDialog(
|
OrientationSelectDialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
screenModel = settingsScreenModel,
|
screenModel = settingsScreenModel,
|
||||||
onChange = { stringRes ->
|
onChange = { stringRes ->
|
||||||
|
@ -482,15 +482,15 @@ class ReaderActivity : BaseActivity() {
|
||||||
*/
|
*/
|
||||||
private fun setManga(manga: Manga) {
|
private fun setManga(manga: Manga) {
|
||||||
val prevViewer = viewModel.state.value.viewer
|
val prevViewer = viewModel.state.value.viewer
|
||||||
val newViewer = ReadingModeType.toViewer(viewModel.getMangaReadingMode(), this)
|
val newViewer = ReadingMode.toViewer(viewModel.getMangaReadingMode(), this)
|
||||||
|
|
||||||
if (window.sharedElementEnterTransition is MaterialContainerTransform) {
|
if (window.sharedElementEnterTransition is MaterialContainerTransform) {
|
||||||
// Wait until transition is complete to avoid crash on API 26
|
// Wait until transition is complete to avoid crash on API 26
|
||||||
window.sharedElementEnterTransition.doOnEnd {
|
window.sharedElementEnterTransition.doOnEnd {
|
||||||
setOrientation(viewModel.getMangaOrientationType())
|
setOrientation(viewModel.getMangaOrientation())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setOrientation(viewModel.getMangaOrientationType())
|
setOrientation(viewModel.getMangaOrientation())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy previous viewer if there was one
|
// Destroy previous viewer if there was one
|
||||||
|
@ -543,7 +543,7 @@ class ReaderActivity : BaseActivity() {
|
||||||
private fun showReadingModeToast(mode: Int) {
|
private fun showReadingModeToast(mode: Int) {
|
||||||
try {
|
try {
|
||||||
readingModeToast?.cancel()
|
readingModeToast?.cancel()
|
||||||
readingModeToast = toast(ReadingModeType.fromPreference(mode).stringRes)
|
readingModeToast = toast(ReadingMode.fromPreference(mode).stringRes)
|
||||||
} catch (e: ArrayIndexOutOfBoundsException) {
|
} catch (e: ArrayIndexOutOfBoundsException) {
|
||||||
logcat(LogPriority.ERROR) { "Unknown reading mode: $mode" }
|
logcat(LogPriority.ERROR) { "Unknown reading mode: $mode" }
|
||||||
}
|
}
|
||||||
|
@ -721,7 +721,7 @@ class ReaderActivity : BaseActivity() {
|
||||||
* Forces the user preferred [orientation] on the activity.
|
* Forces the user preferred [orientation] on the activity.
|
||||||
*/
|
*/
|
||||||
private fun setOrientation(orientation: Int) {
|
private fun setOrientation(orientation: Int) {
|
||||||
val newOrientation = OrientationType.fromPreference(orientation)
|
val newOrientation = ReaderOrientation.fromPreference(orientation)
|
||||||
if (newOrientation.flag != requestedOrientation) {
|
if (newOrientation.flag != requestedOrientation) {
|
||||||
requestedOrientation = newOrientation.flag
|
requestedOrientation = newOrientation.flag
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ import androidx.lifecycle.viewModelScope
|
||||||
import eu.kanade.domain.base.BasePreferences
|
import eu.kanade.domain.base.BasePreferences
|
||||||
import eu.kanade.domain.chapter.model.toDbChapter
|
import eu.kanade.domain.chapter.model.toDbChapter
|
||||||
import eu.kanade.domain.manga.interactor.SetMangaViewerFlags
|
import eu.kanade.domain.manga.interactor.SetMangaViewerFlags
|
||||||
import eu.kanade.domain.manga.model.orientationType
|
import eu.kanade.domain.manga.model.readerOrientation
|
||||||
import eu.kanade.domain.manga.model.readingModeType
|
import eu.kanade.domain.manga.model.readingMode
|
||||||
import eu.kanade.domain.track.interactor.TrackChapter
|
import eu.kanade.domain.track.interactor.TrackChapter
|
||||||
import eu.kanade.domain.track.service.TrackPreferences
|
import eu.kanade.domain.track.service.TrackPreferences
|
||||||
import eu.kanade.tachiyomi.data.database.models.toDomainChapter
|
import eu.kanade.tachiyomi.data.database.models.toDomainChapter
|
||||||
|
@ -29,9 +29,9 @@ import eu.kanade.tachiyomi.ui.reader.model.InsertPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderOrientation
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingMode
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.Viewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.Viewer
|
||||||
import eu.kanade.tachiyomi.util.chapter.filterDownloaded
|
import eu.kanade.tachiyomi.util.chapter.filterDownloaded
|
||||||
import eu.kanade.tachiyomi.util.chapter.removeDuplicates
|
import eu.kanade.tachiyomi.util.chapter.removeDuplicates
|
||||||
|
@ -630,20 +630,20 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||||
*/
|
*/
|
||||||
fun getMangaReadingMode(resolveDefault: Boolean = true): Int {
|
fun getMangaReadingMode(resolveDefault: Boolean = true): Int {
|
||||||
val default = readerPreferences.defaultReadingMode().get()
|
val default = readerPreferences.defaultReadingMode().get()
|
||||||
val readingMode = ReadingModeType.fromPreference(manga?.readingModeType?.toInt())
|
val readingMode = ReadingMode.fromPreference(manga?.readingMode?.toInt())
|
||||||
return when {
|
return when {
|
||||||
resolveDefault && readingMode == ReadingModeType.DEFAULT -> default
|
resolveDefault && readingMode == ReadingMode.DEFAULT -> default
|
||||||
else -> manga?.readingModeType?.toInt() ?: default
|
else -> manga?.readingMode?.toInt() ?: default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the viewer position for the open manga.
|
* Updates the viewer position for the open manga.
|
||||||
*/
|
*/
|
||||||
fun setMangaReadingMode(readingModeType: ReadingModeType) {
|
fun setMangaReadingMode(readingMode: ReadingMode) {
|
||||||
val manga = manga ?: return
|
val manga = manga ?: return
|
||||||
runBlocking(Dispatchers.IO) {
|
runBlocking(Dispatchers.IO) {
|
||||||
setMangaViewerFlags.awaitSetReadingMode(manga.id, readingModeType.flagValue.toLong())
|
setMangaViewerFlags.awaitSetReadingMode(manga.id, readingMode.flagValue.toLong())
|
||||||
val currChapters = state.value.viewerChapters
|
val currChapters = state.value.viewerChapters
|
||||||
if (currChapters != null) {
|
if (currChapters != null) {
|
||||||
// Save current page
|
// Save current page
|
||||||
|
@ -664,22 +664,22 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||||
/**
|
/**
|
||||||
* Returns the orientation type used by this manga or the default one.
|
* Returns the orientation type used by this manga or the default one.
|
||||||
*/
|
*/
|
||||||
fun getMangaOrientationType(resolveDefault: Boolean = true): Int {
|
fun getMangaOrientation(resolveDefault: Boolean = true): Int {
|
||||||
val default = readerPreferences.defaultOrientationType().get()
|
val default = readerPreferences.defaultOrientationType().get()
|
||||||
val orientation = OrientationType.fromPreference(manga?.orientationType?.toInt())
|
val orientation = ReaderOrientation.fromPreference(manga?.readerOrientation?.toInt())
|
||||||
return when {
|
return when {
|
||||||
resolveDefault && orientation == OrientationType.DEFAULT -> default
|
resolveDefault && orientation == ReaderOrientation.DEFAULT -> default
|
||||||
else -> manga?.orientationType?.toInt() ?: default
|
else -> manga?.readerOrientation?.toInt() ?: default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the orientation type for the open manga.
|
* Updates the orientation type for the open manga.
|
||||||
*/
|
*/
|
||||||
fun setMangaOrientationType(rotationType: OrientationType) {
|
fun setMangaOrientationType(orientation: ReaderOrientation) {
|
||||||
val manga = manga ?: return
|
val manga = manga ?: return
|
||||||
viewModelScope.launchIO {
|
viewModelScope.launchIO {
|
||||||
setMangaViewerFlags.awaitSetOrientation(manga.id, rotationType.flagValue.toLong())
|
setMangaViewerFlags.awaitSetOrientation(manga.id, orientation.flagValue.toLong())
|
||||||
val currChapters = state.value.viewerChapters
|
val currChapters = state.value.viewerChapters
|
||||||
if (currChapters != null) {
|
if (currChapters != null) {
|
||||||
// Save current page
|
// Save current page
|
||||||
|
@ -692,14 +692,14 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||||
viewerChapters = currChapters,
|
viewerChapters = currChapters,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
eventChannel.send(Event.SetOrientation(getMangaOrientationType()))
|
eventChannel.send(Event.SetOrientation(getMangaOrientation()))
|
||||||
eventChannel.send(Event.ReloadViewerChapters)
|
eventChannel.send(Event.ReloadViewerChapters)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleCropBorders(): Boolean {
|
fun toggleCropBorders(): Boolean {
|
||||||
val isPagerType = ReadingModeType.isPagerType(getMangaReadingMode())
|
val isPagerType = ReadingMode.isPagerType(getMangaReadingMode())
|
||||||
return if (isPagerType) {
|
return if (isPagerType) {
|
||||||
readerPreferences.cropBorders().toggle()
|
readerPreferences.cropBorders().toggle()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import androidx.annotation.DrawableRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
|
||||||
enum class OrientationType(
|
enum class ReaderOrientation(
|
||||||
val flag: Int,
|
val flag: Int,
|
||||||
@StringRes val stringRes: Int,
|
@StringRes val stringRes: Int,
|
||||||
@DrawableRes val iconRes: Int,
|
@DrawableRes val iconRes: Int,
|
||||||
|
@ -58,6 +58,6 @@ enum class OrientationType(
|
||||||
companion object {
|
companion object {
|
||||||
const val MASK = 0x00000038
|
const val MASK = 0x00000038
|
||||||
|
|
||||||
fun fromPreference(preference: Int?): OrientationType = entries.find { it.flagValue == preference } ?: DEFAULT
|
fun fromPreference(preference: Int?): ReaderOrientation = entries.find { it.flagValue == preference } ?: DEFAULT
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,12 +32,12 @@ class ReaderPreferences(
|
||||||
|
|
||||||
fun defaultReadingMode() = preferenceStore.getInt(
|
fun defaultReadingMode() = preferenceStore.getInt(
|
||||||
"pref_default_reading_mode_key",
|
"pref_default_reading_mode_key",
|
||||||
ReadingModeType.RIGHT_TO_LEFT.flagValue,
|
ReadingMode.RIGHT_TO_LEFT.flagValue,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun defaultOrientationType() = preferenceStore.getInt(
|
fun defaultOrientationType() = preferenceStore.getInt(
|
||||||
"pref_default_orientation_type_key",
|
"pref_default_orientation_type_key",
|
||||||
OrientationType.FREE.flagValue,
|
ReaderOrientation.FREE.flagValue,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun webtoonDoubleTapZoomEnabled() = preferenceStore.getBoolean("pref_enable_double_tap_zoom_webtoon", true)
|
fun webtoonDoubleTapZoomEnabled() = preferenceStore.getBoolean("pref_enable_double_tap_zoom_webtoon", true)
|
||||||
|
|
|
@ -14,8 +14,8 @@ import uy.kohesive.injekt.api.get
|
||||||
class ReaderSettingsScreenModel(
|
class ReaderSettingsScreenModel(
|
||||||
readerState: StateFlow<ReaderViewModel.State>,
|
readerState: StateFlow<ReaderViewModel.State>,
|
||||||
val hasDisplayCutout: Boolean,
|
val hasDisplayCutout: Boolean,
|
||||||
val onChangeReadingMode: (ReadingModeType) -> Unit,
|
val onChangeReadingMode: (ReadingMode) -> Unit,
|
||||||
val onChangeOrientation: (OrientationType) -> Unit,
|
val onChangeOrientation: (ReaderOrientation) -> Unit,
|
||||||
val preferences: ReaderPreferences = Injekt.get(),
|
val preferences: ReaderPreferences = Injekt.get(),
|
||||||
) : ScreenModel {
|
) : ScreenModel {
|
||||||
|
|
||||||
|
|
|
@ -10,27 +10,59 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.VerticalPagerViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.pager.VerticalPagerViewer
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
||||||
|
|
||||||
enum class ReadingModeType(
|
enum class ReadingMode(
|
||||||
@StringRes val stringRes: Int,
|
@StringRes val stringRes: Int,
|
||||||
@DrawableRes val iconRes: Int,
|
@DrawableRes val iconRes: Int,
|
||||||
val flagValue: Int,
|
val flagValue: Int,
|
||||||
|
val direction: Direction? = null,
|
||||||
|
val type: ViewerType? = null,
|
||||||
) {
|
) {
|
||||||
DEFAULT(R.string.label_default, R.drawable.ic_reader_default_24dp, 0x00000000),
|
DEFAULT(R.string.label_default, R.drawable.ic_reader_default_24dp, 0x00000000),
|
||||||
LEFT_TO_RIGHT(R.string.left_to_right_viewer, R.drawable.ic_reader_ltr_24dp, 0x00000001),
|
LEFT_TO_RIGHT(
|
||||||
RIGHT_TO_LEFT(R.string.right_to_left_viewer, R.drawable.ic_reader_rtl_24dp, 0x00000002),
|
R.string.left_to_right_viewer,
|
||||||
VERTICAL(R.string.vertical_viewer, R.drawable.ic_reader_vertical_24dp, 0x00000003),
|
R.drawable.ic_reader_ltr_24dp,
|
||||||
WEBTOON(R.string.webtoon_viewer, R.drawable.ic_reader_webtoon_24dp, 0x00000004),
|
0x00000001,
|
||||||
CONTINUOUS_VERTICAL(R.string.vertical_plus_viewer, R.drawable.ic_reader_continuous_vertical_24dp, 0x00000005),
|
Direction.Horizontal,
|
||||||
|
ViewerType.Pager,
|
||||||
|
),
|
||||||
|
RIGHT_TO_LEFT(
|
||||||
|
R.string.right_to_left_viewer,
|
||||||
|
R.drawable.ic_reader_rtl_24dp,
|
||||||
|
0x00000002,
|
||||||
|
Direction.Horizontal,
|
||||||
|
ViewerType.Pager,
|
||||||
|
),
|
||||||
|
VERTICAL(
|
||||||
|
R.string.vertical_viewer,
|
||||||
|
R.drawable.ic_reader_vertical_24dp,
|
||||||
|
0x00000003,
|
||||||
|
Direction.Vertical,
|
||||||
|
ViewerType.Pager,
|
||||||
|
),
|
||||||
|
WEBTOON(
|
||||||
|
R.string.webtoon_viewer,
|
||||||
|
R.drawable.ic_reader_webtoon_24dp,
|
||||||
|
0x00000004,
|
||||||
|
Direction.Vertical,
|
||||||
|
ViewerType.Webtoon,
|
||||||
|
),
|
||||||
|
CONTINUOUS_VERTICAL(
|
||||||
|
R.string.vertical_plus_viewer,
|
||||||
|
R.drawable.ic_reader_continuous_vertical_24dp,
|
||||||
|
0x00000005,
|
||||||
|
Direction.Vertical,
|
||||||
|
ViewerType.Webtoon,
|
||||||
|
),
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val MASK = 0x00000007
|
const val MASK = 0x00000007
|
||||||
|
|
||||||
fun fromPreference(preference: Int?): ReadingModeType = entries.find { it.flagValue == preference } ?: DEFAULT
|
fun fromPreference(preference: Int?): ReadingMode = entries.find { it.flagValue == preference } ?: DEFAULT
|
||||||
|
|
||||||
fun isPagerType(preference: Int): Boolean {
|
fun isPagerType(preference: Int): Boolean {
|
||||||
val mode = fromPreference(preference)
|
val mode = fromPreference(preference)
|
||||||
return mode == LEFT_TO_RIGHT || mode == RIGHT_TO_LEFT || mode == VERTICAL
|
return mode.type is ViewerType.Pager
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toViewer(preference: Int?, activity: ReaderActivity): Viewer {
|
fun toViewer(preference: Int?, activity: ReaderActivity): Viewer {
|
||||||
|
@ -44,4 +76,14 @@ enum class ReadingModeType(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sealed interface Direction {
|
||||||
|
data object Horizontal : Direction
|
||||||
|
data object Vertical : Direction
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed interface ViewerType {
|
||||||
|
data object Pager : ViewerType
|
||||||
|
data object Webtoon : ViewerType
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue