diff --git a/app/src/main/java/com/github/jing332/alistandroid/config/AppConfig.kt b/app/src/main/java/com/github/jing332/alistandroid/config/AppConfig.kt index 4269bd4..7410db7 100644 --- a/app/src/main/java/com/github/jing332/alistandroid/config/AppConfig.kt +++ b/app/src/main/java/com/github/jing332/alistandroid/config/AppConfig.kt @@ -27,4 +27,10 @@ object AppConfig { initialValue = false ) + var autoOpenWebPage = mutableDataSaverStateOf( + dataSaverInterface = pref, + key = "autoOpenWebPage", + initialValue = false + ) + } \ No newline at end of file diff --git a/app/src/main/java/com/github/jing332/alistandroid/ui/nav/NavigationGraph.kt b/app/src/main/java/com/github/jing332/alistandroid/ui/nav/NavigationGraph.kt index 01bf9bd..a83ad58 100644 --- a/app/src/main/java/com/github/jing332/alistandroid/ui/nav/NavigationGraph.kt +++ b/app/src/main/java/com/github/jing332/alistandroid/ui/nav/NavigationGraph.kt @@ -5,6 +5,7 @@ import androidx.compose.ui.Modifier import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable +import com.github.jing332.alistandroid.config.AppConfig import com.github.jing332.alistandroid.ui.nav.alist.AListScreen import com.github.jing332.alistandroid.ui.nav.config.AListConfigScreen import com.github.jing332.alistandroid.ui.nav.provider.AListProviderScreen @@ -13,7 +14,11 @@ import com.github.jing332.alistandroid.ui.nav.web.WebScreen @Composable fun NavigationGraph(navController: NavHostController, modifier: Modifier) { - NavHost(navController, startDestination = BottomNavRoute.AList.id, modifier = modifier) { + NavHost( + navController, + startDestination = if (AppConfig.autoOpenWebPage.value) BottomNavRoute.Web.id else BottomNavRoute.AList.id, + modifier = modifier + ) { composable(BottomNavRoute.AListConfig.id) { AListConfigScreen() } diff --git a/app/src/main/java/com/github/jing332/alistandroid/ui/nav/settings/SettingsScreen.kt b/app/src/main/java/com/github/jing332/alistandroid/ui/nav/settings/SettingsScreen.kt index 90c813c..36082f0 100644 --- a/app/src/main/java/com/github/jing332/alistandroid/ui/nav/settings/SettingsScreen.kt +++ b/app/src/main/java/com/github/jing332/alistandroid/ui/nav/settings/SettingsScreen.kt @@ -17,6 +17,7 @@ import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowCircleUp import androidx.compose.material.icons.filled.FilePresent +import androidx.compose.material.icons.filled.HdrAuto import androidx.compose.material.icons.filled.ScreenLockPortrait import androidx.compose.material.icons.filled.SupervisorAccount import androidx.compose.material3.Checkbox @@ -165,6 +166,14 @@ fun SettingsScreen() { Text(stringResource(id = R.string.web)) } + var autoOpenPage by remember { AppConfig.autoOpenWebPage } + SwitchPreference( + title = { Text(stringResource(R.string.auto_open_web)) }, + subTitle = { Text(stringResource(R.string.auto_open_web_desc)) }, + icon = { Icon(Icons.Default.HdrAuto, null) }, + checked = autoOpenPage + ) { autoOpenPage = it } + BasePreferenceWidget( onClick = { WebView(context).clearCache(true) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2725a51..c147a7a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,4 +58,6 @@ 仅清空资源缓存,不影响用户数据。 已清除 确定 + 自动打开网页界面 + 打开主界面时,自动跳转到网页界面。