From d1832fd6b8a892a748558a8903491e46023e8ad3 Mon Sep 17 00:00:00 2001 From: Lakoja Date: Mon, 10 Mar 2025 19:47:05 +0100 Subject: [PATCH] Fix the popup content: Every notification can have an alert (scheduling them as group should still only make one sound) Also: Several name combination fixes --- .../systemnotifications/NotificationService.kt | 17 ++++++----------- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt b/app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt index 4067f10c3..0e3373bff 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/systemnotifications/NotificationService.kt @@ -402,7 +402,6 @@ class NotificationService @Inject constructor( .setCategory(NotificationCompat.CATEGORY_SOCIAL) .setGroup(typeChannelId) .setGroupSummary(true) - .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) setSoundVibrationLight(account, summaryBuilder) @@ -470,7 +469,6 @@ class NotificationService @Inject constructor( .setCategory(NotificationCompat.CATEGORY_SOCIAL) .setOnlyAlertOnce(true) .setGroup(channelId) - .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY) // Only ever alert for the summary notification setSoundVibrationLight(account, builder) @@ -583,16 +581,11 @@ class NotificationService @Inject constructor( } private fun joinNames(notifications1: List, notifications2: List): String? { - val names = java.util.ArrayList(notifications1.size + notifications2.size) + val names1 = notifications1.mapNotNull { it.notification.extras.getString(EXTRA_ACCOUNT_NAME) } + val names2 = notifications2.map { it.account.name } - for (notification in notifications1) { - val author = notification.notification.extras.getString(EXTRA_ACCOUNT_NAME) ?: continue - names.add(author) - } - - for (noti in notifications2) { - names.add(noti.account.name) - } + // Collapsing the same names + val names: List = (names1 + names2).distinct() if (names.size > 3) { val length = names.size @@ -616,6 +609,8 @@ class NotificationService @Inject constructor( names[1].unicodeWrap(), names[0].unicodeWrap() ) + } else if (names.size == 1) { + return names[0].unicodeWrap() } return null diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9163704a1..af639665c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -395,7 +395,7 @@ %1$s mentioned you %1$s, %2$s, %3$s and %4$d others - %1$s, %2$s, and %3$s + %1$s, %2$s and %3$s %1$s and %2$s %1$d new interaction