Skip to content

Commit

Permalink
Merge pull request #1139 from ironveil/main
Browse files Browse the repository at this point in the history
Set VPN notification persistent
  • Loading branch information
hussainmohd-a authored Nov 25, 2023
2 parents db261b0 + 54374a2 commit 859519a
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
Expand Down
54 changes: 54 additions & 0 deletions app/src/full/res/layout/activity_misc_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,60 @@
android:padding="10dp" />
</RelativeLayout>

<RelativeLayout
android:id="@+id/settings_activity_app_notification_persistent_rl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:paddingTop="15dp"
android:paddingBottom="15dp">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/settings_activity_app_notification_persistent_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:padding="10dp"
android:src="@drawable/ic_notification" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toStartOf="@id/settings_activity_app_notification_persistent_switch"
android:layout_toEndOf="@id/settings_activity_app_notification_persistent_icon"
android:orientation="vertical">

<TextView
android:id="@+id/gen_settings_app_notification_persistent_txt"
style="@style/TextAppearance.AppCompat.Subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_app_notification_persistent_heading"
android:textSize="@dimen/large_font_text_view" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:text="@string/settings_app_notification_persistent_desc"
android:textSize="@dimen/default_font_text_view" />
</LinearLayout>

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/settings_activity_app_notification_persistent_switch"
style="@style/CustomWidget.MaterialComponents.CompoundButton.Switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:padding="10dp" />
</RelativeLayout>

</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,11 @@ class BraveVPNService :
builder.setSmallIcon(R.drawable.ic_notification_icon).setContentIntent(pendingIntent)
builder.color = ContextCompat.getColor(this, getAccentColor(persistentState.theme))

if (persistentState.persistentNotification)
{
builder.setOngoing(true)
}

// New action button options in the notification
// 1. Pause / Resume, Stop action button.
// 2. RethinkDNS modes (dns & dns+firewall mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ class PersistentState(context: Context) : SimpleKrate(context), KoinComponent {
var shouldRequestNotificationPermission by
booleanPref("notification_permission_request").withDefault<Boolean>(true)

// make notification persistent
var persistentNotification by
booleanPref("persistent_notification").withDefault<Boolean>(false)

// biometric authentication
var biometricAuth by booleanPref("biometric_authentication").withDefault<Boolean>(false)

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,9 @@
<string name="settings_app_notification_a13_heading" translatable="true">App Notification</string>
<string name="settings_app_notification_a13_desc" translatable="true">Enable notification permission for the app</string>

<string name="settings_app_notification_persistent_heading" translatable="true">Persistent Notification</string>
<string name="settings_app_notification_persistent_desc" translatable="true">Make the notification persistent</string>

<string name="settings_theme_heading" translatable="true">Appearance</string>
<string name="settings_theme_desc" translatable="true">Dark/light theme</string>

Expand Down

0 comments on commit 859519a

Please sign in to comment.