diff options
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt index 7a638721ac..0f4646335c 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt @@ -37,26 +37,36 @@ class NotificationChannel( } } - fun buildNotification(intent: PendingIntent, title: String): Notification { - return buildNotification(intent, title, emptyList()) + fun buildNotification( + intent: PendingIntent, + title: String, + deleteIntent: PendingIntent? = null + ): Notification { + return buildNotification(intent, title, emptyList(), deleteIntent) } - fun buildNotification(intent: PendingIntent, title: Int): Notification { - return buildNotification(intent, title, emptyList()) + fun buildNotification( + intent: PendingIntent, + title: Int, + deleteIntent: PendingIntent? = null + ): Notification { + return buildNotification(intent, title, emptyList(), deleteIntent) } fun buildNotification( pendingIntent: PendingIntent, title: Int, - actions: List<NotificationCompat.Action> + actions: List<NotificationCompat.Action>, + deleteIntent: PendingIntent? = null ): Notification { - return buildNotification(pendingIntent, context.getString(title), actions) + return buildNotification(pendingIntent, context.getString(title), actions, deleteIntent) } fun buildNotification( pendingIntent: PendingIntent, title: String, - actions: List<NotificationCompat.Action> + actions: List<NotificationCompat.Action>, + deleteIntent: PendingIntent? = null ): Notification { val builder = NotificationCompat.Builder(context, id) .setSmallIcon(R.drawable.small_logo_black) @@ -68,6 +78,10 @@ class NotificationChannel( builder.addAction(action) } + deleteIntent?.let { intent -> + builder.setDeleteIntent(intent) + } + return builder.build() } } |
