diff --git a/app/src/main/java/de/bollwerk/app/notification/NotificationHelper.kt b/app/src/main/java/de/bollwerk/app/notification/NotificationHelper.kt index f6c305f..5c5b53e 100644 --- a/app/src/main/java/de/bollwerk/app/notification/NotificationHelper.kt +++ b/app/src/main/java/de/bollwerk/app/notification/NotificationHelper.kt @@ -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())