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.

Signed-off-by: Edwiin Kusuma Jaya <kutemeikito0905@gmail.com>
  • Loading branch information
backslashxx authored and kutemeikito committed Nov 4, 2024
1 parent 33dd2ae commit 43d86af
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 25 deletions.
42 changes: 35 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,39 @@ 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
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_unofficial_kernelsu_credits),
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 +487,4 @@ private fun WarningCardPreview() {
MaterialTheme.colorScheme.outlineVariant,
onClick = {})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,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 @@ -483,4 +468,4 @@ private fun TopBar(
@Composable
private fun SettingsPreview() {
SettingScreen(EmptyDestinationsNavigator)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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
6 changes: 5 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,10 @@
<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 KernelSU by Ryz</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_unofficial_kernelsu_credits">Big Thanks to backslashxx for best commits</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 @@ -133,4 +137,4 @@
<string name="selected_lkm">Selected LKM: %s</string>
<string name="save_log">Save logs</string>
<string name="log_saved">Logs saved</string>
</resources>
</resources>

0 comments on commit 43d86af

Please sign in to comment.