From 692c620dae8f1651472f5ba6c9b698770487f695 Mon Sep 17 00:00:00 2001 From: Markus Doits Date: Wed, 30 Nov 2022 21:51:44 +0100 Subject: [PATCH] add a default group for notifications --- .../main/java/io/heckel/ntfy/msg/NotificationService.kt | 8 ++++++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 9 insertions(+) diff --git a/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt b/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt index 7913693..068426d 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/NotificationService.kt @@ -345,10 +345,17 @@ class NotificationService(val context: Context) { } else -> NotificationChannel(toChannelId(name, priority), context.getString(R.string.channel_notifications_default_name), NotificationManager.IMPORTANCE_DEFAULT) } + maybeCreateNotificationChannelGroup(DEFAULT_GROUP_ID, context.getString(R.string.channel_notifications_group_default_name)) + channel.setGroup(DEFAULT_GROUP_ID) + notificationManager.createNotificationChannel(channel) } } + private fun maybeCreateNotificationChannelGroup(id: String, name: String) { + notificationManager.createNotificationChannelGroup(NotificationChannelGroup(id, name)) + } + private fun toChannelId(name: String, priority: Int): String { return when (priority) { 1 -> name + PRIORITY_MIN @@ -416,6 +423,7 @@ class NotificationService(val context: Context) { private const val TAG = "NtfyNotifService" private const val DEFAULT_CHANNEL = "ntfy" + private const val DEFAULT_GROUP_ID = "ntfy" private const val PRIORITY_MIN = "-min" private const val PRIORITY_LOW = "-low" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 59c9817..ee42d95 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -7,6 +7,7 @@ Notifications (default priority) Notifications (high priority) Notifications (max priority) + Standard Subscription Service Listening for incoming notifications Subscribed to instant delivery topics