From 741fdbcbd2414a2b967d203153762da8a4d22ecc Mon Sep 17 00:00:00 2001 From: Yukai Li Date: Mon, 5 Oct 2020 05:34:45 -0600 Subject: [PATCH] Lefun: Tweak notifications for empty message handling --- .../requests/AbstractSendNotificationRequest.java | 2 +- .../lefun/requests/SendCallNotificationRequest.java | 4 ++-- .../lefun/requests/SendNotificationRequest.java | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/AbstractSendNotificationRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/AbstractSendNotificationRequest.java index acfb01935..d462674b7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/AbstractSendNotificationRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/AbstractSendNotificationRequest.java @@ -68,7 +68,7 @@ public abstract class AbstractSendNotificationRequest extends Request { int maxPayloadLength = NotificationCommand.MAX_PAYLOAD_LENGTH; if (reserveSpaceForExtended) maxPayloadLength -= 1; maxPayloadLength = Math.min(maxPayloadLength, buffer.limit() - buffer.position()); - if (maxPayloadLength == 0) break; + if (maxPayloadLength == 0 && i != 0) break; byte[] payload = new byte[maxPayloadLength]; buffer.get(payload); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/SendCallNotificationRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/SendCallNotificationRequest.java index bd572f62a..2b68ba517 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/SendCallNotificationRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/SendCallNotificationRequest.java @@ -41,11 +41,11 @@ public class SendCallNotificationRequest extends AbstractSendNotificationRequest @Override protected String getMessage() { String message = ""; - if (callNotification.number != null) { + if (callNotification.number != null &&!callNotification.number.isEmpty()) { message = callNotification.number; } - if (callNotification.name != null) { + if (callNotification.name != null && !callNotification.name.isEmpty()) { if (message.length() > 0) { message += " - "; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/SendNotificationRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/SendNotificationRequest.java index 98405d0bc..7f4262f9c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/SendNotificationRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/lefun/requests/SendNotificationRequest.java @@ -90,19 +90,19 @@ public class SendNotificationRequest extends AbstractSendNotificationRequest { // Based on nodomain.freeyourgadget.gadgetbridge.service.devices.id115.SendNotificationOperation String message = ""; - if (notification.phoneNumber != null) { + if (notification.phoneNumber != null && !notification.phoneNumber.isEmpty()) { message += notification.phoneNumber + ": "; } - if (notification.sender != null) { + if (notification.sender != null && !notification.sender.isEmpty()) { message += notification.sender + " - "; - } else if (notification.title != null) { + } else if (notification.title != null && !notification.title.isEmpty()) { message += notification.title + " - "; - } else if (notification.subject != null) { + } else if (notification.subject != null && !notification.sender.isEmpty()) { message += notification.subject + " - "; } - if (notification.body != null) { + if (notification.body != null && !notification.body.isEmpty()) { message += notification.body; }