From 53708531c030e57623f2e04fc70544a22252972a Mon Sep 17 00:00:00 2001 From: IronVeil Date: Mon, 13 Nov 2023 21:15:09 +0000 Subject: [PATCH 1/2] Set VPN notification persistent Signed-off-by: IronVeil --- .../main/java/com/celzero/bravedns/service/BraveVPNService.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt b/app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt index 4df9d8334..dcb789708 100644 --- a/app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt +++ b/app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt @@ -1094,6 +1094,7 @@ class BraveVPNService : builder.setSmallIcon(R.drawable.ic_notification_icon).setContentIntent(pendingIntent) builder.color = ContextCompat.getColor(this, getAccentColor(persistentState.theme)) + builder.setOngoing(true) // New action button options in the notification // 1. Pause / Resume, Stop action button. From 54374a2cb0d47b26532ea3b9df684891d678fcbb Mon Sep 17 00:00:00 2001 From: IronVeil Date: Tue, 14 Nov 2023 00:05:21 +0000 Subject: [PATCH 2/2] Added basic persistent notification toggle (#1136) Signed-off-by: IronVeil --- .../bravedns/ui/MiscSettingsActivity.kt | 15 +++++- .../res/layout/activity_misc_settings.xml | 54 +++++++++++++++++++ .../bravedns/service/BraveVPNService.kt | 6 ++- .../bravedns/service/PersistentState.kt | 4 ++ app/src/main/res/values/strings.xml | 3 ++ 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/app/src/full/java/com/celzero/bravedns/ui/MiscSettingsActivity.kt b/app/src/full/java/com/celzero/bravedns/ui/MiscSettingsActivity.kt index bdb92f731..56ad32576 100644 --- a/app/src/full/java/com/celzero/bravedns/ui/MiscSettingsActivity.kt +++ b/app/src/full/java/com/celzero/bravedns/ui/MiscSettingsActivity.kt @@ -213,7 +213,9 @@ class MiscSettingsActivity : AppCompatActivity(R.layout.activity_misc_settings) !b.settingsActivityAutoStartSwitch.isChecked } - b.settingsActivityAutoStartSwitch.setOnCheckedChangeListener { _: CompoundButton, b: Boolean + b.settingsActivityAutoStartSwitch.setOnCheckedChangeListener { + _: CompoundButton, + b: Boolean -> persistentState.prefAutoStartBootUp = b } @@ -248,6 +250,17 @@ class MiscSettingsActivity : AppCompatActivity(R.layout.activity_misc_settings) showNotificationActionDialog() } + b.settingsActivityAppNotificationPersistentRl.setOnClickListener { + b.settingsActivityAppNotificationPersistentSwitch.isChecked = + !b.settingsActivityAppNotificationPersistentSwitch.isChecked + } + + b.settingsActivityAppNotificationPersistentSwitch.setOnCheckedChangeListener { + _: CompoundButton, + b: Boolean -> + persistentState.persistentNotification = b + } + b.settingsActivityPcapRl.setOnClickListener { enableAfterDelay(TimeUnit.SECONDS.toMillis(1L), b.settingsActivityPcapRl) showPcapOptionsDialog() diff --git a/app/src/full/res/layout/activity_misc_settings.xml b/app/src/full/res/layout/activity_misc_settings.xml index 4fdce82c6..12370a345 100644 --- a/app/src/full/res/layout/activity_misc_settings.xml +++ b/app/src/full/res/layout/activity_misc_settings.xml @@ -722,6 +722,60 @@ android:padding="10dp" /> + + + + + + + + + + + + + + diff --git a/app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt b/app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt index dcb789708..f949f75c9 100644 --- a/app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt +++ b/app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt @@ -1094,7 +1094,11 @@ class BraveVPNService : builder.setSmallIcon(R.drawable.ic_notification_icon).setContentIntent(pendingIntent) builder.color = ContextCompat.getColor(this, getAccentColor(persistentState.theme)) - builder.setOngoing(true) + + if (persistentState.persistentNotification) + { + builder.setOngoing(true) + } // New action button options in the notification // 1. Pause / Resume, Stop action button. diff --git a/app/src/main/java/com/celzero/bravedns/service/PersistentState.kt b/app/src/main/java/com/celzero/bravedns/service/PersistentState.kt index 38f7284e7..537056f1e 100644 --- a/app/src/main/java/com/celzero/bravedns/service/PersistentState.kt +++ b/app/src/main/java/com/celzero/bravedns/service/PersistentState.kt @@ -239,6 +239,10 @@ class PersistentState(context: Context) : SimpleKrate(context), KoinComponent { var shouldRequestNotificationPermission by booleanPref("notification_permission_request").withDefault(true) + // make notification persistent + var persistentNotification by + booleanPref("persistent_notification").withDefault(false) + // biometric authentication var biometricAuth by booleanPref("biometric_authentication").withDefault(false) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 39334aeac..31e89d7e5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -473,6 +473,9 @@ App Notification Enable notification permission for the app + Persistent Notification + Make the notification persistent + Appearance Dark/light theme