feat: Allow the sender's data being null
This commit is contained in:
parent
2490a8ee9f
commit
2f5a39416b
@ -171,30 +171,24 @@ public class Api {
|
|||||||
/** Generated class from Pigeon that represents data sent in messages. */
|
/** Generated class from Pigeon that represents data sent in messages. */
|
||||||
public static final class NotificationMessage {
|
public static final class NotificationMessage {
|
||||||
/** The sender of the message. */
|
/** The sender of the message. */
|
||||||
private @NonNull String sender;
|
private @Nullable String sender;
|
||||||
|
|
||||||
public @NonNull String getSender() {
|
public @Nullable String getSender() {
|
||||||
return sender;
|
return sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSender(@NonNull String setterArg) {
|
public void setSender(@Nullable String setterArg) {
|
||||||
if (setterArg == null) {
|
|
||||||
throw new IllegalStateException("Nonnull field \"sender\" is null.");
|
|
||||||
}
|
|
||||||
this.sender = setterArg;
|
this.sender = setterArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The jid of the sender. */
|
/** The jid of the sender. */
|
||||||
private @NonNull String jid;
|
private @Nullable String jid;
|
||||||
|
|
||||||
public @NonNull String getJid() {
|
public @Nullable String getJid() {
|
||||||
return jid;
|
return jid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJid(@NonNull String setterArg) {
|
public void setJid(@Nullable String setterArg) {
|
||||||
if (setterArg == null) {
|
|
||||||
throw new IllegalStateException("Nonnull field \"jid\" is null.");
|
|
||||||
}
|
|
||||||
this.jid = setterArg;
|
this.jid = setterArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,14 +238,14 @@ public class Api {
|
|||||||
|
|
||||||
private @Nullable String sender;
|
private @Nullable String sender;
|
||||||
|
|
||||||
public @NonNull Builder setSender(@NonNull String setterArg) {
|
public @NonNull Builder setSender(@Nullable String setterArg) {
|
||||||
this.sender = setterArg;
|
this.sender = setterArg;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable String jid;
|
private @Nullable String jid;
|
||||||
|
|
||||||
public @NonNull Builder setJid(@NonNull String setterArg) {
|
public @NonNull Builder setJid(@Nullable String setterArg) {
|
||||||
this.jid = setterArg;
|
this.jid = setterArg;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -664,6 +658,20 @@ public class Api {
|
|||||||
|
|
||||||
/** Generated class from Pigeon that represents data sent in messages. */
|
/** Generated class from Pigeon that represents data sent in messages. */
|
||||||
public static final class NotificationEvent {
|
public static final class NotificationEvent {
|
||||||
|
/** The notification id. */
|
||||||
|
private @NonNull Long id;
|
||||||
|
|
||||||
|
public @NonNull Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(@NonNull Long setterArg) {
|
||||||
|
if (setterArg == null) {
|
||||||
|
throw new IllegalStateException("Nonnull field \"id\" is null.");
|
||||||
|
}
|
||||||
|
this.id = setterArg;
|
||||||
|
}
|
||||||
|
|
||||||
/** The JID the notification was for. */
|
/** The JID the notification was for. */
|
||||||
private @NonNull String jid;
|
private @NonNull String jid;
|
||||||
|
|
||||||
@ -723,6 +731,13 @@ public class Api {
|
|||||||
|
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
|
||||||
|
private @Nullable Long id;
|
||||||
|
|
||||||
|
public @NonNull Builder setId(@NonNull Long setterArg) {
|
||||||
|
this.id = setterArg;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
private @Nullable String jid;
|
private @Nullable String jid;
|
||||||
|
|
||||||
public @NonNull Builder setJid(@NonNull String setterArg) {
|
public @NonNull Builder setJid(@NonNull String setterArg) {
|
||||||
@ -753,6 +768,7 @@ public class Api {
|
|||||||
|
|
||||||
public @NonNull NotificationEvent build() {
|
public @NonNull NotificationEvent build() {
|
||||||
NotificationEvent pigeonReturn = new NotificationEvent();
|
NotificationEvent pigeonReturn = new NotificationEvent();
|
||||||
|
pigeonReturn.setId(id);
|
||||||
pigeonReturn.setJid(jid);
|
pigeonReturn.setJid(jid);
|
||||||
pigeonReturn.setType(type);
|
pigeonReturn.setType(type);
|
||||||
pigeonReturn.setPayload(payload);
|
pigeonReturn.setPayload(payload);
|
||||||
@ -763,7 +779,8 @@ public class Api {
|
|||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
ArrayList<Object> toList() {
|
ArrayList<Object> toList() {
|
||||||
ArrayList<Object> toListResult = new ArrayList<Object>(4);
|
ArrayList<Object> toListResult = new ArrayList<Object>(5);
|
||||||
|
toListResult.add(id);
|
||||||
toListResult.add(jid);
|
toListResult.add(jid);
|
||||||
toListResult.add(type == null ? null : type.index);
|
toListResult.add(type == null ? null : type.index);
|
||||||
toListResult.add(payload);
|
toListResult.add(payload);
|
||||||
@ -773,13 +790,15 @@ public class Api {
|
|||||||
|
|
||||||
static @NonNull NotificationEvent fromList(@NonNull ArrayList<Object> list) {
|
static @NonNull NotificationEvent fromList(@NonNull ArrayList<Object> list) {
|
||||||
NotificationEvent pigeonResult = new NotificationEvent();
|
NotificationEvent pigeonResult = new NotificationEvent();
|
||||||
Object jid = list.get(0);
|
Object id = list.get(0);
|
||||||
|
pigeonResult.setId((id == null) ? null : ((id instanceof Integer) ? (Integer) id : (Long) id));
|
||||||
|
Object jid = list.get(1);
|
||||||
pigeonResult.setJid((String) jid);
|
pigeonResult.setJid((String) jid);
|
||||||
Object type = list.get(1);
|
Object type = list.get(2);
|
||||||
pigeonResult.setType(type == null ? null : NotificationEventType.values()[(int) type]);
|
pigeonResult.setType(type == null ? null : NotificationEventType.values()[(int) type]);
|
||||||
Object payload = list.get(2);
|
Object payload = list.get(3);
|
||||||
pigeonResult.setPayload((String) payload);
|
pigeonResult.setPayload((String) payload);
|
||||||
Object extra = list.get(3);
|
Object extra = list.get(4);
|
||||||
pigeonResult.setExtra((Map<String, String>) extra);
|
pigeonResult.setExtra((Map<String, String>) extra);
|
||||||
return pigeonResult;
|
return pigeonResult;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
private fun handleMarkAsRead(context: Context, intent: Intent) {
|
private fun handleMarkAsRead(context: Context, intent: Intent) {
|
||||||
MoxplatformAndroidPlugin.notificationSink?.success(
|
MoxplatformAndroidPlugin.notificationSink?.success(
|
||||||
NotificationEvent().apply {
|
NotificationEvent().apply {
|
||||||
|
id = intent.getLongExtra(NOTIFICATION_EXTRA_ID_KEY, -1)
|
||||||
jid = intent.getStringExtra(NOTIFICATION_EXTRA_JID_KEY)!!
|
jid = intent.getStringExtra(NOTIFICATION_EXTRA_JID_KEY)!!
|
||||||
type = Api.NotificationEventType.MARK_AS_READ
|
type = Api.NotificationEventType.MARK_AS_READ
|
||||||
payload = null
|
payload = null
|
||||||
@ -74,6 +75,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
val replyPayload = remoteInput.getCharSequence(REPLY_TEXT_KEY)
|
val replyPayload = remoteInput.getCharSequence(REPLY_TEXT_KEY)
|
||||||
MoxplatformAndroidPlugin.notificationSink?.success(
|
MoxplatformAndroidPlugin.notificationSink?.success(
|
||||||
NotificationEvent().apply {
|
NotificationEvent().apply {
|
||||||
|
id = intent.getLongExtra(NOTIFICATION_EXTRA_ID_KEY, -1)
|
||||||
jid = intent.getStringExtra(NOTIFICATION_EXTRA_JID_KEY)!!
|
jid = intent.getStringExtra(NOTIFICATION_EXTRA_JID_KEY)!!
|
||||||
type = Api.NotificationEventType.REPLY
|
type = Api.NotificationEventType.REPLY
|
||||||
payload = replyPayload.toString()
|
payload = replyPayload.toString()
|
||||||
@ -165,6 +167,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
private fun handleTap(context: Context, intent: Intent) {
|
private fun handleTap(context: Context, intent: Intent) {
|
||||||
MoxplatformAndroidPlugin.notificationSink?.success(
|
MoxplatformAndroidPlugin.notificationSink?.success(
|
||||||
NotificationEvent().apply {
|
NotificationEvent().apply {
|
||||||
|
id = intent.getLongExtra(NOTIFICATION_EXTRA_ID_KEY, -1)
|
||||||
jid = intent.getStringExtra(NOTIFICATION_EXTRA_JID_KEY)!!
|
jid = intent.getStringExtra(NOTIFICATION_EXTRA_JID_KEY)!!
|
||||||
type = Api.NotificationEventType.OPEN
|
type = Api.NotificationEventType.OPEN
|
||||||
payload = null
|
payload = null
|
||||||
|
@ -55,18 +55,18 @@ class NotificationMessageContent {
|
|||||||
|
|
||||||
class NotificationMessage {
|
class NotificationMessage {
|
||||||
NotificationMessage({
|
NotificationMessage({
|
||||||
required this.sender,
|
this.sender,
|
||||||
required this.jid,
|
this.jid,
|
||||||
required this.content,
|
required this.content,
|
||||||
required this.timestamp,
|
required this.timestamp,
|
||||||
this.avatarPath,
|
this.avatarPath,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The sender of the message.
|
/// The sender of the message.
|
||||||
String sender;
|
String? sender;
|
||||||
|
|
||||||
/// The jid of the sender.
|
/// The jid of the sender.
|
||||||
String jid;
|
String? jid;
|
||||||
|
|
||||||
/// The body of the message.
|
/// The body of the message.
|
||||||
NotificationMessageContent content;
|
NotificationMessageContent content;
|
||||||
@ -90,8 +90,8 @@ class NotificationMessage {
|
|||||||
static NotificationMessage decode(Object result) {
|
static NotificationMessage decode(Object result) {
|
||||||
result as List<Object?>;
|
result as List<Object?>;
|
||||||
return NotificationMessage(
|
return NotificationMessage(
|
||||||
sender: result[0]! as String,
|
sender: result[0] as String?,
|
||||||
jid: result[1]! as String,
|
jid: result[1] as String?,
|
||||||
content: NotificationMessageContent.decode(result[2]! as List<Object?>),
|
content: NotificationMessageContent.decode(result[2]! as List<Object?>),
|
||||||
timestamp: result[3]! as int,
|
timestamp: result[3]! as int,
|
||||||
avatarPath: result[4] as String?,
|
avatarPath: result[4] as String?,
|
||||||
@ -205,12 +205,16 @@ class RegularNotification {
|
|||||||
|
|
||||||
class NotificationEvent {
|
class NotificationEvent {
|
||||||
NotificationEvent({
|
NotificationEvent({
|
||||||
|
required this.id,
|
||||||
required this.jid,
|
required this.jid,
|
||||||
required this.type,
|
required this.type,
|
||||||
this.payload,
|
this.payload,
|
||||||
this.extra,
|
this.extra,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// The notification id.
|
||||||
|
int id;
|
||||||
|
|
||||||
/// The JID the notification was for.
|
/// The JID the notification was for.
|
||||||
String jid;
|
String jid;
|
||||||
|
|
||||||
@ -227,6 +231,7 @@ class NotificationEvent {
|
|||||||
|
|
||||||
Object encode() {
|
Object encode() {
|
||||||
return <Object?>[
|
return <Object?>[
|
||||||
|
id,
|
||||||
jid,
|
jid,
|
||||||
type.index,
|
type.index,
|
||||||
payload,
|
payload,
|
||||||
@ -237,10 +242,11 @@ class NotificationEvent {
|
|||||||
static NotificationEvent decode(Object result) {
|
static NotificationEvent decode(Object result) {
|
||||||
result as List<Object?>;
|
result as List<Object?>;
|
||||||
return NotificationEvent(
|
return NotificationEvent(
|
||||||
jid: result[0]! as String,
|
id: result[0]! as int,
|
||||||
type: NotificationEventType.values[result[1]! as int],
|
jid: result[1]! as String,
|
||||||
payload: result[2] as String?,
|
type: NotificationEventType.values[result[2]! as int],
|
||||||
extra: (result[3] as Map<Object?, Object?>?)?.cast<String?, String?>(),
|
payload: result[3] as String?,
|
||||||
|
extra: (result[4] as Map<Object?, Object?>?)?.cast<String?, String?>(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ class NotificationMessage {
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// The sender of the message.
|
/// The sender of the message.
|
||||||
final String sender;
|
final String? sender;
|
||||||
|
|
||||||
/// The jid of the sender.
|
/// The jid of the sender.
|
||||||
final String jid;
|
final String? jid;
|
||||||
|
|
||||||
/// The body of the message.
|
/// The body of the message.
|
||||||
final NotificationMessageContent content;
|
final NotificationMessageContent content;
|
||||||
@ -111,12 +111,16 @@ enum NotificationEventType {
|
|||||||
|
|
||||||
class NotificationEvent {
|
class NotificationEvent {
|
||||||
const NotificationEvent(
|
const NotificationEvent(
|
||||||
|
this.id,
|
||||||
this.jid,
|
this.jid,
|
||||||
this.type,
|
this.type,
|
||||||
this.payload,
|
this.payload,
|
||||||
this.extra,
|
this.extra,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// The notification id.
|
||||||
|
final int id;
|
||||||
|
|
||||||
/// The JID the notification was for.
|
/// The JID the notification was for.
|
||||||
final String jid;
|
final String jid;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user