From 5399d003e40fc1068e5f69814bbf2b120cc44096 Mon Sep 17 00:00:00 2001 From: Niko Diamadis Date: Fri, 17 Feb 2023 15:45:41 +0100 Subject: [PATCH] Shrink signature of channel fallback creation method --- .../main/kotlin/com/github/gotify/NotificationSupport.kt | 7 ++++--- .../kotlin/com/github/gotify/service/WebSocketService.kt | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/github/gotify/NotificationSupport.kt b/app/src/main/kotlin/com/github/gotify/NotificationSupport.kt index 92bceea..dd27c22 100644 --- a/app/src/main/kotlin/com/github/gotify/NotificationSupport.kt +++ b/app/src/main/kotlin/com/github/gotify/NotificationSupport.kt @@ -3,6 +3,7 @@ package com.github.gotify import android.app.NotificationChannel import android.app.NotificationChannelGroup import android.app.NotificationManager +import android.app.Service import android.content.Context import android.graphics.Color import android.os.Build @@ -99,13 +100,13 @@ internal object NotificationSupport { @RequiresApi(api = Build.VERSION_CODES.O) fun createChannelIfNonexistent( context: Context, - notificationManager: NotificationManager, groupId: String, - groupName: String, channelId: String ) { if (!doesNotificationChannelExist(context, channelId)) { - createAppChannels(context, notificationManager, groupId, groupName) + val notificationManager = (context as Service) + .getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + createAppChannels(context, notificationManager, groupId, groupId) } } diff --git a/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt b/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt index 2d6a98c..11372b0 100644 --- a/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt +++ b/app/src/main/kotlin/com/github/gotify/service/WebSocketService.kt @@ -5,7 +5,6 @@ import android.app.Notification import android.app.NotificationManager import android.app.PendingIntent import android.app.Service -import android.content.Context import android.content.Intent import android.content.IntentFilter import android.graphics.Color @@ -320,8 +319,6 @@ internal class WebSocketService : Service() { channelId = NotificationSupport.getChannelID(priority, appId.toString()) NotificationSupport.createChannelIfNonexistent( this, - (this.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager), - appId.toString(), appId.toString(), channelId )