diff options
| author | Albin <albin@mullvad.net> | 2022-01-21 15:25:26 +0100 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2022-01-24 13:44:45 +0100 |
| commit | 640d74e88804be666fb2f04ff67a8ba8d3c5e37e (patch) | |
| tree | 719b28919a910bd0a489f0af54f15062ea87c452 /android/app/src | |
| parent | 965c2c703f2905019b93abab6c1645a0917cd679 (diff) | |
| download | mullvadvpn-640d74e88804be666fb2f04ff67a8ba8d3c5e37e.tar.xz mullvadvpn-640d74e88804be666fb2f04ff67a8ba8d3c5e37e.zip | |
Refactor to use NotificationChannelCompat
Diffstat (limited to 'android/app/src')
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt index e251e5b4de..54c8fe05a1 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt @@ -5,31 +5,33 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.app.PendingIntent import android.content.Context +import androidx.core.app.NotificationChannelCompat import androidx.core.app.NotificationCompat +import androidx.core.app.NotificationManagerCompat import net.mullvad.mullvadvpn.R class NotificationChannel( val context: Context, val id: String, - val name: Int, - val description: Int, - val importance: Int + name: Int, + description: Int, + importance: Int ) { private val badgeColor by lazy { context.getColor(R.color.colorPrimary) } - val notificationManager = - context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + val notificationManager = NotificationManagerCompat.from(context) init { val channelName = context.getString(name) val channelDescription = context.getString(description) - val channel = NotificationChannel(id, channelName, importance).apply { - description = channelDescription - setShowBadge(true) - } + val channel = NotificationChannelCompat.Builder(id, importance) + .setName(channelName) + .setDescription(channelDescription) + .setShowBadge(true) + .build() notificationManager.createNotificationChannel(channel) } @@ -59,7 +61,7 @@ class NotificationChannel( return buildNotification(pendingIntent, context.getString(title), actions, deleteIntent) } - fun buildNotification( + private fun buildNotification( pendingIntent: PendingIntent, title: String, actions: List<NotificationCompat.Action>, |
