diff options
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>, |
