Skip to content
This repository was archived by the owner on Nov 1, 2025. It is now read-only.

Commit fb4cdb5

Browse files
5ec1cffbackslashxx
authored andcommitted
app: persist show system app settings
1 parent 882edf5 commit fb4cdb5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fun SuperUserPager(
138138
optionSize = 1,
139139
onSelectedIndexChange = {
140140
scope.launch {
141-
viewModel.showSystemApps = !viewModel.showSystemApps
141+
viewModel.updateShowSystemApps(!viewModel.showSystemApps)
142142
viewModel.fetchAppList()
143143
}
144144
showTopPopup.value = false

manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/SuperUserViewModel.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package me.weishu.kernelsu.ui.viewmodel
22

33
import android.content.ComponentName
4+
import android.content.Context
45
import android.content.Intent
56
import android.content.ServiceConnection
67
import android.content.pm.ApplicationInfo
@@ -13,6 +14,7 @@ import androidx.compose.runtime.State
1314
import androidx.compose.runtime.getValue
1415
import androidx.compose.runtime.mutableStateOf
1516
import androidx.compose.runtime.setValue
17+
import androidx.core.content.edit
1618
import androidx.lifecycle.ViewModel
1719
import com.topjohnwu.superuser.Shell
1820
import kotlinx.coroutines.Dispatchers
@@ -29,6 +31,7 @@ import java.text.Collator
2931
import java.util.Locale
3032
import kotlin.coroutines.resume
3133
import kotlin.coroutines.suspendCoroutine
34+
import androidx.core.content.edit
3235

3336
class 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

Comments
 (0)