Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set VPN notification persistent #1139

Merged
merged 2 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading