Skip to content

Commit af4fc71

Browse files
deps: Upgrade pigeon to 22.7.2
Fixes: zulip#942 And migrate to using non-nullable generic types. Changelog: https://pub.dev/packages/pigeon/changelog#2272
1 parent 117f863 commit af4fc71

File tree

8 files changed

+259
-253
lines changed

8 files changed

+259
-253
lines changed

android/app/src/main/kotlin/com/zulip/flutter/Notifications.g.kt

Lines changed: 74 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v20.0.2), do not edit directly.
1+
// Autogenerated from Pigeon (v22.7.2), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")
44

@@ -7,7 +7,9 @@ package com.zulip.flutter
77
import android.util.Log
88
import io.flutter.plugin.common.BasicMessageChannel
99
import io.flutter.plugin.common.BinaryMessenger
10+
import io.flutter.plugin.common.EventChannel
1011
import io.flutter.plugin.common.MessageCodec
12+
import io.flutter.plugin.common.StandardMethodCodec
1113
import io.flutter.plugin.common.StandardMessageCodec
1214
import java.io.ByteArrayOutputStream
1315
import java.nio.ByteBuffer
@@ -64,17 +66,16 @@ data class NotificationChannel (
6466
val lightsEnabled: Boolean? = null,
6567
val soundUrl: String? = null,
6668
val vibrationPattern: LongArray? = null
67-
68-
) {
69+
)
70+
{
6971
companion object {
70-
@Suppress("LocalVariableName")
71-
fun fromList(__pigeon_list: List<Any?>): NotificationChannel {
72-
val id = __pigeon_list[0] as String
73-
val importance = __pigeon_list[1].let { num -> if (num is Int) num.toLong() else num as Long }
74-
val name = __pigeon_list[2] as String?
75-
val lightsEnabled = __pigeon_list[3] as Boolean?
76-
val soundUrl = __pigeon_list[4] as String?
77-
val vibrationPattern = __pigeon_list[5] as LongArray?
72+
fun fromList(pigeonVar_list: List<Any?>): NotificationChannel {
73+
val id = pigeonVar_list[0] as String
74+
val importance = pigeonVar_list[1] as Long
75+
val name = pigeonVar_list[2] as String?
76+
val lightsEnabled = pigeonVar_list[3] as Boolean?
77+
val soundUrl = pigeonVar_list[4] as String?
78+
val vibrationPattern = pigeonVar_list[5] as LongArray?
7879
return NotificationChannel(id, importance, name, lightsEnabled, soundUrl, vibrationPattern)
7980
}
8081
}
@@ -104,14 +105,13 @@ data class AndroidIntent (
104105
val dataUrl: String,
105106
/** A combination of flags from [IntentFlag]. */
106107
val flags: Long
107-
108-
) {
108+
)
109+
{
109110
companion object {
110-
@Suppress("LocalVariableName")
111-
fun fromList(__pigeon_list: List<Any?>): AndroidIntent {
112-
val action = __pigeon_list[0] as String
113-
val dataUrl = __pigeon_list[1] as String
114-
val flags = __pigeon_list[2].let { num -> if (num is Int) num.toLong() else num as Long }
111+
fun fromList(pigeonVar_list: List<Any?>): AndroidIntent {
112+
val action = pigeonVar_list[0] as String
113+
val dataUrl = pigeonVar_list[1] as String
114+
val flags = pigeonVar_list[2] as Long
115115
return AndroidIntent(action, dataUrl, flags)
116116
}
117117
}
@@ -139,14 +139,13 @@ data class PendingIntent (
139139
* with `Intent`; see Android docs for `PendingIntent.getActivity`.
140140
*/
141141
val flags: Long
142-
143-
) {
142+
)
143+
{
144144
companion object {
145-
@Suppress("LocalVariableName")
146-
fun fromList(__pigeon_list: List<Any?>): PendingIntent {
147-
val requestCode = __pigeon_list[0].let { num -> if (num is Int) num.toLong() else num as Long }
148-
val intent = __pigeon_list[1] as AndroidIntent
149-
val flags = __pigeon_list[2].let { num -> if (num is Int) num.toLong() else num as Long }
145+
fun fromList(pigeonVar_list: List<Any?>): PendingIntent {
146+
val requestCode = pigeonVar_list[0] as Long
147+
val intent = pigeonVar_list[1] as AndroidIntent
148+
val flags = pigeonVar_list[2] as Long
150149
return PendingIntent(requestCode, intent, flags)
151150
}
152151
}
@@ -168,12 +167,11 @@ data class PendingIntent (
168167
*/
169168
data class InboxStyle (
170169
val summaryText: String
171-
172-
) {
170+
)
171+
{
173172
companion object {
174-
@Suppress("LocalVariableName")
175-
fun fromList(__pigeon_list: List<Any?>): InboxStyle {
176-
val summaryText = __pigeon_list[0] as String
173+
fun fromList(pigeonVar_list: List<Any?>): InboxStyle {
174+
val summaryText = pigeonVar_list[0] as String
177175
return InboxStyle(summaryText)
178176
}
179177
}
@@ -205,14 +203,13 @@ data class Person (
205203
val iconBitmap: ByteArray? = null,
206204
val key: String,
207205
val name: String
208-
209-
) {
206+
)
207+
{
210208
companion object {
211-
@Suppress("LocalVariableName")
212-
fun fromList(__pigeon_list: List<Any?>): Person {
213-
val iconBitmap = __pigeon_list[0] as ByteArray?
214-
val key = __pigeon_list[1] as String
215-
val name = __pigeon_list[2] as String
209+
fun fromList(pigeonVar_list: List<Any?>): Person {
210+
val iconBitmap = pigeonVar_list[0] as ByteArray?
211+
val key = pigeonVar_list[1] as String
212+
val name = pigeonVar_list[2] as String
216213
return Person(iconBitmap, key, name)
217214
}
218215
}
@@ -236,14 +233,13 @@ data class MessagingStyleMessage (
236233
val text: String,
237234
val timestampMs: Long,
238235
val person: Person
239-
240-
) {
236+
)
237+
{
241238
companion object {
242-
@Suppress("LocalVariableName")
243-
fun fromList(__pigeon_list: List<Any?>): MessagingStyleMessage {
244-
val text = __pigeon_list[0] as String
245-
val timestampMs = __pigeon_list[1].let { num -> if (num is Int) num.toLong() else num as Long }
246-
val person = __pigeon_list[2] as Person
239+
fun fromList(pigeonVar_list: List<Any?>): MessagingStyleMessage {
240+
val text = pigeonVar_list[0] as String
241+
val timestampMs = pigeonVar_list[1] as Long
242+
val person = pigeonVar_list[2] as Person
247243
return MessagingStyleMessage(text, timestampMs, person)
248244
}
249245
}
@@ -266,17 +262,16 @@ data class MessagingStyleMessage (
266262
data class MessagingStyle (
267263
val user: Person,
268264
val conversationTitle: String? = null,
269-
val messages: List<MessagingStyleMessage?>,
265+
val messages: List<MessagingStyleMessage>,
270266
val isGroupConversation: Boolean
271-
272-
) {
267+
)
268+
{
273269
companion object {
274-
@Suppress("LocalVariableName")
275-
fun fromList(__pigeon_list: List<Any?>): MessagingStyle {
276-
val user = __pigeon_list[0] as Person
277-
val conversationTitle = __pigeon_list[1] as String?
278-
val messages = __pigeon_list[2] as List<MessagingStyleMessage?>
279-
val isGroupConversation = __pigeon_list[3] as Boolean
270+
fun fromList(pigeonVar_list: List<Any?>): MessagingStyle {
271+
val user = pigeonVar_list[0] as Person
272+
val conversationTitle = pigeonVar_list[1] as String?
273+
val messages = pigeonVar_list[2] as List<MessagingStyleMessage>
274+
val isGroupConversation = pigeonVar_list[3] as Boolean
280275
return MessagingStyle(user, conversationTitle, messages, isGroupConversation)
281276
}
282277
}
@@ -299,14 +294,13 @@ data class MessagingStyle (
299294
*/
300295
data class Notification (
301296
val group: String,
302-
val extras: Map<String?, String?>
303-
304-
) {
297+
val extras: Map<String, String>
298+
)
299+
{
305300
companion object {
306-
@Suppress("LocalVariableName")
307-
fun fromList(__pigeon_list: List<Any?>): Notification {
308-
val group = __pigeon_list[0] as String
309-
val extras = __pigeon_list[1] as Map<String?, String?>
301+
fun fromList(pigeonVar_list: List<Any?>): Notification {
302+
val group = pigeonVar_list[0] as String
303+
val extras = pigeonVar_list[1] as Map<String, String>
310304
return Notification(group, extras)
311305
}
312306
}
@@ -329,14 +323,13 @@ data class StatusBarNotification (
329323
val id: Long,
330324
val tag: String,
331325
val notification: Notification
332-
333-
) {
326+
)
327+
{
334328
companion object {
335-
@Suppress("LocalVariableName")
336-
fun fromList(__pigeon_list: List<Any?>): StatusBarNotification {
337-
val id = __pigeon_list[0].let { num -> if (num is Int) num.toLong() else num as Long }
338-
val tag = __pigeon_list[1] as String
339-
val notification = __pigeon_list[2] as Notification
329+
fun fromList(pigeonVar_list: List<Any?>): StatusBarNotification {
330+
val id = pigeonVar_list[0] as Long
331+
val tag = pigeonVar_list[1] as String
332+
val notification = pigeonVar_list[2] as Notification
340333
return StatusBarNotification(id, tag, notification)
341334
}
342335
}
@@ -370,14 +363,13 @@ data class StoredNotificationSound (
370363
val isOwned: Boolean,
371364
/** A `content://…` URL pointing to the sound file. */
372365
val contentUrl: String
373-
374-
) {
366+
)
367+
{
375368
companion object {
376-
@Suppress("LocalVariableName")
377-
fun fromList(__pigeon_list: List<Any?>): StoredNotificationSound {
378-
val fileName = __pigeon_list[0] as String
379-
val isOwned = __pigeon_list[1] as Boolean
380-
val contentUrl = __pigeon_list[2] as String
369+
fun fromList(pigeonVar_list: List<Any?>): StoredNotificationSound {
370+
val fileName = pigeonVar_list[0] as String
371+
val isOwned = pigeonVar_list[1] as Boolean
372+
val contentUrl = pigeonVar_list[2] as String
381373
return StoredNotificationSound(fileName, isOwned, contentUrl)
382374
}
383375
}
@@ -389,7 +381,7 @@ data class StoredNotificationSound (
389381
)
390382
}
391383
}
392-
private object NotificationsPigeonCodec : StandardMessageCodec() {
384+
private open class NotificationsPigeonCodec : StandardMessageCodec() {
393385
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
394386
return when (type) {
395387
129.toByte() -> {
@@ -561,7 +553,7 @@ interface AndroidNotificationHostApi {
561553
* https://developer.android.com/reference/kotlin/android/app/NotificationManager.html#notify
562554
* https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder
563555
*/
564-
fun notify(tag: String?, id: Long, autoCancel: Boolean?, channelId: String, color: Long?, contentIntent: PendingIntent?, contentText: String?, contentTitle: String?, extras: Map<String?, String?>?, groupKey: String?, inboxStyle: InboxStyle?, isGroupSummary: Boolean?, messagingStyle: MessagingStyle?, number: Long?, smallIconResourceName: String?)
556+
fun notify(tag: String?, id: Long, autoCancel: Boolean?, channelId: String, color: Long?, contentIntent: PendingIntent?, contentText: String?, contentTitle: String?, extras: Map<String, String>?, groupKey: String?, inboxStyle: InboxStyle?, isGroupSummary: Boolean?, messagingStyle: MessagingStyle?, number: Long?, smallIconResourceName: String?)
565557
/**
566558
* Wraps `androidx.core.app.NotificationManagerCompat.getActiveNotifications`,
567559
* combined with `androidx.core.app.NotificationCompat.MessagingStyle.extractMessagingStyleFromNotification`.
@@ -597,7 +589,7 @@ interface AndroidNotificationHostApi {
597589
companion object {
598590
/** The codec used by AndroidNotificationHostApi. */
599591
val codec: MessageCodec<Any?> by lazy {
600-
NotificationsPigeonCodec
592+
NotificationsPigeonCodec()
601593
}
602594
/** Sets up an instance of `AndroidNotificationHostApi` to handle messages through the `binaryMessenger`. */
603595
@JvmOverloads
@@ -693,19 +685,19 @@ interface AndroidNotificationHostApi {
693685
channel.setMessageHandler { message, reply ->
694686
val args = message as List<Any?>
695687
val tagArg = args[0] as String?
696-
val idArg = args[1].let { num -> if (num is Int) num.toLong() else num as Long }
688+
val idArg = args[1] as Long
697689
val autoCancelArg = args[2] as Boolean?
698690
val channelIdArg = args[3] as String
699-
val colorArg = args[4].let { num -> if (num is Int) num.toLong() else num as Long? }
691+
val colorArg = args[4] as Long?
700692
val contentIntentArg = args[5] as PendingIntent?
701693
val contentTextArg = args[6] as String?
702694
val contentTitleArg = args[7] as String?
703-
val extrasArg = args[8] as Map<String?, String?>?
695+
val extrasArg = args[8] as Map<String, String>?
704696
val groupKeyArg = args[9] as String?
705697
val inboxStyleArg = args[10] as InboxStyle?
706698
val isGroupSummaryArg = args[11] as Boolean?
707699
val messagingStyleArg = args[12] as MessagingStyle?
708-
val numberArg = args[13].let { num -> if (num is Int) num.toLong() else num as Long? }
700+
val numberArg = args[13] as Long?
709701
val smallIconResourceNameArg = args[14] as String?
710702
val wrapped: List<Any?> = try {
711703
api.notify(tagArg, idArg, autoCancelArg, channelIdArg, colorArg, contentIntentArg, contentTextArg, contentTitleArg, extrasArg, groupKeyArg, inboxStyleArg, isGroupSummaryArg, messagingStyleArg, numberArg, smallIconResourceNameArg)
@@ -759,7 +751,7 @@ interface AndroidNotificationHostApi {
759751
channel.setMessageHandler { message, reply ->
760752
val args = message as List<Any?>
761753
val tagArg = args[0] as String?
762-
val idArg = args[1].let { num -> if (num is Int) num.toLong() else num as Long }
754+
val idArg = args[1] as Long
763755
val wrapped: List<Any?> = try {
764756
api.cancel(tagArg, idArg)
765757
listOf(null)

android/app/src/main/kotlin/com/zulip/flutter/ZulipPlugin.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private class AndroidNotificationHost(val context: Context)
183183
contentIntent: PendingIntent?,
184184
contentText: String?,
185185
contentTitle: String?,
186-
extras: Map<String?, String?>?,
186+
extras: Map<String, String>?,
187187
groupKey: String?,
188188
inboxStyle: InboxStyle?,
189189
isGroupSummary: Boolean?,
@@ -221,7 +221,7 @@ private class AndroidNotificationHost(val context: Context)
221221
val style = NotificationCompat.MessagingStyle(toAndroidPerson(messagingStyle.user))
222222
.setConversationTitle(messagingStyle.conversationTitle)
223223
.setGroupConversation(messagingStyle.isGroupConversation)
224-
messagingStyle.messages.forEach { it?.let {
224+
messagingStyle.messages.forEach { it.let {
225225
style.addMessage(NotificationCompat.MessagingStyle.Message(
226226
it.text,
227227
it.timestampMs,
@@ -268,8 +268,11 @@ private class AndroidNotificationHost(val context: Context)
268268
Notification(
269269
it.notification.group,
270270
desiredExtras
271-
.associateWith { key -> it.notification.extras.getString(key) }
272-
.filter { entry -> entry.value != null }
271+
.mapNotNull { key ->
272+
it.notification.extras.getString(key)?.let { value ->
273+
key to value
274+
} }
275+
.toMap()
273276
),
274277
)
275278
}

0 commit comments

Comments
 (0)