fix: 屏幕方向和屏幕超时设置切换后不立即生效
MoreConfigSheet 中屏幕方向和屏幕超时的变更只写入 DataStore,需经过 6 步异步传播(DataStore → Flow → ViewModel → Effect → Controller) 才能生效,导致: - 切换横屏后文字显示不全,仍保持竖屏布局 - 目录不跟随横屏显示 - 屏幕超时设置延迟生效 修复: - 新增 ReadBookIntent.SetOrientation 意图,直接写入 ReadConfig 并发射 Effect - 将 ReadBookIntent.KeepLightChanged 改为带值的 data class,同理直接生效 - MoreConfigSheet 在写 DataStore 的同时同步调用 onIntent,立即应用变更 - 新增反向横屏(REVERSE_LANDSCAPE)选项
This commit is contained in:
@@ -425,7 +425,8 @@ sealed interface ReadBookIntent {
|
|||||||
data class TextActionDict(val text: String) : ReadBookIntent
|
data class TextActionDict(val text: String) : ReadBookIntent
|
||||||
|
|
||||||
// Screen / selection config
|
// Screen / selection config
|
||||||
data object KeepLightChanged : ReadBookIntent
|
data class KeepLightChanged(val value: String) : ReadBookIntent
|
||||||
|
data class SetOrientation(val value: String) : ReadBookIntent
|
||||||
data class TextSelectAbleChanged(val enabled: Boolean) : ReadBookIntent
|
data class TextSelectAbleChanged(val enabled: Boolean) : ReadBookIntent
|
||||||
|
|
||||||
// Media / TTS
|
// Media / TTS
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import io.legado.app.domain.usecase.GetReadingProgressUseCase
|
|||||||
import io.legado.app.domain.usecase.UploadReadingProgressUseCase
|
import io.legado.app.domain.usecase.UploadReadingProgressUseCase
|
||||||
import io.legado.app.exception.NoStackTraceException
|
import io.legado.app.exception.NoStackTraceException
|
||||||
import io.legado.app.help.DefaultData
|
import io.legado.app.help.DefaultData
|
||||||
|
import io.legado.app.ui.config.readConfig.ReadConfig
|
||||||
import io.legado.app.help.book.BookHelp
|
import io.legado.app.help.book.BookHelp
|
||||||
import io.legado.app.help.book.ContentProcessor
|
import io.legado.app.help.book.ContentProcessor
|
||||||
import io.legado.app.help.book.isEpub
|
import io.legado.app.help.book.isEpub
|
||||||
@@ -581,7 +582,15 @@ class ReadBookViewModel(
|
|||||||
is ReadBookIntent.SaveMenuButtonConfig -> saveMenuButtonConfig(intent.items)
|
is ReadBookIntent.SaveMenuButtonConfig -> saveMenuButtonConfig(intent.items)
|
||||||
is ReadBookIntent.SaveTitleBarButtonConfig -> saveTitleBarButtonConfig(intent.items)
|
is ReadBookIntent.SaveTitleBarButtonConfig -> saveTitleBarButtonConfig(intent.items)
|
||||||
|
|
||||||
is ReadBookIntent.KeepLightChanged -> _effects.tryEmit(ReadBookEffect.UpScreenTimeOut)
|
is ReadBookIntent.KeepLightChanged -> {
|
||||||
|
ReadConfig.keepLight = intent.value
|
||||||
|
_readPreferences.update { it.copy(keepLight = intent.value) }
|
||||||
|
_effects.tryEmit(ReadBookEffect.UpScreenTimeOut)
|
||||||
|
}
|
||||||
|
is ReadBookIntent.SetOrientation -> {
|
||||||
|
ReadConfig.screenOrientation = intent.value
|
||||||
|
_effects.tryEmit(ReadBookEffect.SetOrientation)
|
||||||
|
}
|
||||||
is ReadBookIntent.TextSelectAbleChanged -> _effects.tryEmit(
|
is ReadBookIntent.TextSelectAbleChanged -> _effects.tryEmit(
|
||||||
ReadBookEffect.UpTextSelectAble(
|
ReadBookEffect.UpTextSelectAble(
|
||||||
intent.enabled
|
intent.enabled
|
||||||
|
|||||||
@@ -56,9 +56,11 @@ fun MoreConfigSheet(
|
|||||||
ScreenSettings(
|
ScreenSettings(
|
||||||
preferences = preferences,
|
preferences = preferences,
|
||||||
onScreenOrientationChange = {
|
onScreenOrientationChange = {
|
||||||
|
onIntent(ReadBookIntent.SetOrientation(it))
|
||||||
scope.launch { readSettingsRepository.setScreenOrientation(it) }
|
scope.launch { readSettingsRepository.setScreenOrientation(it) }
|
||||||
},
|
},
|
||||||
onKeepLightChange = {
|
onKeepLightChange = {
|
||||||
|
onIntent(ReadBookIntent.KeepLightChanged(it))
|
||||||
scope.launch { readSettingsRepository.setKeepLight(it) }
|
scope.launch { readSettingsRepository.setKeepLight(it) }
|
||||||
},
|
},
|
||||||
onHideStatusBarChange = {
|
onHideStatusBarChange = {
|
||||||
|
|||||||
@@ -1324,6 +1324,7 @@
|
|||||||
<string name="keep_enable">保留启用状态</string>
|
<string name="keep_enable">保留启用状态</string>
|
||||||
<string name="preview_image_by_click">点击预览图片</string>
|
<string name="preview_image_by_click">点击预览图片</string>
|
||||||
<string name="screen_portrait_reversed">反向竖屏</string>
|
<string name="screen_portrait_reversed">反向竖屏</string>
|
||||||
|
<string name="screen_landscape_reversed">反向横屏</string>
|
||||||
<string name="del_ruby_tag">删除ruby标签</string>
|
<string name="del_ruby_tag">删除ruby标签</string>
|
||||||
<string name="del_h_tag">删除h标签</string>
|
<string name="del_h_tag">删除h标签</string>
|
||||||
<string name="adjust_chapter_page">调整本章页数</string>
|
<string name="adjust_chapter_page">调整本章页数</string>
|
||||||
|
|||||||
@@ -1193,6 +1193,7 @@
|
|||||||
<string name="keep_enable">保留启用状态</string>
|
<string name="keep_enable">保留启用状态</string>
|
||||||
<string name="preview_image_by_click">点击预览图片</string>
|
<string name="preview_image_by_click">点击预览图片</string>
|
||||||
<string name="screen_portrait_reversed">反向竖屏</string>
|
<string name="screen_portrait_reversed">反向竖屏</string>
|
||||||
|
<string name="screen_landscape_reversed">反向橫屏</string>
|
||||||
<string name="del_ruby_tag">删除ruby标签</string>
|
<string name="del_ruby_tag">删除ruby标签</string>
|
||||||
<string name="del_h_tag">删除h标签</string>
|
<string name="del_h_tag">删除h标签</string>
|
||||||
<string name="adjust_chapter_page">调整本章页数</string>
|
<string name="adjust_chapter_page">调整本章页数</string>
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
<item>2</item>
|
<item>2</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
<item>4</item>
|
<item>4</item>
|
||||||
|
<item>5</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="click_image_way_value">
|
<string-array name="click_image_way_value">
|
||||||
|
|||||||
@@ -124,6 +124,7 @@
|
|||||||
<item>@string/screen_landscape</item>
|
<item>@string/screen_landscape</item>
|
||||||
<item>@string/screen_sensor</item>
|
<item>@string/screen_sensor</item>
|
||||||
<item>@string/screen_portrait_reversed</item>
|
<item>@string/screen_portrait_reversed</item>
|
||||||
|
<item>@string/screen_landscape_reversed</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="click_image_way_title">
|
<string-array name="click_image_way_title">
|
||||||
|
|||||||
@@ -1356,6 +1356,7 @@
|
|||||||
<string name="preview_image_by_click">Click to preview image</string>
|
<string name="preview_image_by_click">Click to preview image</string>
|
||||||
<string name="default_home_page">Default Homepage</string>
|
<string name="default_home_page">Default Homepage</string>
|
||||||
<string name="screen_portrait_reversed">Portrait Reversed</string>
|
<string name="screen_portrait_reversed">Portrait Reversed</string>
|
||||||
|
<string name="screen_landscape_reversed">Landscape Reversed</string>
|
||||||
<string name="del_ruby_tag">Delete ruby tag</string>
|
<string name="del_ruby_tag">Delete ruby tag</string>
|
||||||
<string name="del_h_tag">Delete h tag</string>
|
<string name="del_h_tag">Delete h tag</string>
|
||||||
<string name="adjust_chapter_page">Adjust of chapter page</string>
|
<string name="adjust_chapter_page">Adjust of chapter page</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user