android: app picker - hide system apps by default with a toggle
This commit is contained in:
1 parent
8bedf432e2
commit
59a31d6a1d
4 files changed
+25
-3
No files matched your search
+22
-3
@@ -150,9 +150,17 @@ private fun SelectedAppsScreen(
|
||||
onChange(selected)
|
||||
}
|
||||
|
||||
val filtered = remember(apps, query) {
|
||||
if (query.isBlank()) apps
|
||||
else apps.filter { it.toString().contains(query, ignoreCase = true) || it.info.packageName.contains(query, ignoreCase = true) }
|
||||
/* pure system apps are hidden by default (they are rarely worth excluding); a selected one always shows */
|
||||
var showSystem by remember { mutableStateOf(false) }
|
||||
val filtered = remember(apps, query, showSystem, selected) {
|
||||
apps.filter { entry ->
|
||||
val flags = entry.info.flags
|
||||
val system = (flags and android.content.pm.ApplicationInfo.FLAG_SYSTEM) != 0 &&
|
||||
(flags and android.content.pm.ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0
|
||||
(showSystem || !system || selected.contains(entry.info.packageName)) &&
|
||||
(query.isBlank() || entry.toString().contains(query, ignoreCase = true) ||
|
||||
entry.info.packageName.contains(query, ignoreCase = true))
|
||||
}
|
||||
}
|
||||
|
||||
SecondaryScaffold(title = stringResource(R.string.profile_select_apps), onBack = onBack) { padding ->
|
||||
@@ -164,6 +172,17 @@ private fun SelectedAppsScreen(
|
||||
singleLine = true,
|
||||
modifier = Modifier.padding(horizontal = ShxSpacing.lg, vertical = ShxSpacing.sm).fillMaxWidth(),
|
||||
)
|
||||
androidx.compose.foundation.layout.Row(
|
||||
verticalAlignment = androidx.compose.ui.Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable { showSystem = !showSystem }
|
||||
.padding(horizontal = ShxSpacing.lg),
|
||||
)
|
||||
{
|
||||
Text(stringResource(R.string.apps_show_system), modifier = Modifier.weight(1f))
|
||||
androidx.compose.material3.Switch(checked = showSystem, onCheckedChange = null)
|
||||
}
|
||||
if (loading)
|
||||
{
|
||||
LoadingIndicator(Modifier.padding(ShxSpacing.xl).size(32.dp))
|
||||
|
||||
@@ -509,4 +509,5 @@
|
||||
<string name="log_filter_all">Alle</string>
|
||||
<string name="log_filter_warn">Warnungen</string>
|
||||
<string name="log_filter_error">Fehler</string>
|
||||
<string name="apps_show_system">Systemapps anzeigen</string>
|
||||
</resources>
|
||||
@@ -506,4 +506,5 @@
|
||||
<string name="log_filter_all">Все</string>
|
||||
<string name="log_filter_warn">Предупреждения</string>
|
||||
<string name="log_filter_error">Ошибки</string>
|
||||
<string name="apps_show_system">Показывать системные приложения</string>
|
||||
</resources>
|
||||
@@ -511,4 +511,5 @@
|
||||
<string name="log_filter_all">All</string>
|
||||
<string name="log_filter_warn">Warnings</string>
|
||||
<string name="log_filter_error">Errors</string>
|
||||
<string name="apps_show_system">Show system apps</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user