11package me.weishu.kernelsu.ui.viewmodel
22
33import android.content.ComponentName
4+ import android.content.Context
45import android.content.Intent
56import android.content.ServiceConnection
67import android.content.pm.ApplicationInfo
@@ -13,6 +14,7 @@ import androidx.compose.runtime.State
1314import androidx.compose.runtime.getValue
1415import androidx.compose.runtime.mutableStateOf
1516import androidx.compose.runtime.setValue
17+ import androidx.core.content.edit
1618import androidx.lifecycle.ViewModel
1719import com.topjohnwu.superuser.Shell
1820import kotlinx.coroutines.Dispatchers
@@ -29,6 +31,7 @@ import java.text.Collator
2931import java.util.Locale
3032import kotlin.coroutines.resume
3133import kotlin.coroutines.suspendCoroutine
34+ import androidx.core.content.edit
3235
3336class SuperUserViewModel : ViewModel () {
3437
@@ -70,10 +73,16 @@ class SuperUserViewModel : ViewModel() {
7073 }
7174 }
7275
73- var showSystemApps by mutableStateOf(false )
76+ private val prefs = ksuApp.getSharedPreferences(" settings" , Context .MODE_PRIVATE )!!
77+ var showSystemApps by mutableStateOf(prefs.getBoolean(" show_system_apps" , false ))
7478 var isRefreshing by mutableStateOf(false )
7579 private set
7680
81+ fun updateShowSystemApps (newValue : Boolean ) {
82+ showSystemApps = newValue
83+ prefs.edit { putBoolean(" show_system_apps" , newValue) }
84+ }
85+
7786 private val _searchResults = mutableStateOf<List <AppInfo >>(emptyList())
7887 val searchResults: State <List <AppInfo >> = _searchResults
7988
0 commit comments