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.
- also ☃️ emoji as promised
- also update setup.sh for automated builds
- add 'legacy' on apk filename
  • Loading branch information
backslashxx committed Nov 14, 2024
1 parent 59fe408 commit 9df8fd0
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 29 deletions.
2 changes: 1 addition & 1 deletion kernel/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ perform_cleanup() {
# Sets up or update KernelSU environment
setup_kernelsu() {
echo "[+] Setting up KernelSU..."
test -d "$GKI_ROOT/KernelSU" || git clone https://github.com/tiann/KernelSU && echo "[+] Repository cloned."
test -d "$GKI_ROOT/KernelSU" || git clone https://github.com/backslashxx/KernelSU && echo "[+] Repository cloned."
cd "$GKI_ROOT/KernelSU"
git stash && echo "[-] Stashed current changes."
if [ "$(git status | grep -Po 'v\d+(\.\d+)*' | head -n1)" ]; then
Expand Down
4 changes: 2 additions & 2 deletions manager/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ android {
applicationVariants.all {
outputs.forEach {
val output = it as BaseVariantOutputImpl
output.outputFileName = "KernelSU_${managerVersionName}_${managerVersionCode}-$name.apk"
output.outputFileName = "KernelSU_${managerVersionName}_${managerVersionCode}-legacy-$name.apk"
}
kotlin.sourceSets {
getByName(name) {
Expand Down Expand Up @@ -133,4 +133,4 @@ dependencies {
implementation(libs.androidx.webkit)

implementation(libs.lsposed.cxx)
}
}
39 changes: 31 additions & 8 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 @@ -405,7 +400,7 @@ private fun InfoCard() {
val managerVersion = getManagerVersion(context)
InfoCardItem(
stringResource(R.string.home_manager_version),
"${managerVersion.first} (${managerVersion.second})"
"${managerVersion.first}-legacy (${managerVersion.second})"
)

Spacer(Modifier.height(16.dp))
Expand All @@ -417,6 +412,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 @@ -444,4 +467,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
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 @@ -49,6 +49,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 @@ -135,4 +138,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 9df8fd0

Please sign in to comment.