|
@@ -22,8 +22,7 @@ import androidx.compose.ui.res.stringResource
|
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|
|
import io.legado.app.R
|
|
import io.legado.app.R
|
|
|
-import io.legado.app.constant.PreferKey
|
|
|
|
|
-import io.legado.app.help.config.DsSync
|
|
|
|
|
|
|
+import io.legado.app.constant.EventBus
|
|
|
import io.legado.app.service.WebService
|
|
import io.legado.app.service.WebService
|
|
|
import io.legado.app.ui.config.readMangaConfig.ReadMangaConfig
|
|
import io.legado.app.ui.config.readMangaConfig.ReadMangaConfig
|
|
|
import io.legado.app.ui.theme.LegadoTheme
|
|
import io.legado.app.ui.theme.LegadoTheme
|
|
@@ -40,9 +39,8 @@ import io.legado.app.ui.widget.components.settingItem.SwitchSettingItem
|
|
|
import io.legado.app.ui.widget.components.topbar.GlassMediumFlexibleTopAppBar
|
|
import io.legado.app.ui.widget.components.topbar.GlassMediumFlexibleTopAppBar
|
|
|
import io.legado.app.ui.widget.components.topbar.GlassTopAppBarDefaults
|
|
import io.legado.app.ui.widget.components.topbar.GlassTopAppBarDefaults
|
|
|
import io.legado.app.ui.widget.components.topbar.TopBarNavigationButton
|
|
import io.legado.app.ui.widget.components.topbar.TopBarNavigationButton
|
|
|
-import io.legado.app.utils.restart
|
|
|
|
|
|
|
+import io.legado.app.utils.postEvent
|
|
|
import io.legado.app.utils.takePersistablePermissionSafely
|
|
import io.legado.app.utils.takePersistablePermissionSafely
|
|
|
-import kotlinx.coroutines.runBlocking
|
|
|
|
|
import org.koin.androidx.compose.koinViewModel
|
|
import org.koin.androidx.compose.koinViewModel
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@@ -107,10 +105,9 @@ fun OtherConfigScreen(
|
|
|
entryValues = stringArrayResource(R.array.language_value),
|
|
entryValues = stringArrayResource(R.array.language_value),
|
|
|
onValueChange = { newValue ->
|
|
onValueChange = { newValue ->
|
|
|
OtherConfig.language = newValue
|
|
OtherConfig.language = newValue
|
|
|
- // prefDelegate 的 DataStore 写入是异步的,restart() 会立刻杀进程,
|
|
|
|
|
- // 必须先同步落盘,否则下次启动从 DataStore 读回旧值,语言切换失效
|
|
|
|
|
- runBlocking { DsSync.putString(PreferKey.language, newValue) }
|
|
|
|
|
- context.restart()
|
|
|
|
|
|
|
+ // 与 fontScale 相同:locale 在各 Activity onCreate 的
|
|
|
|
|
+ // applyLocaleAndFont 里应用,原地重建即可生效,无需杀进程
|
|
|
|
|
+ postEvent(EventBus.RECREATE, "")
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
|