diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-06-26 17:08:29 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-01 20:22:02 +0000 |
| commit | 3e221112d304fc50a0ddf7e61b34ff15a81ac068 (patch) | |
| tree | 8a2e06283a6c63c69e116b5564a385e6f2d29f32 /android/src | |
| parent | 5e49b276c9dd82d3e2de7494d4c70e3660fb7c28 (diff) | |
| download | mullvadvpn-3e221112d304fc50a0ddf7e61b34ff15a81ac068.tar.xz mullvadvpn-3e221112d304fc50a0ddf7e61b34ff15a81ac068.zip | |
Create `NotificationWithUrlWithToken` helper class
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrlWithToken.kt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrlWithToken.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrlWithToken.kt new file mode 100644 index 0000000000..2c8c713a83 --- /dev/null +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrlWithToken.kt @@ -0,0 +1,25 @@ +package net.mullvad.mullvadvpn.ui.notification + +import android.content.Context +import android.content.Intent +import android.net.Uri +import net.mullvad.mullvadvpn.service.MullvadDaemon + +abstract class NotificationWithUrlWithToken( + protected val context: Context, + protected val daemon: MullvadDaemon, + urlId: Int +) : InAppNotification() { + private val url = context.getString(urlId) + + protected val openUrl: suspend () -> Unit = { + context.startActivity(Intent(Intent.ACTION_VIEW, buildUrl())) + } + + init { + onClick = openUrl + showIcon = true + } + + private fun buildUrl() = Uri.parse("$url?token=${daemon.getWwwAuthToken()}") +} |
