@@ -85,6 +85,7 @@ class FirewallAppFilterBottomSheet : BottomSheetDialogFragment() {
8585 return
8686 } else {
8787 this .filters.firewallFilter = f.firewallFilter
88+ this .filters.categoryFilters.addAll(f.categoryFilters)
8889 }
8990
9091 applyParentFilter(f.topLevelFilter.id)
@@ -190,23 +191,20 @@ class FirewallAppFilterBottomSheet : BottomSheetDialogFragment() {
190191 when (tag) {
191192 AppListActivity .TopLevelFilter .ALL .id -> {
192193 filters.topLevelFilter = AppListActivity .TopLevelFilter .ALL
193- filters.categoryFilters.clear()
194194 io {
195195 val categories = FirewallManager .getAllCategories()
196196 uiCtx { remakeChildFilterChipsUi(categories) }
197197 }
198198 }
199199 AppListActivity .TopLevelFilter .INSTALLED .id -> {
200200 filters.topLevelFilter = AppListActivity .TopLevelFilter .INSTALLED
201- filters.categoryFilters.clear()
202201 io {
203202 val categories = FirewallManager .getCategoriesForInstalledApps()
204203 uiCtx { remakeChildFilterChipsUi(categories) }
205204 }
206205 }
207206 AppListActivity .TopLevelFilter .SYSTEM .id -> {
208207 filters.topLevelFilter = AppListActivity .TopLevelFilter .SYSTEM
209- filters.categoryFilters.clear()
210208 io {
211209 val categories = FirewallManager .getCategoriesForSystemApps()
212210 uiCtx { remakeChildFilterChipsUi(categories) }
@@ -218,14 +216,21 @@ class FirewallAppFilterBottomSheet : BottomSheetDialogFragment() {
218216 private fun remakeChildFilterChipsUi (categories : List <String >) {
219217 b.ffaChipGroup.removeAllViews()
220218 for (c in categories) {
221- b.ffaChipGroup.addView(makeChildChip(c))
219+ if (filters.categoryFilters.contains(c)) {
220+ // if the category is already selected, check the chip
221+ b.ffaChipGroup.addView(makeChildChip(c, true ))
222+ } else {
223+ b.ffaChipGroup.addView(makeChildChip(c, false ))
224+ }
222225 }
223226 }
224227
225- private fun makeChildChip (title : String ): Chip {
228+ private fun makeChildChip (title : String , checked : Boolean ): Chip {
226229 val chip = this .layoutInflater.inflate(R .layout.item_chip_filter, b.root, false ) as Chip
227230 chip.text = title
228231 chip.tag = title
232+ chip.isChecked = checked
233+ if (checked) colorUpChipIcon(chip)
229234
230235 chip.setOnCheckedChangeListener { compoundButton: CompoundButton , isSelected: Boolean ->
231236 applyChildFilter(compoundButton.tag, isSelected)
0 commit comments