@@ -108,8 +108,7 @@ internal fun onReceived(context: Context, mapData: Map<String, String>) {
108
108
private fun removeNotification (context : Context , fcmMessage : RemoveFcmMessage ) {
109
109
// We have an FCM message telling us that some Zulip messages were read
110
110
// 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.
113
112
114
113
// There may be a lot of messages mentioned here, across a lot of
115
114
// conversations. But they'll all be for one identity, so they'll
@@ -121,7 +120,6 @@ private fun removeNotification(context: Context, fcmMessage: RemoveFcmMessage) {
121
120
// they're read, so we wait until we're ready to remove the whole
122
121
// conversation's notification.
123
122
// See: https://github.com/zulip/zulip-mobile/pull/4842#pullrequestreview-725817909
124
- var haveRemaining = false
125
123
for (statusBarNotification in context.notificationManager.activeNotifications) {
126
124
// The StatusBarNotification object describes an active notification in the UI.
127
125
// Its relationship to the Notification and to our metadata is a bit confusing:
@@ -136,27 +134,14 @@ private fun removeNotification(context: Context, fcmMessage: RemoveFcmMessage) {
136
134
// Don't act on notifications that are for other Zulip accounts/identities.
137
135
if (notification.group != groupKey) continue ;
138
136
139
- // Don't act on the summary notification for the group.
140
- if (statusBarNotification.tag == groupKey) continue ;
141
-
142
137
val lastMessageId = notification.extras.getInt(" lastZulipMessageId" )
143
138
if (fcmMessage.messageIds.contains(lastMessageId)) {
144
139
// The latest Zulip message in this conversation was read.
145
140
// That's our cue to cancel the notification for the conversation.
146
141
NotificationManagerCompat .from(context)
147
142
.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
152
143
}
153
144
}
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
- }
160
145
}
161
146
162
147
/* *
@@ -345,31 +330,10 @@ private fun updateNotification(
345
330
setAutoCancel(true )
346
331
}.build()
347
332
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
-
368
333
NotificationManagerCompat .from(context).apply {
369
334
// This posts the notifications. If there is an existing notification
370
335
// with the same tag and ID as one of these calls to `notify`, this will
371
336
// replace it with the updated notification we've just constructed.
372
- notify(groupKey, NOTIFICATION_ID , summaryNotification)
373
337
notify(conversationKey, NOTIFICATION_ID , notification)
374
338
}
375
339
}
0 commit comments