diff options
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()}") +} |
