Skip to content

Commit

Permalink
manager: Add option to disable update close #1303
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Jan 29, 2024
1 parent d7bc853 commit 8abd37a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
DonateCard()
LearnMoreCard()
Expand Down
36 changes: 32 additions & 4 deletions manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.weishu.kernelsu.ui.screen

import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.clickable
Expand Down Expand Up @@ -62,9 +63,9 @@ fun SettingScreen(navigator: DestinationsNavigator) {
ListItem(
leadingContent = { Icon(Icons.Filled.Fence, 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 {
navigator.navigate(AppProfileTemplateScreenDestination)
navigator.navigate(AppProfileTemplateScreenDestination)
}
)

Expand All @@ -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(
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)) },
modifier = Modifier.clickable {
scope.launch {
Expand Down Expand Up @@ -117,7 +140,12 @@ fun SettingScreen(navigator: DestinationsNavigator) {

val about = stringResource(id = R.string.about)
ListItem(
leadingContent = { Icon(Icons.Filled.ContactPage, stringResource(id = R.string.about)) },
leadingContent = {
Icon(
Icons.Filled.ContactPage,
stringResource(id = R.string.about)
)
},
headlineContent = { Text(about) },
modifier = Modifier.clickable {
showAboutDialog.value = true
Expand Down
2 changes: 2 additions & 0 deletions manager/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,6 @@
<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="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>

0 comments on commit 8abd37a

Please sign in to comment.