diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/component/SearchBar.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/component/SearchBar.kt
index f617fa520ba4..1d9a822e025a 100644
--- a/manager/app/src/main/java/me/weishu/kernelsu/ui/component/SearchBar.kt
+++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/component/SearchBar.kt
@@ -10,8 +10,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.filled.Close
-import androidx.compose.material.icons.filled.Search
+import androidx.compose.material.icons.filled.*
import androidx.compose.material.icons.outlined.ArrowBack
import androidx.compose.material3.*
import androidx.compose.runtime.*
@@ -22,9 +21,11 @@ import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
+import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
+import me.weishu.kernelsu.R
private const val TAG = "SearchBar"
@@ -36,7 +37,8 @@ fun SearchAppBar(
onSearchTextChange: (String) -> Unit,
onClearClick: () -> Unit,
onBackClick: (() -> Unit)? = null,
- onConfirm: (() -> Unit)? = null
+ onConfirm: (() -> Unit)? = null,
+ dropdownContent: @Composable (() -> Unit)? = null,
) {
val keyboardController = LocalSoftwareKeyboardController.current
val focusRequester = remember { FocusRequester() }
@@ -116,6 +118,11 @@ fun SearchAppBar(
content = { Icon(Icons.Filled.Search, null) }
)
}
+
+ if (dropdownContent != null) {
+ dropdownContent()
+ }
+
}
)
}
diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt
index 9c25ae1c9019..29607bfe896b 100644
--- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt
+++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/SuperUser.kt
@@ -1,14 +1,10 @@
package me.weishu.kernelsu.ui.screen
-import android.content.pm.ApplicationInfo
-import android.content.pm.PackageManager
-import android.graphics.Bitmap
-import android.graphics.drawable.Drawable
-import android.util.Log
-import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
@@ -17,17 +13,8 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
-import coil.ImageLoader
import coil.compose.AsyncImage
-import coil.compose.rememberAsyncImagePainter
-import coil.compose.rememberImagePainter
-import coil.decode.DataSource
-import coil.fetch.DrawableResult
-import coil.fetch.FetchResult
-import coil.fetch.Fetcher
-import coil.request.CachePolicy
import coil.request.ImageRequest
-import coil.request.Options
import com.google.accompanist.swiperefresh.SwipeRefresh
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
import com.ramcosta.composedestinations.annotation.Destination
@@ -37,7 +24,6 @@ import me.weishu.kernelsu.R
import me.weishu.kernelsu.ui.component.SearchAppBar
import me.weishu.kernelsu.ui.util.LocalSnackbarHost
import me.weishu.kernelsu.ui.viewmodel.SuperUserViewModel
-import me.zhanghai.android.appiconloader.coil.AppIconKeyer
import java.util.*
@OptIn(ExperimentalMaterial3Api::class)
@@ -60,7 +46,44 @@ fun SuperUserScreen() {
title = { Text(stringResource(R.string.superuser)) },
searchText = viewModel.search,
onSearchTextChange = { viewModel.search = it },
- onClearClick = { viewModel.search = "" }
+ onClearClick = { viewModel.search = "" },
+ dropdownContent = {
+ var showDropdown by remember { mutableStateOf(false) }
+
+ IconButton(
+ onClick = { showDropdown = true },
+ ) {
+ Icon(
+ imageVector = Icons.Filled.MoreVert,
+ contentDescription = stringResource(id = R.string.settings)
+ )
+
+ DropdownMenu(expanded = showDropdown, onDismissRequest = {
+ showDropdown = false
+ }) {
+ DropdownMenuItem(text = {
+ Text(stringResource(R.string.refresh))
+ }, onClick = {
+ scope.launch {
+ viewModel.fetchAppList()
+ }
+ showDropdown = false
+ })
+ DropdownMenuItem(text = {
+ Text(
+ if (viewModel.showSystemApps) {
+ stringResource(R.string.hide_system_apps)
+ } else {
+ stringResource(R.string.show_system_apps)
+ }
+ )
+ }, onClick = {
+ viewModel.showSystemApps = !viewModel.showSystemApps
+ showDropdown = false
+ })
+ }
+ }
+ },
)
}
) { innerPadding ->
diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/SuperUserViewModel.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/SuperUserViewModel.kt
index edc2ab5971f1..40e83535b897 100644
--- a/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/SuperUserViewModel.kt
+++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/viewmodel/SuperUserViewModel.kt
@@ -35,6 +35,7 @@ class SuperUserViewModel : ViewModel() {
)
var search by mutableStateOf("")
+ var showSystemApps by mutableStateOf(false)
var isRefreshing by mutableStateOf(false)
private set
@@ -55,6 +56,9 @@ class SuperUserViewModel : ViewModel() {
sortedList.filter {
it.label.contains(search) || it.packageName.contains(search) || HanziToPinyin.getInstance()
.toPinyinString(it.label).contains(search)
+ }.filter {
+ it.uid == 2000 // Always show shell
+ || showSystemApps || it.icon.applicationInfo.flags.and(ApplicationInfo.FLAG_SYSTEM) == 0
}
}
diff --git a/manager/app/src/main/res/values-zh-rCN/strings.xml b/manager/app/src/main/res/values-zh-rCN/strings.xml
index 26bb9750b723..0fa11f69409c 100644
--- a/manager/app/src/main/res/values-zh-rCN/strings.xml
+++ b/manager/app/src/main/res/values-zh-rCN/strings.xml
@@ -46,4 +46,7 @@
版本
作者
内核不支持 overlayfs,模块功能无法运作!
+ 刷新
+ 显示系统应用
+ 隐藏系统应用
diff --git a/manager/app/src/main/res/values/strings.xml b/manager/app/src/main/res/values/strings.xml
index ee91352f8be9..474a010fb8b6 100644
--- a/manager/app/src/main/res/values/strings.xml
+++ b/manager/app/src/main/res/values/strings.xml
@@ -50,5 +50,8 @@
Version
Author
overlayfs is not available, module cannot work!
+ Refresh
+ Show system apps
+ Hide system apps