Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
feat: 设置 自动打开网页
Browse files Browse the repository at this point in the history
  • Loading branch information
jing332 committed Jan 11, 2024
1 parent dbc99dd commit 4f1953b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ object AppConfig {
initialValue = false
)

var autoOpenWebPage = mutableDataSaverStateOf(
dataSaverInterface = pref,
key = "autoOpenWebPage",
initialValue = false
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@
<string name="clear_web_cache_desc">仅清空资源缓存,不影响用户数据。</string>
<string name="cleared">已清除</string>
<string name="confirm">确定</string>
<string name="auto_open_web">自动打开网页界面</string>
<string name="auto_open_web_desc">打开主界面时,自动跳转到网页界面。</string>
</resources>

0 comments on commit 4f1953b

Please sign in to comment.