manager: Add option to disable update close #1303

This commit is contained in:
weishu
2024-01-29 21:33:24 +08:00
parent d7bc853bfc
commit 8abd37a35c
3 changed files with 40 additions and 5 deletions

View File

@@ -69,7 +69,12 @@ fun HomeScreen(navigator: DestinationsNavigator) {
) )
) )
} }
UpdateCard() val checkUpdate =
LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("check_update", true)
if (checkUpdate) {
UpdateCard()
}
InfoCard() InfoCard()
DonateCard() DonateCard()
LearnMoreCard() LearnMoreCard()

View File

@@ -1,5 +1,6 @@
package me.weishu.kernelsu.ui.screen package me.weishu.kernelsu.ui.screen
import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
@@ -62,9 +63,9 @@ fun SettingScreen(navigator: DestinationsNavigator) {
ListItem( ListItem(
leadingContent = { Icon(Icons.Filled.Fence, profileTemplate) }, leadingContent = { Icon(Icons.Filled.Fence, profileTemplate) },
headlineContent = { Text(profileTemplate) }, headlineContent = { Text(profileTemplate) },
supportingContent = { Text(stringResource(id = R.string.settings_profile_template_summary))}, supportingContent = { Text(stringResource(id = R.string.settings_profile_template_summary)) },
modifier = Modifier.clickable { modifier = Modifier.clickable {
navigator.navigate(AppProfileTemplateScreenDestination) navigator.navigate(AppProfileTemplateScreenDestination)
} }
) )
@@ -82,8 +83,30 @@ fun SettingScreen(navigator: DestinationsNavigator) {
} }
} }
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
var checkUpdate by rememberSaveable {
mutableStateOf(
prefs.getBoolean("check_update", true)
)
}
SwitchItem(
icon = Icons.Filled.RemoveModerator,
title = stringResource(id = R.string.settings_check_update),
summary = stringResource(id = R.string.settings_check_update_summary),
checked = checkUpdate
) {
prefs.edit().putBoolean("check_update", it).apply()
checkUpdate = it
}
ListItem( ListItem(
leadingContent = { Icon(Icons.Filled.BugReport, stringResource(id = R.string.send_log)) }, leadingContent = {
Icon(
Icons.Filled.BugReport,
stringResource(id = R.string.send_log)
)
},
headlineContent = { Text(stringResource(id = R.string.send_log)) }, headlineContent = { Text(stringResource(id = R.string.send_log)) },
modifier = Modifier.clickable { modifier = Modifier.clickable {
scope.launch { scope.launch {
@@ -117,7 +140,12 @@ fun SettingScreen(navigator: DestinationsNavigator) {
val about = stringResource(id = R.string.about) val about = stringResource(id = R.string.about)
ListItem( ListItem(
leadingContent = { Icon(Icons.Filled.ContactPage, stringResource(id = R.string.about)) }, leadingContent = {
Icon(
Icons.Filled.ContactPage,
stringResource(id = R.string.about)
)
},
headlineContent = { Text(about) }, headlineContent = { Text(about) },
modifier = Modifier.clickable { modifier = Modifier.clickable {
showAboutDialog.value = true showAboutDialog.value = true

View File

@@ -104,4 +104,6 @@
<string name="app_profile_template_save_failed">Failed to save template</string> <string name="app_profile_template_save_failed">Failed to save template</string>
<string name="app_profile_template_import_empty">Clipboard is empty!</string> <string name="app_profile_template_import_empty">Clipboard is empty!</string>
<string name="module_changelog_failed">Fetch changelog failed: %s</string> <string name="module_changelog_failed">Fetch changelog failed: %s</string>
<string name="settings_check_update">Check update</string>
<string name="settings_check_update_summary">Automatically check for updates when opening the app</string>
</resources> </resources>