Skip to content

Commit a4a9ff7

Browse files
authored
add proprietary-only filter and sync dashboard filter states (#137)
2 parents 843dcef + 774b171 commit a4a9ff7

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

app/src/main/java/com/jksalcedo/librefind/ui/dashboard/DashboardScreen.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,19 @@ fun DashboardScreen(
187187
)
188188
HorizontalDivider()
189189
DropdownMenuItem(
190-
text = { Text("PROP with Alternatives") },
190+
text = { Text("All Proprietary") },
191+
onClick = {
192+
viewModel.setAppFilter(AppFilter.PROP_ONLY)
193+
showFilterMenu = false
194+
},
195+
leadingIcon = {
196+
if (state.appFilter == AppFilter.PROP_ONLY) {
197+
Icon(Icons.Default.Check, contentDescription = null)
198+
}
199+
}
200+
)
201+
DropdownMenuItem(
202+
text = { Text("With Alternatives") },
191203
onClick = {
192204
viewModel.setAppFilter(AppFilter.PROP_WITH_ALTERNATIVES)
193205
showFilterMenu = false
@@ -199,7 +211,7 @@ fun DashboardScreen(
199211
}
200212
)
201213
DropdownMenuItem(
202-
text = { Text("PROP without Alternatives") },
214+
text = { Text("Without Alternatives") },
203215
onClick = {
204216
viewModel.setAppFilter(AppFilter.PROP_NO_ALTERNATIVES)
205217
showFilterMenu = false

app/src/main/java/com/jksalcedo/librefind/ui/dashboard/DashboardViewModel.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import kotlinx.coroutines.launch
2222

2323
enum class AppFilter {
2424
ALL,
25+
PROP_ONLY,
2526
PROP_WITH_ALTERNATIVES,
2627
PROP_NO_ALTERNATIVES,
2728
FOSS_ONLY,
@@ -76,6 +77,7 @@ class DashboardViewModel(
7677
} else {
7778
when (appFilter) {
7879
AppFilter.ALL -> app.status != AppStatus.IGNORED
80+
AppFilter.PROP_ONLY -> app.status == AppStatus.PROP
7981
AppFilter.PROP_WITH_ALTERNATIVES -> app.status == AppStatus.PROP && app.knownAlternatives > 0
8082
AppFilter.PROP_NO_ALTERNATIVES -> app.status == AppStatus.PROP && app.knownAlternatives == 0
8183
AppFilter.FOSS_ONLY -> app.status == AppStatus.FOSS
@@ -121,12 +123,30 @@ class DashboardViewModel(
121123

122124
fun setStatusFilter(status: AppStatus?) {
123125
_statusFilter.value = status
124-
_appFilter.value = AppFilter.ALL
126+
// Sync app filter based on status
127+
_appFilter.value = when (status) {
128+
AppStatus.FOSS -> AppFilter.FOSS_ONLY
129+
AppStatus.PROP -> AppFilter.PROP_ONLY
130+
AppStatus.UNKN -> AppFilter.UNKNOWN_ONLY
131+
AppStatus.PENDING -> AppFilter.PENDING_ONLY
132+
AppStatus.IGNORED -> AppFilter.IGNORED_ONLY
133+
null -> AppFilter.ALL
134+
}
125135
}
126136

127137
fun setAppFilter(filter: AppFilter) {
128138
_appFilter.value = filter
129-
_statusFilter.value = null
139+
// Sync status filter based on app filter
140+
_statusFilter.value = when (filter) {
141+
AppFilter.FOSS_ONLY -> AppStatus.FOSS
142+
AppFilter.PROP_ONLY,
143+
AppFilter.PROP_WITH_ALTERNATIVES,
144+
AppFilter.PROP_NO_ALTERNATIVES -> AppStatus.PROP
145+
AppFilter.UNKNOWN_ONLY -> AppStatus.UNKN
146+
AppFilter.PENDING_ONLY -> AppStatus.PENDING
147+
AppFilter.IGNORED_ONLY -> AppStatus.IGNORED
148+
AppFilter.ALL -> null
149+
}
130150
}
131151

132152
fun ignoreApp(packageName: String) {

metadata/en-US/changelogs/13.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
What's New:
2+
- Added contribution guidelines and Wiki link.
3+
- Improved app category styling (bold & capitalized).
4+
- Added 'ignored' status styling.
5+
- Added linking of alternatives to existing proprietary apps.
6+
- Synchronized the filter icon state with the dashboard gauge.

0 commit comments

Comments
 (0)