-
Notifications
You must be signed in to change notification settings - Fork 308
notif: Create summary notification #703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
499573c
c665d6e
c7ee2d3
365f9da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,27 +89,30 @@ class NotificationDisplayManager { | |
} | ||
} | ||
|
||
static void _onMessageFcmMessage(MessageFcmMessage data, Map<String, dynamic> dataJson) { | ||
static Future<void> _onMessageFcmMessage(MessageFcmMessage data, Map<String, dynamic> dataJson) async { | ||
assert(debugLog('notif message content: ${data.content}')); | ||
final zulipLocalizations = GlobalLocalizations.zulipLocalizations; | ||
final title = switch (data.recipient) { | ||
FcmMessageStreamRecipient(:var streamName?, :var topic) => | ||
'$streamName > $topic', | ||
'#$streamName > $topic', | ||
FcmMessageStreamRecipient(:var topic) => | ||
'(unknown channel) > $topic', // TODO get stream name from data | ||
'#(unknown channel) > $topic', // TODO get stream name from data | ||
FcmMessageDmRecipient(:var allRecipientIds) when allRecipientIds.length > 2 => | ||
zulipLocalizations.notifGroupDmConversationLabel( | ||
data.senderFullName, allRecipientIds.length - 2), // TODO use others' names, from data | ||
FcmMessageDmRecipient() => | ||
data.senderFullName, | ||
}; | ||
final conversationKey = _conversationKey(data); | ||
ZulipBinding.instance.androidNotificationHost.notify( | ||
final groupKey = _groupKey(data); | ||
final conversationKey = _conversationKey(data, groupKey); | ||
|
||
await ZulipBinding.instance.androidNotificationHost.notify( | ||
// TODO the notification ID can be constant, instead of matching requestCode | ||
// (This is a legacy of `flutter_local_notifications`.) | ||
id: notificationIdAsHashOf(conversationKey), | ||
tag: conversationKey, | ||
channelId: NotificationChannelManager.kChannelId, | ||
groupKey: groupKey, | ||
|
||
contentTitle: title, | ||
contentText: data.content, | ||
|
@@ -139,6 +142,22 @@ class NotificationDisplayManager { | |
// TODO this doesn't set the Intent flags we set in zulip-mobile; is that OK? | ||
// (This is a legacy of `flutter_local_notifications`.) | ||
), | ||
autoCancel: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I see that zulip-mobile also does this ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved this to a separate commit — it's not really needed for Group summary notifications, but was added just to make the UX better, and match the zulip-mobile implementation. |
||
); | ||
|
||
await ZulipBinding.instance.androidNotificationHost.notify( | ||
id: notificationIdAsHashOf(groupKey), | ||
tag: groupKey, | ||
channelId: NotificationChannelManager.kChannelId, | ||
groupKey: groupKey, | ||
isGroupSummary: true, | ||
|
||
color: kZulipBrandColor.value, | ||
// TODO vary notification icon for debug | ||
smallIconResourceName: 'zulip_notification', // This name must appear in keep.xml too: https://github.com/zulip/zulip-flutter/issues/528 | ||
inboxStyle: InboxStyle( | ||
// TODO(#570) Show organization name, not URL | ||
summaryText: data.realmUri.toString()), | ||
Comment on lines
+158
to
+160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tldr: No, #128 will be fixed by #718 What #128 is talking about is actually called "MessagingStyle" notifications on Android, and here's how zulip-mobile implements it. Whereas the usage here of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also updated (main) commit description with the doc link, even though it was already present in the previous commit. |
||
); | ||
} | ||
|
||
|
@@ -157,8 +176,7 @@ class NotificationDisplayManager { | |
| ((bytes[3] & 0x7f) << 24); | ||
} | ||
|
||
static String _conversationKey(MessageFcmMessage data) { | ||
final groupKey = _groupKey(data); | ||
static String _conversationKey(MessageFcmMessage data, String groupKey) { | ||
final conversation = switch (data.recipient) { | ||
FcmMessageStreamRecipient(:var streamId, :var topic) => 'stream:$streamId:$topic', | ||
FcmMessageDmRecipient(:var allRecipientIds) => 'dm:${allRecipientIds.join(',')}', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A general rule of thumb would be if this is an unrelated commit (e.g., its a nice to have commit, but isn't dependent on the later ones), you could move it earlier in the commit sequence?