app: persist show system app settings

This commit is contained in:
5ec1cff
2025-05-21 16:28:24 +08:00
committed by Rifat Azad
parent d562594ae1
commit 66d42de599
2 changed files with 17 additions and 2 deletions
@@ -92,7 +92,7 @@ fun SuperUserScreen(navigator: DestinationsNavigator) {
} }
) )
}, onClick = { }, onClick = {
viewModel.showSystemApps = !viewModel.showSystemApps viewModel.updateShowSystemApps(!viewModel.showSystemApps)
showDropdown = false showDropdown = false
}) })
} }
@@ -1,5 +1,9 @@
package com.rifsxd.ksunext.ui.viewmodel package com.rifsxd.ksunext.ui.viewmodel
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.content.pm.ApplicationInfo import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo import android.content.pm.PackageInfo
import android.os.Parcelable import android.os.Parcelable
@@ -24,6 +28,9 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.withTimeoutOrNull import kotlinx.coroutines.withTimeoutOrNull
import java.text.Collator import java.text.Collator
import java.util.* import java.util.*
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import androidx.core.content.edit
class SuperUserViewModel : ViewModel() { class SuperUserViewModel : ViewModel() {
val isPlatformAlive get() = Platform.isAlive val isPlatformAlive get() = Platform.isAlive
@@ -61,11 +68,19 @@ class SuperUserViewModel : ViewModel() {
} }
} }
private val prefs = ksuApp.getSharedPreferences("settings", Context.MODE_PRIVATE)!!
var search by mutableStateOf("") var search by mutableStateOf("")
var showSystemApps by mutableStateOf(false) var showSystemApps by mutableStateOf(prefs.getBoolean("show_system_apps", false))
private set
var isRefreshing by mutableStateOf(false) var isRefreshing by mutableStateOf(false)
private set private set
fun updateShowSystemApps(newValue: Boolean) {
showSystemApps = newValue
prefs.edit { putBoolean("show_system_apps", newValue) }
}
private val sortedList by derivedStateOf { private val sortedList by derivedStateOf {
val comparator = compareBy<AppInfo> { val comparator = compareBy<AppInfo> {
when { when {