Skip to content

Commit 3936ad9

Browse files
committed
fixes #326
1 parent 37bb034 commit 3936ad9

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

app/src/main/java/io/github/samolego/canta/ui/menu/FiltersMenu.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,20 @@ fun FiltersMenu(
4343
modifier = Modifier.width(180.dp)
4444
) {
4545
// System apps toggle
46+
val toggleSystem = { enabled: Boolean ->
47+
appListViewModel.onlySystem = enabled
48+
if (enabled && appListViewModel.selectedFilter == Filter.user) {
49+
appListViewModel.selectedFilter = Filter.any
50+
}
51+
}
4652
FilterChip(
4753
text = stringResource(R.string.only_system),
4854
isSelected = appListViewModel.onlySystem,
49-
onClick = { appListViewModel.onlySystem = !appListViewModel.onlySystem },
55+
onClick = { toggleSystem(!appListViewModel.onlySystem) },
5056
trailingContent = {
5157
Checkbox(
5258
checked = appListViewModel.onlySystem,
53-
onCheckedChange = { appListViewModel.onlySystem = it }
59+
onCheckedChange = toggleSystem,
5460
)
5561
}
5662
)
@@ -76,6 +82,9 @@ fun FiltersMenu(
7682
isSelected = appListViewModel.selectedFilter == filter,
7783
onClick = {
7884
appListViewModel.selectedFilter = filter
85+
if (filter == Filter.user && appListViewModel.onlySystem) {
86+
appListViewModel.onlySystem = false
87+
}
7988
filtersMenu = false
8089
}
8190
)

app/src/main/java/io/github/samolego/canta/util/apps/Filter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Filter(
1919
*/
2020
val any: Filter = Filter(name = "Any", shouldShow = { true })
2121

22+
val user = Filter(name = "User", shouldShow = { app -> !app.isSystemApp })
23+
2224
/**
2325
* List of available filters.
2426
*/
@@ -39,7 +41,6 @@ class Filter(
3941
removalFilters.add(0, any)
4042

4143
// Apps that are not system apps.
42-
val user = Filter(name = "User", shouldShow = { app -> !app.isSystemApp })
4344
removalFilters.add(1, user)
4445

4546
val unclassified =

0 commit comments

Comments
 (0)