manager: remember sus_su toggle state

This commit is contained in:
Rifat Azad
2024-12-23 09:49:22 +06:00
parent 65a2088483
commit eafff027e5
2 changed files with 15 additions and 2 deletions

View File

@@ -46,6 +46,7 @@ import com.rifsxd.ksunext.ui.theme.KernelSUTheme
import com.rifsxd.ksunext.ui.util.LocalSnackbarHost
import com.rifsxd.ksunext.ui.util.rootAvailable
import com.rifsxd.ksunext.ui.util.install
import com.rifsxd.ksunext.ui.util.*
class MainActivity : ComponentActivity() {
@@ -62,6 +63,17 @@ class MainActivity : ComponentActivity() {
val isManager = Natives.becomeManager(ksuApp.packageName)
if (isManager) install()
val prefs = getSharedPreferences("settings", MODE_PRIVATE)
val suSFSVar = getSuSFSVariant()
if (suSFSVar != "NON-GKI") {
if (prefs.getBoolean("enable_susfs", false)) {
if (susfsSUSSU_Mode() != "2") {
susfsSUSSU_1()
}
}
}
setContent {
KernelSUTheme {
val navController = rememberNavController()

View File

@@ -186,11 +186,11 @@ fun SettingScreen(navigator: DestinationsNavigator) {
prefs.edit().putBoolean("enable_web_debugging", it).apply()
enableWebDebugging = it
}
val suSFSVar = getSuSFSVariant()
if (suSFSVar != "NON-GKI") {
var isEnabled by rememberSaveable {
mutableStateOf(susfsSUSSU_Mode() == "2")
mutableStateOf(prefs.getBoolean("enable_susfs", susfsSUSSU_Mode() == "2"))
}
SwitchItem(
icon = Icons.Filled.VisibilityOff,
@@ -203,6 +203,7 @@ fun SettingScreen(navigator: DestinationsNavigator) {
} else {
susfsSUSSU_0()
}
prefs.edit().putBoolean("enable_susfs", it).apply()
isEnabled = it
}
}