add a default group for notifications
This commit is contained in:
parent
d953507d2a
commit
692c620dae
2 changed files with 9 additions and 0 deletions
|
@ -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"
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<string name="channel_notifications_default_name">Notifications (default priority)</string>
|
||||
<string name="channel_notifications_high_name">Notifications (high priority)</string>
|
||||
<string name="channel_notifications_max_name">Notifications (max priority)</string>
|
||||
<string name="channel_notifications_group_default_name">Standard</string>
|
||||
<string name="channel_subscriber_service_name">Subscription Service</string>
|
||||
<string name="channel_subscriber_notification_title">Listening for incoming notifications</string>
|
||||
<string name="channel_subscriber_notification_instant_text">Subscribed to instant delivery topics</string>
|
||||
|
|
Loading…
Reference in a new issue