fix: 修复阅读界面导航与朗读配置问题
This commit is contained in:
@@ -273,7 +273,8 @@ val appModule = module {
|
||||
readBookStyleConfigRepository = get(),
|
||||
readAloudSettingsRepository = get(),
|
||||
localPreferencesRepository = get(),
|
||||
highlightRuleRepository = get()
|
||||
highlightRuleRepository = get(),
|
||||
uploadRepository = get()
|
||||
)
|
||||
}
|
||||
viewModelOf(::ChangeCoverViewModel)
|
||||
|
||||
@@ -1048,7 +1048,7 @@ class ReadBookController(
|
||||
}
|
||||
|
||||
private fun upScreenTimeOut() {
|
||||
val keepLightPrefer = viewModel.readPreferences.value.keepLight.toIntOrNull() ?: 0
|
||||
val keepLightPrefer = ReadConfig.keepLight.toLongOrNull() ?: 0L
|
||||
screenTimeOut = keepLightPrefer * 1000L
|
||||
screenOffTimerStartInternal()
|
||||
}
|
||||
|
||||
@@ -2300,7 +2300,7 @@ private fun ReadMenuLiquidSlider(
|
||||
val animationScope = rememberCoroutineScope()
|
||||
var didDrag by remember { mutableStateOf(false) }
|
||||
val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
|
||||
val dampedDragAnimation = remember(animationScope) {
|
||||
val dampedDragAnimation = remember(animationScope, trackWidth, rangeStart, rangeEnd, isLtr) {
|
||||
DampedDragAnimation(
|
||||
animationScope = animationScope,
|
||||
initialValue = value(),
|
||||
@@ -3057,8 +3057,12 @@ private fun BrightnessBar(
|
||||
glassThumbEnabled: Boolean = false,
|
||||
) {
|
||||
val activity = LocalActivity.current
|
||||
var sliderValue by remember { mutableFloatStateOf(brightness.toFloat()) }
|
||||
var sliderDragging by remember { mutableStateOf(false) }
|
||||
var sliderValue by remember(vertical, buttonGlassEnabled) {
|
||||
mutableFloatStateOf(brightness.toFloat())
|
||||
}
|
||||
var sliderDragging by remember(vertical, buttonGlassEnabled) {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
|
||||
LaunchedEffect(brightness, brightnessAuto) {
|
||||
if (brightnessAuto) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import io.legado.app.data.repository.ReadAloudSettingsRepository
|
||||
import io.legado.app.data.repository.ReadBookStyleConfigRepository
|
||||
import io.legado.app.data.repository.ReadPreferences
|
||||
import io.legado.app.data.repository.ReadSettingsRepository
|
||||
import io.legado.app.data.repository.UploadRepository
|
||||
import io.legado.app.domain.model.ReadingProgress
|
||||
import io.legado.app.domain.usecase.GetReadingProgressUseCase
|
||||
import io.legado.app.domain.usecase.UploadReadingProgressUseCase
|
||||
@@ -137,6 +138,7 @@ class ReadBookViewModel(
|
||||
private val readAloudSettingsRepository: ReadAloudSettingsRepository,
|
||||
private val localPreferencesRepository: LocalPreferencesRepository,
|
||||
private val highlightRuleRepository: HighlightRuleRepository,
|
||||
private val uploadRepository: UploadRepository,
|
||||
) : BaseViewModel(application), ReadBook.CallBack {
|
||||
|
||||
// --- MVI State ---
|
||||
@@ -847,11 +849,12 @@ class ReadBookViewModel(
|
||||
is ReadBookIntent.ExportAllHttpTtsAsUrl -> {
|
||||
execute {
|
||||
val json = exportHttpTtsJson()
|
||||
val dataUrl = "data:application/json;base64," + Base64.encodeToString(
|
||||
json.toByteArray(Charsets.UTF_8),
|
||||
Base64.NO_WRAP
|
||||
val url = uploadRepository.upload(
|
||||
fileName = "httpTTS.json",
|
||||
file = json,
|
||||
contentType = "application/json"
|
||||
)
|
||||
"legado://import/httpTTS?src=" + URLEncoder.encode(dataUrl, "UTF-8")
|
||||
"legado://import/httpTTS?src=" + URLEncoder.encode(url, "UTF-8")
|
||||
}.onSuccess { url ->
|
||||
context.sendToClip(url)
|
||||
_effects.tryEmit(ReadBookEffect.ShowToast(context.getString(R.string.copy_url)))
|
||||
@@ -2024,15 +2027,6 @@ class ReadBookViewModel(
|
||||
ReadBook.resetData(book)
|
||||
}
|
||||
_uiState.update { it.copy(isInitFinish = true) }
|
||||
// 旋转后 ChapterProvider 的 doublePage/visibleWidth 已在 onSizeChanged 中更新,
|
||||
// 但 ReloadContent 因 isInitFinish=false 被跳过。此处确保内容用新布局重新加载。
|
||||
if (isSameBook) {
|
||||
_effects.tryEmit(
|
||||
ReadBookEffect.UpdateReadViewConfig(
|
||||
setOf(ConfigUpdateAction.UpdateLayout, ConfigUpdateAction.ReloadContent)
|
||||
)
|
||||
)
|
||||
}
|
||||
if (!book.isLocal && book.tocUrl.isEmpty() && !loadBookInfo(book)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ fun ContentEditSheet(
|
||||
pendingLocateOffset = null
|
||||
return@LaunchedEffect
|
||||
}
|
||||
val offset = locateOffset.coerceIn(0, layoutTextLength)
|
||||
val offset = locateOffset.coerceIn(0, layoutTextLength - 1)
|
||||
val cursorTop = layoutResult.getCursorRect(offset).top.toInt()
|
||||
editorScrollState.scrollTo((cursorTop - 120).coerceIn(0, editorScrollState.maxValue))
|
||||
pendingLocateOffset = null
|
||||
|
||||
@@ -5,10 +5,18 @@ import android.content.Intent
|
||||
import androidx.navigation3.runtime.NavKey
|
||||
import io.legado.app.ui.rss.article.MainRouteRssSort
|
||||
import io.legado.app.ui.rss.read.MainRouteRssRead
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
object MainNavigator {
|
||||
|
||||
private var backNavigationInProgress = false
|
||||
private val navigationScope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
|
||||
private var backNavigationResetJob: Job? = null
|
||||
|
||||
fun navigateToRoute(backStack: MutableList<NavKey>, route: NavKey) {
|
||||
val currentRoute = backStack.lastOrNull()
|
||||
@@ -186,8 +194,8 @@ object MainNavigator {
|
||||
if (backNavigationInProgress) {
|
||||
return
|
||||
}
|
||||
backNavigationInProgress = true
|
||||
if (backStack.size > 1) {
|
||||
backNavigationInProgress = true
|
||||
backStack.removeLastOrNull()
|
||||
} else {
|
||||
activity.finish()
|
||||
@@ -195,7 +203,11 @@ object MainNavigator {
|
||||
}
|
||||
|
||||
fun onBackStackChanged() {
|
||||
backNavigationInProgress = false
|
||||
backNavigationResetJob?.cancel()
|
||||
backNavigationResetJob = navigationScope.launch {
|
||||
delay(500)
|
||||
backNavigationInProgress = false
|
||||
}
|
||||
}
|
||||
|
||||
fun resolveStartRoute(intent: Intent?): NavKey {
|
||||
|
||||
Reference in New Issue
Block a user