fix:修复阅读更多设置状态同步问题
This commit is contained in:
@@ -1049,6 +1049,9 @@ sealed interface ConfigUpdate {
|
|||||||
data class TitleBarMode(val value: String) : ConfigUpdate {
|
data class TitleBarMode(val value: String) : ConfigUpdate {
|
||||||
override val actions = emptySet<ConfigUpdateAction>()
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
}
|
}
|
||||||
|
data class ReadBodyToLh(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = setOf(ConfigUpdateAction.ReloadContent)
|
||||||
|
}
|
||||||
data class TextFullJustify(val value: Boolean) : ConfigUpdate {
|
data class TextFullJustify(val value: Boolean) : ConfigUpdate {
|
||||||
override val actions = setOf(ConfigUpdateAction.ReloadContent)
|
override val actions = setOf(ConfigUpdateAction.ReloadContent)
|
||||||
}
|
}
|
||||||
@@ -1087,9 +1090,49 @@ sealed interface ConfigUpdate {
|
|||||||
data class ProgressBarBehavior(val value: String) : ConfigUpdate {
|
data class ProgressBarBehavior(val value: String) : ConfigUpdate {
|
||||||
override val actions = emptySet<ConfigUpdateAction>()
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
}
|
}
|
||||||
|
data class MouseWheelPage(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
|
data class VolumeKeyPage(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
|
data class VolumeKeyPageOnPlay(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
|
data class KeyPageOnLongPress(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
|
data class SliderVibrator(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
|
data class SelectVibrator(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
|
data class AutoChangeSource(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
|
data class SelectText(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
data class NoAnimScrollPage(val value: Boolean) : ConfigUpdate {
|
data class NoAnimScrollPage(val value: Boolean) : ConfigUpdate {
|
||||||
override val actions = emptySet<ConfigUpdateAction>()
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
}
|
}
|
||||||
|
data class OptimizeRender(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = setOf(
|
||||||
|
ConfigUpdateAction.UpdateChapterStyle,
|
||||||
|
ConfigUpdateAction.ReloadContent,
|
||||||
|
ConfigUpdateAction.SubmitRenderTask,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
data class ClickImgWay(val value: String) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
|
data class DisableReturnKey(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
|
data class ExpandTextMenu(val value: Boolean) : ConfigUpdate {
|
||||||
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
}
|
||||||
data class ShowReadTitleAddition(val value: Boolean) : ConfigUpdate {
|
data class ShowReadTitleAddition(val value: Boolean) : ConfigUpdate {
|
||||||
override val actions = emptySet<ConfigUpdateAction>()
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -633,10 +633,16 @@ class ReadBookViewModel(
|
|||||||
is ReadBookIntent.KeepLightChanged -> {
|
is ReadBookIntent.KeepLightChanged -> {
|
||||||
ReadConfig.keepLight = intent.value
|
ReadConfig.keepLight = intent.value
|
||||||
_readPreferences.update { it.copy(keepLight = intent.value) }
|
_readPreferences.update { it.copy(keepLight = intent.value) }
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setKeepLight(intent.value)
|
||||||
|
}
|
||||||
_effects.tryEmit(ReadBookEffect.UpScreenTimeOut)
|
_effects.tryEmit(ReadBookEffect.UpScreenTimeOut)
|
||||||
}
|
}
|
||||||
is ReadBookIntent.SetOrientation -> {
|
is ReadBookIntent.SetOrientation -> {
|
||||||
ReadConfig.screenOrientation = intent.value
|
ReadConfig.screenOrientation = intent.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setScreenOrientation(intent.value)
|
||||||
|
}
|
||||||
_effects.tryEmit(ReadBookEffect.SetOrientation)
|
_effects.tryEmit(ReadBookEffect.SetOrientation)
|
||||||
}
|
}
|
||||||
is ReadBookIntent.TextSelectAbleChanged -> _effects.tryEmit(
|
is ReadBookIntent.TextSelectAbleChanged -> _effects.tryEmit(
|
||||||
@@ -1457,6 +1463,12 @@ class ReadBookViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun syncReadPreferencesSnapshot() {
|
||||||
|
val preferences = readSettingsRepository.preferences.first()
|
||||||
|
ReadConfig.syncReadPreferences(preferences)
|
||||||
|
_readPreferences.value = preferences
|
||||||
|
}
|
||||||
|
|
||||||
private fun collectReadAloudPreferences() {
|
private fun collectReadAloudPreferences() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readAloudSettingsRepository.preferences.collect { prefs ->
|
readAloudSettingsRepository.preferences.collect { prefs ->
|
||||||
@@ -1734,6 +1746,7 @@ class ReadBookViewModel(
|
|||||||
|
|
||||||
fun initData(intent: Intent, success: (() -> Unit)? = null) {
|
fun initData(intent: Intent, success: (() -> Unit)? = null) {
|
||||||
execute {
|
execute {
|
||||||
|
syncReadPreferencesSnapshot()
|
||||||
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
|
ReadBook.inBookshelf = intent.getBooleanExtra("inBookshelf", true)
|
||||||
ReadBook.chapterChanged = intent.getBooleanExtra("chapterChanged", false)
|
ReadBook.chapterChanged = intent.getBooleanExtra("chapterChanged", false)
|
||||||
val bookUrl = intent.getStringExtra("bookUrl")
|
val bookUrl = intent.getStringExtra("bookUrl")
|
||||||
@@ -2861,6 +2874,13 @@ class ReadBookViewModel(
|
|||||||
}
|
}
|
||||||
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
||||||
}
|
}
|
||||||
|
is ConfigUpdate.ReadBodyToLh -> {
|
||||||
|
ReadConfig.readBodyToLh = update.value
|
||||||
|
ReadBookConfig.readBodyToLh = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setReadBodyToLh(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
is ConfigUpdate.TextFullJustify -> {
|
is ConfigUpdate.TextFullJustify -> {
|
||||||
ReadBookConfig.textFullJustify = update.value
|
ReadBookConfig.textFullJustify = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
@@ -2949,6 +2969,55 @@ class ReadBookViewModel(
|
|||||||
}
|
}
|
||||||
_uiState.update { it.copy(styleConfig = buildStyleConfig()) }
|
_uiState.update { it.copy(styleConfig = buildStyleConfig()) }
|
||||||
}
|
}
|
||||||
|
is ConfigUpdate.MouseWheelPage -> {
|
||||||
|
ReadConfig.mouseWheelPage = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setMouseWheelPage(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.VolumeKeyPage -> {
|
||||||
|
ReadConfig.volumeKeyPage = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setVolumeKeyPage(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.VolumeKeyPageOnPlay -> {
|
||||||
|
ReadConfig.volumeKeyPageOnPlay = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setVolumeKeyPageOnPlay(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.KeyPageOnLongPress -> {
|
||||||
|
ReadConfig.keyPageOnLongPress = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setKeyPageOnLongPress(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.SliderVibrator -> {
|
||||||
|
ReadConfig.sliderVibrator = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setSliderVibrator(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.SelectVibrator -> {
|
||||||
|
ReadConfig.selectVibrator = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setSelectVibrator(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.AutoChangeSource -> {
|
||||||
|
ReadConfig.autoChangeSource = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setAutoChangeSource(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.SelectText -> {
|
||||||
|
ReadConfig.selectText = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setSelectText(update.value)
|
||||||
|
}
|
||||||
|
_effects.tryEmit(ReadBookEffect.UpTextSelectAble(update.value))
|
||||||
|
}
|
||||||
is ConfigUpdate.NoAnimScrollPage -> {
|
is ConfigUpdate.NoAnimScrollPage -> {
|
||||||
ReadConfig.noAnimScrollPage = update.value
|
ReadConfig.noAnimScrollPage = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
@@ -2956,7 +3025,32 @@ class ReadBookViewModel(
|
|||||||
}
|
}
|
||||||
_effects.tryEmit(ReadBookEffect.UpPageAnim(upRecorder = false))
|
_effects.tryEmit(ReadBookEffect.UpPageAnim(upRecorder = false))
|
||||||
}
|
}
|
||||||
|
is ConfigUpdate.OptimizeRender -> {
|
||||||
|
ReadConfig.optimizeRender = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setOptimizeRender(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.ClickImgWay -> {
|
||||||
|
ReadConfig.clickImgWay = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setClickImgWay(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.DisableReturnKey -> {
|
||||||
|
ReadConfig.disableReturnKey = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setDisableReturnKey(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ConfigUpdate.ExpandTextMenu -> {
|
||||||
|
ReadConfig.expandTextMenu = update.value
|
||||||
|
viewModelScope.launch {
|
||||||
|
readSettingsRepository.setExpandTextMenu(update.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
is ConfigUpdate.ShowReadTitleAddition -> {
|
is ConfigUpdate.ShowReadTitleAddition -> {
|
||||||
|
ReadConfig.showReadTitleAddition = update.value
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
readSettingsRepository.setShowReadTitleAddition(update.value)
|
readSettingsRepository.setShowReadTitleAddition(update.value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import androidx.compose.foundation.rememberScrollState
|
|||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringArrayResource
|
import androidx.compose.ui.res.stringArrayResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
@@ -23,7 +22,6 @@ import io.legado.app.ui.widget.components.modalBottomSheet.AppModalBottomSheet
|
|||||||
import io.legado.app.ui.widget.components.settingItem.TinyClickableSettingItem
|
import io.legado.app.ui.widget.components.settingItem.TinyClickableSettingItem
|
||||||
import io.legado.app.ui.widget.components.settingItem.TinyDropdownSettingItem
|
import io.legado.app.ui.widget.components.settingItem.TinyDropdownSettingItem
|
||||||
import io.legado.app.ui.widget.components.settingItem.TinySwitchSettingItem
|
import io.legado.app.ui.widget.components.settingItem.TinySwitchSettingItem
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import org.koin.compose.koinInject
|
import org.koin.compose.koinInject
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -38,7 +36,6 @@ fun MoreConfigSheet(
|
|||||||
val preferences by readSettingsRepository.preferences.collectAsStateWithLifecycle(
|
val preferences by readSettingsRepository.preferences.collectAsStateWithLifecycle(
|
||||||
initialValue = ReadPreferences()
|
initialValue = ReadPreferences()
|
||||||
)
|
)
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
|
|
||||||
AppModalBottomSheet(
|
AppModalBottomSheet(
|
||||||
show = show,
|
show = show,
|
||||||
@@ -57,11 +54,9 @@ fun MoreConfigSheet(
|
|||||||
preferences = preferences,
|
preferences = preferences,
|
||||||
onScreenOrientationChange = {
|
onScreenOrientationChange = {
|
||||||
onIntent(ReadBookIntent.SetOrientation(it))
|
onIntent(ReadBookIntent.SetOrientation(it))
|
||||||
scope.launch { readSettingsRepository.setScreenOrientation(it) }
|
|
||||||
},
|
},
|
||||||
onKeepLightChange = {
|
onKeepLightChange = {
|
||||||
onIntent(ReadBookIntent.KeepLightChanged(it))
|
onIntent(ReadBookIntent.KeepLightChanged(it))
|
||||||
scope.launch { readSettingsRepository.setKeepLight(it) }
|
|
||||||
},
|
},
|
||||||
onHideStatusBarChange = {
|
onHideStatusBarChange = {
|
||||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.HideStatusBar(it)))
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.HideStatusBar(it)))
|
||||||
@@ -73,7 +68,7 @@ fun MoreConfigSheet(
|
|||||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.PaddingDisplayCutouts(it)))
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.PaddingDisplayCutouts(it)))
|
||||||
},
|
},
|
||||||
onReadBodyToLhChange = {
|
onReadBodyToLhChange = {
|
||||||
scope.launch { readSettingsRepository.setReadBodyToLh(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ReadBodyToLh(it)))
|
||||||
},
|
},
|
||||||
onTextFullJustifyChange = {
|
onTextFullJustifyChange = {
|
||||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TextFullJustify(it)))
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.TextFullJustify(it)))
|
||||||
@@ -103,16 +98,16 @@ fun MoreConfigSheet(
|
|||||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ProgressBarBehavior(it)))
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ProgressBarBehavior(it)))
|
||||||
},
|
},
|
||||||
onMouseWheelPageChange = {
|
onMouseWheelPageChange = {
|
||||||
scope.launch { readSettingsRepository.setMouseWheelPage(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.MouseWheelPage(it)))
|
||||||
},
|
},
|
||||||
onVolumeKeyPageChange = {
|
onVolumeKeyPageChange = {
|
||||||
scope.launch { readSettingsRepository.setVolumeKeyPage(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.VolumeKeyPage(it)))
|
||||||
},
|
},
|
||||||
onVolumeKeyPageOnPlayChange = {
|
onVolumeKeyPageOnPlayChange = {
|
||||||
scope.launch { readSettingsRepository.setVolumeKeyPageOnPlay(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.VolumeKeyPageOnPlay(it)))
|
||||||
},
|
},
|
||||||
onKeyPageOnLongPressChange = {
|
onKeyPageOnLongPressChange = {
|
||||||
scope.launch { readSettingsRepository.setKeyPageOnLongPress(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.KeyPageOnLongPress(it)))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -121,30 +116,33 @@ fun MoreConfigSheet(
|
|||||||
OtherSettings(
|
OtherSettings(
|
||||||
preferences = preferences,
|
preferences = preferences,
|
||||||
onSliderVibratorChange = {
|
onSliderVibratorChange = {
|
||||||
scope.launch { readSettingsRepository.setSliderVibrator(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.SliderVibrator(it)))
|
||||||
},
|
},
|
||||||
onSelectVibratorChange = {
|
onSelectVibratorChange = {
|
||||||
scope.launch { readSettingsRepository.setSelectVibrator(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.SelectVibrator(it)))
|
||||||
},
|
},
|
||||||
onAutoChangeSourceChange = {
|
onAutoChangeSourceChange = {
|
||||||
scope.launch { readSettingsRepository.setAutoChangeSource(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.AutoChangeSource(it)))
|
||||||
},
|
},
|
||||||
onSelectTextChange = {
|
onSelectTextChange = {
|
||||||
scope.launch { readSettingsRepository.setSelectText(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.SelectText(it)))
|
||||||
},
|
},
|
||||||
onNoAnimScrollPageChange = {
|
onNoAnimScrollPageChange = {
|
||||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.NoAnimScrollPage(it)))
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.NoAnimScrollPage(it)))
|
||||||
},
|
},
|
||||||
|
onOptimizeRenderChange = {
|
||||||
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.OptimizeRender(it)))
|
||||||
|
},
|
||||||
onClickImgWayChange = {
|
onClickImgWayChange = {
|
||||||
scope.launch { readSettingsRepository.setClickImgWay(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ClickImgWay(it)))
|
||||||
},
|
},
|
||||||
onOpenClickRegionalConfig = onOpenClickRegionalConfig,
|
onOpenClickRegionalConfig = onOpenClickRegionalConfig,
|
||||||
onDisableReturnKeyChange = {
|
onDisableReturnKeyChange = {
|
||||||
scope.launch { readSettingsRepository.setDisableReturnKey(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.DisableReturnKey(it)))
|
||||||
},
|
},
|
||||||
onOpenPageKeyConfig = onOpenPageKeyConfig,
|
onOpenPageKeyConfig = onOpenPageKeyConfig,
|
||||||
onExpandTextMenuChange = {
|
onExpandTextMenuChange = {
|
||||||
scope.launch { readSettingsRepository.setExpandTextMenu(it) }
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ExpandTextMenu(it)))
|
||||||
},
|
},
|
||||||
onShowReadTitleAdditionChange = {
|
onShowReadTitleAdditionChange = {
|
||||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ShowReadTitleAddition(it)))
|
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ShowReadTitleAddition(it)))
|
||||||
@@ -294,6 +292,7 @@ private fun OtherSettings(
|
|||||||
onAutoChangeSourceChange: (Boolean) -> Unit,
|
onAutoChangeSourceChange: (Boolean) -> Unit,
|
||||||
onSelectTextChange: (Boolean) -> Unit,
|
onSelectTextChange: (Boolean) -> Unit,
|
||||||
onNoAnimScrollPageChange: (Boolean) -> Unit,
|
onNoAnimScrollPageChange: (Boolean) -> Unit,
|
||||||
|
onOptimizeRenderChange: (Boolean) -> Unit,
|
||||||
onClickImgWayChange: (String) -> Unit,
|
onClickImgWayChange: (String) -> Unit,
|
||||||
onOpenClickRegionalConfig: () -> Unit,
|
onOpenClickRegionalConfig: () -> Unit,
|
||||||
onDisableReturnKeyChange: (Boolean) -> Unit,
|
onDisableReturnKeyChange: (Boolean) -> Unit,
|
||||||
@@ -329,6 +328,11 @@ private fun OtherSettings(
|
|||||||
checked = preferences.noAnimScrollPage,
|
checked = preferences.noAnimScrollPage,
|
||||||
onCheckedChange = onNoAnimScrollPageChange,
|
onCheckedChange = onNoAnimScrollPageChange,
|
||||||
)
|
)
|
||||||
|
TinySwitchSettingItem(
|
||||||
|
title = stringResource(R.string.enable_optimize_render),
|
||||||
|
checked = preferences.optimizeRender,
|
||||||
|
onCheckedChange = onOptimizeRenderChange,
|
||||||
|
)
|
||||||
TinyDropdownSettingItem(
|
TinyDropdownSettingItem(
|
||||||
title = stringResource(R.string.click_image_way),
|
title = stringResource(R.string.click_image_way),
|
||||||
selectedValue = preferences.clickImgWay,
|
selectedValue = preferences.clickImgWay,
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ object ReadConfig {
|
|||||||
optimizeRender = preferences.optimizeRender
|
optimizeRender = preferences.optimizeRender
|
||||||
adaptSpecialStyle = preferences.adaptSpecialStyle
|
adaptSpecialStyle = preferences.adaptSpecialStyle
|
||||||
useUnderline = preferences.useUnderline
|
useUnderline = preferences.useUnderline
|
||||||
|
keepLight = preferences.keepLight
|
||||||
brightnessVwPos = preferences.brightnessVwPos
|
brightnessVwPos = preferences.brightnessVwPos
|
||||||
readBrightness = preferences.readBrightness
|
readBrightness = preferences.readBrightness
|
||||||
brightnessAuto = preferences.brightnessAuto
|
brightnessAuto = preferences.brightnessAuto
|
||||||
@@ -110,6 +111,7 @@ object ReadConfig {
|
|||||||
clickActionBC = preferences.clickActionBC
|
clickActionBC = preferences.clickActionBC
|
||||||
clickActionBR = preferences.clickActionBR
|
clickActionBR = preferences.clickActionBR
|
||||||
screenOrientation = preferences.screenOrientation
|
screenOrientation = preferences.screenOrientation
|
||||||
|
readBodyToLh = preferences.readBodyToLh
|
||||||
noAnimScrollPage = preferences.noAnimScrollPage
|
noAnimScrollPage = preferences.noAnimScrollPage
|
||||||
tocUiUseReplace = preferences.tocUiUseReplace
|
tocUiUseReplace = preferences.tocUiUseReplace
|
||||||
tocCountWords = preferences.tocCountWords
|
tocCountWords = preferences.tocCountWords
|
||||||
@@ -123,6 +125,9 @@ object ReadConfig {
|
|||||||
mouseWheelPage = preferences.mouseWheelPage
|
mouseWheelPage = preferences.mouseWheelPage
|
||||||
paddingDisplayCutouts = preferences.paddingDisplayCutouts
|
paddingDisplayCutouts = preferences.paddingDisplayCutouts
|
||||||
pageTouchSlop = preferences.pageTouchSlop
|
pageTouchSlop = preferences.pageTouchSlop
|
||||||
|
selectText = preferences.selectText
|
||||||
|
disableReturnKey = preferences.disableReturnKey
|
||||||
|
expandTextMenu = preferences.expandTextMenu
|
||||||
showReadTitleAddition = preferences.showReadTitleAddition
|
showReadTitleAddition = preferences.showReadTitleAddition
|
||||||
titleBarMode = preferences.titleBarMode
|
titleBarMode = preferences.titleBarMode
|
||||||
menuAlpha = preferences.menuAlpha
|
menuAlpha = preferences.menuAlpha
|
||||||
@@ -144,15 +149,9 @@ object ReadConfig {
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
var screenOrientation by prefDelegate(
|
var screenOrientation: String = "0"
|
||||||
PreferKey.screenOrientation,
|
|
||||||
"0"
|
|
||||||
)
|
|
||||||
|
|
||||||
var keepLight by prefDelegate(
|
var keepLight: String = "0"
|
||||||
PreferKey.keepLight,
|
|
||||||
"0"
|
|
||||||
)
|
|
||||||
|
|
||||||
var hideStatusBar by prefDelegate(
|
var hideStatusBar by prefDelegate(
|
||||||
PreferKey.hideStatusBar,
|
PreferKey.hideStatusBar,
|
||||||
@@ -164,25 +163,13 @@ object ReadConfig {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
var paddingDisplayCutouts by prefDelegate(
|
var paddingDisplayCutouts: Boolean = false
|
||||||
PreferKey.paddingDisplayCutouts,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
var titleBarMode by prefDelegate(
|
var titleBarMode: String = "1"
|
||||||
PreferKey.titleBarMode,
|
|
||||||
"1"
|
|
||||||
)
|
|
||||||
|
|
||||||
var menuAlpha by prefDelegate(
|
var menuAlpha: Int = 100
|
||||||
PreferKey.menuAlpha,
|
|
||||||
100
|
|
||||||
)
|
|
||||||
|
|
||||||
var readBodyToLh by prefDelegate(
|
var readBodyToLh: Boolean = true
|
||||||
PreferKey.readBodyToLh,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
var defaultSourceChangeAll by prefDelegate(
|
var defaultSourceChangeAll by prefDelegate(
|
||||||
PreferKey.defaultSourceChangeAll,
|
PreferKey.defaultSourceChangeAll,
|
||||||
@@ -199,10 +186,7 @@ object ReadConfig {
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
var adaptSpecialStyle by prefDelegate(
|
var adaptSpecialStyle: Boolean = true
|
||||||
PreferKey.adaptSpecialStyle,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
var useZhLayout by prefDelegate(
|
var useZhLayout by prefDelegate(
|
||||||
PreferKey.useZhLayout,
|
PreferKey.useZhLayout,
|
||||||
@@ -229,100 +213,46 @@ object ReadConfig {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
var useUnderline by prefDelegate(
|
var useUnderline: Boolean = false
|
||||||
PreferKey.useUnderline,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
var readSliderMode by prefDelegate(
|
var readSliderMode: String = "0"
|
||||||
PreferKey.readSliderMode,
|
|
||||||
"0"
|
|
||||||
)
|
|
||||||
|
|
||||||
var doubleHorizontalPage by prefDelegate(
|
var doubleHorizontalPage: String = "0"
|
||||||
PreferKey.doublePageHorizontal,
|
|
||||||
"0"
|
|
||||||
)
|
|
||||||
|
|
||||||
var progressBarBehavior by prefDelegate(
|
var progressBarBehavior: String = "page"
|
||||||
PreferKey.progressBarBehavior,
|
|
||||||
"page"
|
|
||||||
)
|
|
||||||
|
|
||||||
var mouseWheelPage by prefDelegate(
|
var mouseWheelPage: Boolean = true
|
||||||
PreferKey.mouseWheelPage,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
var volumeKeyPage by prefDelegate(
|
var volumeKeyPage: Boolean = true
|
||||||
PreferKey.volumeKeyPage,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
var volumeKeyPageOnPlay by prefDelegate(
|
var volumeKeyPageOnPlay: Boolean = true
|
||||||
PreferKey.volumeKeyPageOnPlay,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
var keyPageOnLongPress by prefDelegate(
|
var keyPageOnLongPress: Boolean = false
|
||||||
PreferKey.keyPageOnLongPress,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
var pageTouchSlop by prefDelegate(
|
var pageTouchSlop by prefDelegate(
|
||||||
PreferKey.pageTouchSlop,
|
PreferKey.pageTouchSlop,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
var sliderVibrator by prefDelegate(
|
var sliderVibrator: Boolean = false
|
||||||
PreferKey.sliderVibrator,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
var selectVibrator by prefDelegate(
|
var selectVibrator: Boolean = false
|
||||||
PreferKey.selectVibrator,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
var autoChangeSource by prefDelegate(
|
var autoChangeSource: Boolean = true
|
||||||
PreferKey.autoChangeSource,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
var selectText by prefDelegate(
|
var selectText: Boolean = true
|
||||||
PreferKey.selectText,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
var noAnimScrollPage by prefDelegate(
|
var noAnimScrollPage: Boolean = false
|
||||||
PreferKey.noAnimScrollPage,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
var clickImgWay by prefDelegate(
|
var clickImgWay: String = "2"
|
||||||
PreferKey.clickImgWay,
|
|
||||||
"2"
|
|
||||||
)
|
|
||||||
|
|
||||||
var optimizeRender by prefDelegate(
|
var optimizeRender: Boolean = false
|
||||||
PreferKey.optimizeRender,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
var disableReturnKey by prefDelegate(
|
var disableReturnKey: Boolean = false
|
||||||
PreferKey.disableReturnKey,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
var expandTextMenu by prefDelegate(
|
var expandTextMenu: Boolean = false
|
||||||
PreferKey.expandTextMenu,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
|
|
||||||
var showReadTitleAddition by prefDelegate(
|
var showReadTitleAddition: Boolean = true
|
||||||
PreferKey.showReadTitleAddition,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
|
|
||||||
var clickActionTL by prefDelegate(
|
var clickActionTL by prefDelegate(
|
||||||
PreferKey.clickActionTL,
|
PreferKey.clickActionTL,
|
||||||
|
|||||||
@@ -28,10 +28,12 @@ class ReadConfigViewModel(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
when (intent) {
|
when (intent) {
|
||||||
is ReadConfigIntent.ScreenOrientationChanged -> {
|
is ReadConfigIntent.ScreenOrientationChanged -> {
|
||||||
|
ReadConfig.screenOrientation = intent.value
|
||||||
readSettingsRepository.setScreenOrientation(intent.value)
|
readSettingsRepository.setScreenOrientation(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.KeepLightChanged -> {
|
is ReadConfigIntent.KeepLightChanged -> {
|
||||||
|
ReadConfig.keepLight = intent.value
|
||||||
readSettingsRepository.setKeepLight(intent.value)
|
readSettingsRepository.setKeepLight(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,19 +50,24 @@ class ReadConfigViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.PaddingDisplayCutoutsChanged -> {
|
is ReadConfigIntent.PaddingDisplayCutoutsChanged -> {
|
||||||
|
ReadConfig.paddingDisplayCutouts = intent.value
|
||||||
readSettingsRepository.setPaddingDisplayCutouts(intent.value)
|
readSettingsRepository.setPaddingDisplayCutouts(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.TitleBarModeChanged -> {
|
is ReadConfigIntent.TitleBarModeChanged -> {
|
||||||
|
ReadConfig.titleBarMode = intent.value
|
||||||
readSettingsRepository.setTitleBarMode(intent.value)
|
readSettingsRepository.setTitleBarMode(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.MenuAlphaChanged -> {
|
is ReadConfigIntent.MenuAlphaChanged -> {
|
||||||
|
ReadConfig.menuAlpha = intent.value
|
||||||
readSettingsRepository.setMenuAlpha(intent.value)
|
readSettingsRepository.setMenuAlpha(intent.value)
|
||||||
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.ReadBodyToLhChanged -> {
|
is ReadConfigIntent.ReadBodyToLhChanged -> {
|
||||||
|
ReadConfig.readBodyToLh = intent.value
|
||||||
|
ReadBookConfig.readBodyToLh = intent.value
|
||||||
readSettingsRepository.setReadBodyToLh(intent.value)
|
readSettingsRepository.setReadBodyToLh(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +86,7 @@ class ReadConfigViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.AdaptSpecialStyleChanged -> {
|
is ReadConfigIntent.AdaptSpecialStyleChanged -> {
|
||||||
|
ReadConfig.adaptSpecialStyle = intent.value
|
||||||
readSettingsRepository.setAdaptSpecialStyle(intent.value)
|
readSettingsRepository.setAdaptSpecialStyle(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,37 +105,45 @@ class ReadConfigViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.UseUnderlineChanged -> {
|
is ReadConfigIntent.UseUnderlineChanged -> {
|
||||||
|
ReadConfig.useUnderline = intent.value
|
||||||
readSettingsRepository.setUseUnderline(intent.value)
|
readSettingsRepository.setUseUnderline(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.ReadSliderModeChanged -> {
|
is ReadConfigIntent.ReadSliderModeChanged -> {
|
||||||
|
ReadConfig.readSliderMode = intent.value
|
||||||
readSettingsRepository.setReadSliderMode(intent.value)
|
readSettingsRepository.setReadSliderMode(intent.value)
|
||||||
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.DoubleHorizontalPageChanged -> {
|
is ReadConfigIntent.DoubleHorizontalPageChanged -> {
|
||||||
|
ReadConfig.doubleHorizontalPage = intent.value
|
||||||
readSettingsRepository.setDoubleHorizontalPage(intent.value)
|
readSettingsRepository.setDoubleHorizontalPage(intent.value)
|
||||||
upLayout()
|
upLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.ProgressBarBehaviorChanged -> {
|
is ReadConfigIntent.ProgressBarBehaviorChanged -> {
|
||||||
|
ReadConfig.progressBarBehavior = intent.value
|
||||||
readSettingsRepository.setProgressBarBehavior(intent.value)
|
readSettingsRepository.setProgressBarBehavior(intent.value)
|
||||||
postEvent(EventBus.UP_SEEK_BAR, true)
|
postEvent(EventBus.UP_SEEK_BAR, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.MouseWheelPageChanged -> {
|
is ReadConfigIntent.MouseWheelPageChanged -> {
|
||||||
|
ReadConfig.mouseWheelPage = intent.value
|
||||||
readSettingsRepository.setMouseWheelPage(intent.value)
|
readSettingsRepository.setMouseWheelPage(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.VolumeKeyPageChanged -> {
|
is ReadConfigIntent.VolumeKeyPageChanged -> {
|
||||||
|
ReadConfig.volumeKeyPage = intent.value
|
||||||
readSettingsRepository.setVolumeKeyPage(intent.value)
|
readSettingsRepository.setVolumeKeyPage(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.VolumeKeyPageOnPlayChanged -> {
|
is ReadConfigIntent.VolumeKeyPageOnPlayChanged -> {
|
||||||
|
ReadConfig.volumeKeyPageOnPlay = intent.value
|
||||||
readSettingsRepository.setVolumeKeyPageOnPlay(intent.value)
|
readSettingsRepository.setVolumeKeyPageOnPlay(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.KeyPageOnLongPressChanged -> {
|
is ReadConfigIntent.KeyPageOnLongPressChanged -> {
|
||||||
|
ReadConfig.keyPageOnLongPress = intent.value
|
||||||
readSettingsRepository.setKeyPageOnLongPress(intent.value)
|
readSettingsRepository.setKeyPageOnLongPress(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,18 +153,22 @@ class ReadConfigViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.SliderVibratorChanged -> {
|
is ReadConfigIntent.SliderVibratorChanged -> {
|
||||||
|
ReadConfig.sliderVibrator = intent.value
|
||||||
readSettingsRepository.setSliderVibrator(intent.value)
|
readSettingsRepository.setSliderVibrator(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.SelectVibratorChanged -> {
|
is ReadConfigIntent.SelectVibratorChanged -> {
|
||||||
|
ReadConfig.selectVibrator = intent.value
|
||||||
readSettingsRepository.setSelectVibrator(intent.value)
|
readSettingsRepository.setSelectVibrator(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.AutoChangeSourceChanged -> {
|
is ReadConfigIntent.AutoChangeSourceChanged -> {
|
||||||
|
ReadConfig.autoChangeSource = intent.value
|
||||||
readSettingsRepository.setAutoChangeSource(intent.value)
|
readSettingsRepository.setAutoChangeSource(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.SelectTextChanged -> {
|
is ReadConfigIntent.SelectTextChanged -> {
|
||||||
|
ReadConfig.selectText = intent.value
|
||||||
readSettingsRepository.setSelectText(intent.value)
|
readSettingsRepository.setSelectText(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,23 +178,28 @@ class ReadConfigViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.ClickImgWayChanged -> {
|
is ReadConfigIntent.ClickImgWayChanged -> {
|
||||||
|
ReadConfig.clickImgWay = intent.value
|
||||||
readSettingsRepository.setClickImgWay(intent.value)
|
readSettingsRepository.setClickImgWay(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.OptimizeRenderChanged -> {
|
is ReadConfigIntent.OptimizeRenderChanged -> {
|
||||||
|
ReadConfig.optimizeRender = intent.value
|
||||||
readSettingsRepository.setOptimizeRender(intent.value)
|
readSettingsRepository.setOptimizeRender(intent.value)
|
||||||
upStyle()
|
upStyle()
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.DisableReturnKeyChanged -> {
|
is ReadConfigIntent.DisableReturnKeyChanged -> {
|
||||||
|
ReadConfig.disableReturnKey = intent.value
|
||||||
readSettingsRepository.setDisableReturnKey(intent.value)
|
readSettingsRepository.setDisableReturnKey(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.ExpandTextMenuChanged -> {
|
is ReadConfigIntent.ExpandTextMenuChanged -> {
|
||||||
|
ReadConfig.expandTextMenu = intent.value
|
||||||
readSettingsRepository.setExpandTextMenu(intent.value)
|
readSettingsRepository.setExpandTextMenu(intent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadConfigIntent.ShowReadTitleAdditionChanged -> {
|
is ReadConfigIntent.ShowReadTitleAdditionChanged -> {
|
||||||
|
ReadConfig.showReadTitleAddition = intent.value
|
||||||
readSettingsRepository.setShowReadTitleAddition(intent.value)
|
readSettingsRepository.setShowReadTitleAddition(intent.value)
|
||||||
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user