Skip to content

Commit 251dbba

Browse files
Merge pull request #2064 from hussainmohd-a/v055n
v055q
2 parents b781af8 + 0a6f888 commit 251dbba

File tree

6 files changed

+248
-204
lines changed

6 files changed

+248
-204
lines changed

app/src/full/java/com/celzero/bravedns/ui/bottomsheet/FirewallAppFilterBottomSheet.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.celzero.bravedns"
5-
android:versionCode="48"
6-
android:versionName="v055p"> <!-- 48 for v055p -->
5+
android:versionCode="49"
6+
android:versionName="v055q"> <!-- 49 for v055q -->
77

88
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
99
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED" />

0 commit comments

Comments
 (0)