summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-06-26 17:04:42 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-07-01 20:22:02 +0000
commit76c014b878399d375dad036b049cf2575bba5d01 (patch)
treedee639a1c02efaae64f1f34cdabea4e3c52a4ff7
parent7c241c641b1b4796c529e270e9a775c6e1eed42f (diff)
downloadmullvadvpn-76c014b878399d375dad036b049cf2575bba5d01.tar.xz
mullvadvpn-76c014b878399d375dad036b049cf2575bba5d01.zip
Create `NotificationWithUrl` helper class
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrl.kt21
1 files changed, 21 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrl.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrl.kt
new file mode 100644
index 0000000000..4257f8d2a6
--- /dev/null
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrl.kt
@@ -0,0 +1,21 @@
+package net.mullvad.mullvadvpn.ui.notification
+
+import android.content.Context
+import android.content.Intent
+import android.net.Uri
+
+abstract class NotificationWithUrl(
+ protected val context: Context,
+ urlId: Int
+) : InAppNotification() {
+ private val url = Uri.parse(context.getString(urlId))
+
+ protected val openUrl: suspend () -> Unit = {
+ context.startActivity(Intent(Intent.ACTION_VIEW, url))
+ }
+
+ init {
+ onClick = openUrl
+ showIcon = true
+ }
+}