@@ -20,6 +20,8 @@ import '../widgets/page.dart';
20
20
import '../widgets/store.dart' ;
21
21
import '../widgets/theme.dart' ;
22
22
23
+ AndroidNotificationHostApi get _androidHost => ZulipBinding .instance.androidNotificationHost;
24
+
23
25
/// Service for configuring our Android "notification channel".
24
26
class NotificationChannelManager {
25
27
@visibleForTesting
@@ -54,7 +56,7 @@ class NotificationChannelManager {
54
56
// channel ID and delete it. See zulip-mobile's `createNotificationChannel`
55
57
// in android/app/src/main/java/com/zulipmobile/notifications/NotificationChannelManager.kt .
56
58
static Future <void > _ensureChannel () async {
57
- await ZulipBinding .instance.androidNotificationHost .createNotificationChannel (NotificationChannel (
59
+ await _androidHost .createNotificationChannel (NotificationChannel (
58
60
id: kChannelId,
59
61
name: 'Messages' , // TODO(i18n)
60
62
importance: NotificationImportance .high,
@@ -95,7 +97,7 @@ class NotificationDisplayManager {
95
97
final groupKey = _groupKey (data);
96
98
final conversationKey = _conversationKey (data, groupKey);
97
99
98
- final oldMessagingStyle = await ZulipBinding .instance.androidNotificationHost
100
+ final oldMessagingStyle = await _androidHost
99
101
.getActiveNotificationMessagingStyleByTag (conversationKey);
100
102
101
103
final MessagingStyle messagingStyle;
@@ -141,7 +143,7 @@ class NotificationDisplayManager {
141
143
name: data.senderFullName,
142
144
iconBitmap: await _fetchBitmap (data.senderAvatarUrl))));
143
145
144
- await ZulipBinding .instance.androidNotificationHost .notify (
146
+ await _androidHost .notify (
145
147
// TODO the notification ID can be constant, instead of matching requestCode
146
148
// (This is a legacy of `flutter_local_notifications`.)
147
149
id: notificationIdAsHashOf (conversationKey),
@@ -184,7 +186,7 @@ class NotificationDisplayManager {
184
186
autoCancel: true ,
185
187
);
186
188
187
- await ZulipBinding .instance.androidNotificationHost .notify (
189
+ await _androidHost .notify (
188
190
id: notificationIdAsHashOf (groupKey),
189
191
tag: groupKey,
190
192
channelId: NotificationChannelManager .kChannelId,
@@ -210,9 +212,8 @@ class NotificationDisplayManager {
210
212
assert (debugLog ('notif remove zulipMessageIds: ${data .zulipMessageIds }' ));
211
213
212
214
final groupKey = _groupKey (data);
213
- final activeNotifications =
214
- await ZulipBinding .instance.androidNotificationHost.getActiveNotifications (
215
- desiredExtras: [kExtraZulipMessageId]);
215
+ final activeNotifications = await _androidHost.getActiveNotifications (
216
+ desiredExtras: [kExtraZulipMessageId]);
216
217
217
218
var haveRemaining = false ;
218
219
for (final statusBarNotification in activeNotifications) {
@@ -237,8 +238,8 @@ class NotificationDisplayManager {
237
238
if (data.zulipMessageIds.contains (lastMessageId)) {
238
239
// The latest Zulip message in this conversation was read.
239
240
// That's our cue to cancel the notification for the conversation.
240
- await ZulipBinding .instance.androidNotificationHost
241
- . cancel ( tag: statusBarNotification.tag, id: statusBarNotification.id);
241
+ await _androidHost. cancel (
242
+ tag: statusBarNotification.tag, id: statusBarNotification.id);
242
243
assert (debugLog (' … notif cancelled.' ));
243
244
} else {
244
245
// This notification is for another conversation that's still unread.
@@ -254,8 +255,8 @@ class NotificationDisplayManager {
254
255
// Even though we enable the `autoCancel` flag for summary notification
255
256
// during creation, the summary notification doesn't get auto canceled if
256
257
// child notifications are canceled programatically as done above.
257
- await ZulipBinding .instance.androidNotificationHost
258
- . cancel ( tag: groupKey, id: notificationIdAsHashOf (groupKey));
258
+ await _androidHost. cancel (
259
+ tag: groupKey, id: notificationIdAsHashOf (groupKey));
259
260
}
260
261
}
261
262
0 commit comments