From cd25996a6cf85b7b72d669ef7997e59093d547fe Mon Sep 17 00:00:00 2001
From: backslashxx <118538522+backslashxx@users.noreply.github.com>
Date: Tue, 29 Oct 2024 00:08:06 +0800
Subject: [PATCH] manager: unofficial build

- disable updates
- warn and inform that this is not an official build.
---
 .../java/me/weishu/kernelsu/ui/screen/Home.kt | 37 +++++++++++++++----
 .../me/weishu/kernelsu/ui/screen/Settings.kt  | 17 +--------
 .../me/weishu/kernelsu/ui/util/Downloader.kt  |  3 +-
 manager/app/src/main/res/values/strings.xml   |  5 ++-
 4 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
index 0fa3b34a8d4e..15389fe37a45 100644
--- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
+++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
@@ -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()
@@ -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)
@@ -459,4 +482,4 @@ private fun WarningCardPreview() {
             MaterialTheme.colorScheme.outlineVariant,
             onClick = {})
     }
-}
\ No newline at end of file
+}
diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt
index 42caaa853dd5..eb02aafc37cc 100644
--- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt
+++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Settings.kt
@@ -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)
@@ -491,4 +476,4 @@ private fun TopBar(
 @Composable
 private fun SettingsPreview() {
     SettingScreen(EmptyDestinationsNavigator)
-}
\ No newline at end of file
+}
diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/util/Downloader.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/util/Downloader.kt
index 954cac50da30..5d85bc63d5fe 100644
--- a/manager/app/src/main/java/me/weishu/kernelsu/ui/util/Downloader.kt
+++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/util/Downloader.kt
@@ -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 {
diff --git a/manager/app/src/main/res/values/strings.xml b/manager/app/src/main/res/values/strings.xml
index e9d058e9e0bd..2df83a821ead 100644
--- a/manager/app/src/main/res/values/strings.xml
+++ b/manager/app/src/main/res/values/strings.xml
@@ -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>
@@ -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>
\ No newline at end of file
+</resources>