fix(notification): set badge count via setNumber() for multi-sender notifications
This commit is contained in:
parent
22112e7978
commit
ab2cbff8ba
1 changed files with 12 additions and 6 deletions
|
|
@ -111,19 +111,22 @@ internal class NotificationHelper @Inject constructor(
|
|||
if (shouldSuppressNotification(senderId)) return false
|
||||
|
||||
val senderNotificationId = senderId.hashCode()
|
||||
val (contentText, pendingIntent) = synchronized(activeSenderNotificationIds) {
|
||||
val (contentText, pendingIntent, senderCount) = synchronized(activeSenderNotificationIds) {
|
||||
activeSenderNotificationIds.add(senderNotificationId)
|
||||
activeSenderNamesById[senderNotificationId] = senderUsername
|
||||
val names = activeSenderNamesById.values.toList()
|
||||
if (activeSenderNotificationIds.size == 1) {
|
||||
Pair(
|
||||
val count = activeSenderNotificationIds.size
|
||||
if (count == 1) {
|
||||
Triple(
|
||||
"Neue Nachricht von $senderUsername",
|
||||
buildChatPendingIntent(senderId, senderUsername)
|
||||
buildChatPendingIntent(senderId, senderUsername),
|
||||
count
|
||||
)
|
||||
} else {
|
||||
Pair(
|
||||
Triple(
|
||||
buildSummaryText(names),
|
||||
buildMessagesPendingIntent()
|
||||
buildMessagesPendingIntent(),
|
||||
count
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -133,6 +136,7 @@ internal class NotificationHelper @Inject constructor(
|
|||
.setContentTitle("Bollwerk")
|
||||
.setContentText(contentText)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setNumber(senderCount)
|
||||
.setAutoCancel(false)
|
||||
.setOngoing(true)
|
||||
.setContentIntent(pendingIntent)
|
||||
|
|
@ -175,11 +179,13 @@ internal class NotificationHelper @Inject constructor(
|
|||
if (remainingText == null) {
|
||||
notificationManager.notify(MessagingService.NOTIFICATION_ID, buildIdleNotification())
|
||||
} else {
|
||||
val remainingCount = activeSenderNotificationIds.size
|
||||
val updatedNotification = NotificationCompat.Builder(context, CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_notification_message)
|
||||
.setContentTitle("Bollwerk")
|
||||
.setContentText(remainingText)
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setNumber(remainingCount)
|
||||
.setAutoCancel(false)
|
||||
.setOngoing(true)
|
||||
.setContentIntent(buildMessagesPendingIntent())
|
||||
|
|
|
|||
Loading…
Reference in a new issue