Skip to content

Commit

Permalink
manager: unofficial build
Browse files Browse the repository at this point in the history
- disable updates
- warn and inform that this is not an official build.
  • Loading branch information
backslashxx committed Oct 29, 2024
1 parent 5530f87 commit cd25996
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
37 changes: 30 additions & 7 deletions manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
stringResource(id = R.string.grant_root_failed)
)
}
val checkUpdate =
LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("check_update", true)
if (checkUpdate) {
UpdateCard()
}
Unofficial()
InfoCard()
DonateCard()
LearnMoreCard()
Expand Down Expand Up @@ -432,6 +427,34 @@ private fun InfoCard() {
}
}

@Composable
fun Unofficial() {
val uriHandler = LocalUriHandler.current
val url = stringResource(R.string.home_unofficial_kernelsu_announce)

ElevatedCard {

Row(modifier = Modifier
.fillMaxWidth()
.clickable {
uriHandler.openUri(url)
}
.padding(24.dp), verticalAlignment = Alignment.CenterVertically) {
Column {
Text(
text = stringResource(R.string.home_unofficial_kernelsu),
style = MaterialTheme.typography.titleSmall
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_unofficial_kernelsu_body),
style = MaterialTheme.typography.bodyMedium
)
}
}
}
}

fun getManagerVersion(context: Context): Pair<String, Long> {
val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)!!
val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo)
Expand Down Expand Up @@ -459,4 +482,4 @@ private fun WarningCardPreview() {
MaterialTheme.colorScheme.outlineVariant,
onClick = {})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,6 @@ 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.Update,
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
}

var enableWebDebugging by rememberSaveable {
mutableStateOf(
prefs.getBoolean("enable_web_debugging", false)
Expand Down Expand Up @@ -491,4 +476,4 @@ private fun TopBar(
@Composable
private fun SettingsPreview() {
SettingScreen(EmptyDestinationsNavigator)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ fun download(
}

fun checkNewVersion(): LatestVersionInfo {
val url = "https://api.github.com/repos/tiann/KernelSU/releases/latest"
// disable updates
val url = "https://127.0.0.1/repos/tiann/KernelSU/releases/latest"
// default null value if failed
val defaultValue = LatestVersionInfo()
runCatching {
Expand Down
5 changes: 4 additions & 1 deletion manager/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<string name="safe_mode">Safe mode</string>
<string name="reboot_to_apply">Reboot to take effect</string>
<string name="module_magisk_conflict">Modules are unavailable due to a conflict with Magisk!</string>
<string name="home_unofficial_kernelsu">🚨 Unofficial Build ⁽ˣˣ⁾</string>
<string name="home_unofficial_kernelsu_announce">https://github.com/tiann/KernelSU/issues/1705</string>
<string name="home_unofficial_kernelsu_body">Non-GKI support ended; see announcement.</string>
<string name="home_learn_kernelsu">Learn KernelSU</string>
<string name="home_learn_kernelsu_url">https://kernelsu.org/guide/what-is-kernelsu.html</string>
<string name="home_click_to_learn_kernelsu">Learn how to install KernelSU and use modules</string>
Expand Down Expand Up @@ -132,4 +135,4 @@
<string name="flash_failed">Flash failed</string>
<string name="selected_lkm">Selected LKM: %s</string>
<string name="save_log">Save logs</string>
</resources>
</resources>

0 comments on commit cd25996

Please sign in to comment.