Skip to content

Commit 5a951a2

Browse files
committed
notifications: Remove Android summary notification.
Removes the summary notification from the notification group in NotificationManager.kt, and removes logic around removing the summary notification when Zulip messages are read. This change allows the user to tap on the body of the notification to open the app, which was not possible with the summary notification (only the chevron would expand the notification, which would then allow the user to interact with the individual notifications below it. Please note that removing the summary notification breaks proper grouping: multiple private messages from the same user will correctly be grouped together, but notifications for different stream conversations appear in separate notifications. This was tested manually. Fixes part of zulip#5242.
1 parent b1eba83 commit 5a951a2

File tree

1 file changed

+1
-37
lines changed

1 file changed

+1
-37
lines changed

android/app/src/main/java/com/zulipmobile/notifications/NotificationUiManager.kt

+1-37
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ internal fun onReceived(context: Context, mapData: Map<String, String>) {
108108
private fun removeNotification(context: Context, fcmMessage: RemoveFcmMessage) {
109109
// We have an FCM message telling us that some Zulip messages were read
110110
// and should no longer appear as notifications. We'll remove their
111-
// conversations' notifications, if appropriate, and then the whole
112-
// notification group if it's now empty.
111+
// conversations' notifications, if appropriate.
113112

114113
// There may be a lot of messages mentioned here, across a lot of
115114
// conversations. But they'll all be for one identity, so they'll
@@ -121,7 +120,6 @@ private fun removeNotification(context: Context, fcmMessage: RemoveFcmMessage) {
121120
// they're read, so we wait until we're ready to remove the whole
122121
// conversation's notification.
123122
// See: https://github.com/zulip/zulip-mobile/pull/4842#pullrequestreview-725817909
124-
var haveRemaining = false
125123
for (statusBarNotification in context.notificationManager.activeNotifications) {
126124
// The StatusBarNotification object describes an active notification in the UI.
127125
// Its relationship to the Notification and to our metadata is a bit confusing:
@@ -136,27 +134,14 @@ private fun removeNotification(context: Context, fcmMessage: RemoveFcmMessage) {
136134
// Don't act on notifications that are for other Zulip accounts/identities.
137135
if (notification.group != groupKey) continue;
138136

139-
// Don't act on the summary notification for the group.
140-
if (statusBarNotification.tag == groupKey) continue;
141-
142137
val lastMessageId = notification.extras.getInt("lastZulipMessageId")
143138
if (fcmMessage.messageIds.contains(lastMessageId)) {
144139
// The latest Zulip message in this conversation was read.
145140
// That's our cue to cancel the notification for the conversation.
146141
NotificationManagerCompat.from(context)
147142
.cancel(statusBarNotification.tag, statusBarNotification.id)
148-
} else {
149-
// This notification is for another conversation that's still unread.
150-
// We won't cancel the summary notification.
151-
haveRemaining = true
152143
}
153144
}
154-
155-
if (!haveRemaining) {
156-
// The notification group is now empty; it had no notifications we didn't
157-
// just cancel, except the summary notification. Cancel that one too.
158-
NotificationManagerCompat.from(context).cancel(groupKey, NOTIFICATION_ID)
159-
}
160145
}
161146

162147
/**
@@ -345,31 +330,10 @@ private fun updateNotification(
345330
setAutoCancel(true)
346331
}.build()
347332

348-
val summaryNotification = NotificationCompat.Builder(context, CHANNEL_ID).apply {
349-
setGroup(groupKey)
350-
setGroupSummary(true)
351-
352-
color = context.getColor(R.color.brandColor)
353-
setSmallIcon(if (BuildConfig.DEBUG) R.mipmap.ic_launcher else R.drawable.zulip_notification)
354-
355-
// For the summary we use an "inbox-style" notification, as recommended here:
356-
// https://developer.android.com/training/notify-user/group#set_a_group_summary
357-
setStyle(NotificationCompat.InboxStyle()
358-
// TODO(#5115): Use the org's friendly name instead of its URL.
359-
.setSummaryText(fcmMessage.identity.realmUri.toString())
360-
// TODO: Use addLine and setBigContentTitle to add some summary info when collapsed?
361-
// (See example in the linked doc.)
362-
)
363-
364-
// TODO Does this do something useful? There isn't a way to open these summary notifs.
365-
setAutoCancel(true)
366-
}.build()
367-
368333
NotificationManagerCompat.from(context).apply {
369334
// This posts the notifications. If there is an existing notification
370335
// with the same tag and ID as one of these calls to `notify`, this will
371336
// replace it with the updated notification we've just constructed.
372-
notify(groupKey, NOTIFICATION_ID, summaryNotification)
373337
notify(conversationKey, NOTIFICATION_ID, notification)
374338
}
375339
}

0 commit comments

Comments
 (0)