From 4f1953b72c84dcf968fc6aea4dad49f1ef271bb1 Mon Sep 17 00:00:00 2001
From: Jing <42014615+jing332@users.noreply.github.com>
Date: Thu, 11 Jan 2024 20:59:22 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E7=BD=AE=20=E8=87=AA=E5=8A=A8?=
=?UTF-8?q?=E6=89=93=E5=BC=80=E7=BD=91=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/github/jing332/alistandroid/config/AppConfig.kt | 6 ++++++
.../jing332/alistandroid/ui/nav/NavigationGraph.kt | 7 ++++++-
.../alistandroid/ui/nav/settings/SettingsScreen.kt | 9 +++++++++
app/src/main/res/values/strings.xml | 2 ++
4 files changed, 23 insertions(+), 1 deletion(-)
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 @@
仅清空资源缓存,不影响用户数据。
已清除
确定
+ 自动打开网页界面
+ 打开主界面时,自动跳转到网页界面。