Fix predictive back crash after launch page change

https://issuetracker.google.com/384186542
This commit is contained in:
FooIbar committed 2025-05-27 22:34:41 +08:00
1 parent 809f628bc0
commit f74b8373e3
3 files changed
+4 -6

No files matched your search

@@ -107,6 +107,7 @@ object Settings : DataStorePreferences(null) {
var favCloudCount by intPref("fav_cloud", 0).emitTo(_favFlow)
val gallerySite = intPref("gallery_site_2", 0).observed { updateWhenGallerySiteChanges() }
val launchPage = intPref("launch_page_2", 0)
val listMode = intPref("list_mode_2", 0)
val detailSize = intPref("detail_size_2", 0)
val thumbColumns = intPref("thumb_columns", 3)
@@ -145,7 +146,6 @@ object Settings : DataStorePreferences(null) {
var timeoutSpeed by intPref("timeout_speed_level", 6)
var theme by intPref("theme_2", -1).observed { updateWhenThemeChanges() }
var readCacheSize by intPref("read_cache_size_2", 640)
var launchPage by intPref("launch_page_2", 0)
var commentThreshold by intPref("comment_threshold", -100)
var hardwareBitmapThreshold by intPref("hardware_bitmap_threshold", 16384)
var showComments by boolPref("show_gallery_comments", true)
@@ -173,9 +173,6 @@ private val navItems = arrayOf<Triple<Direction, Int, ImageVector>>(
Triple(SettingsScreenDestination, R.string.settings, Icons.Default.Settings),
)
val StartDestination
get() = navItems[Settings.launchPage].first
class MainActivity : EhActivity() {
private var shareUrl: String? = null
@@ -359,6 +356,7 @@ class MainActivity : EhActivity() {
val density = LocalDensity.current
val adaptiveInfo = currentWindowAdaptiveInfo()
val needSignIn by Settings.needSignIn.collectAsState()
val launchPage by Settings.launchPage.collectAsState()
CompositionLocalProvider(
LocalNavDrawerState provides navDrawerState,
LocalSideSheetState provides sideSheetState,
@@ -443,7 +441,7 @@ class MainActivity : EhActivity() {
CompositionLocalProvider(LocalSharedTransitionScope provides this) {
val start = when {
needSignIn -> SignInScreenDestination
hasNetwork -> StartDestination
hasNetwork -> navItems[launchPage].first
else -> DownloadsScreenDestination
}
DestinationsNavHost(
@@ -187,7 +187,7 @@ fun AnimatedVisibilityScope.EhScreen(navigator: DestinationsNavigator) = Screen(
title = stringResource(id = R.string.settings_eh_launch_page),
entry = R.array.launch_page_entries,
entryValueRes = R.array.launch_page_entry_values,
value = Settings::launchPage.observed,
value = Settings.launchPage.asMutableState(),
)
val listMode = Settings.listMode.asMutableState()
SimpleMenuPreferenceInt(