diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-10-03 21:15:34 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-10-05 12:32:42 +0000 |
| commit | 8ff831b8d60ab6a95db965890b0abbefe283fb67 (patch) | |
| tree | 81c4bdfecb9d40d11553d7399f11f031e315d577 /android | |
| parent | df2c5877ab88adaa6787d50308c0d1ea467db934 (diff) | |
| download | mullvadvpn-8ff831b8d60ab6a95db965890b0abbefe283fb67.tar.xz mullvadvpn-8ff831b8d60ab6a95db965890b0abbefe283fb67.zip | |
Allow specifying intent for notification dismissal
Diffstat (limited to 'android')
| -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() } } |
