Lefun: Tweak notifications for empty message handling

This commit is contained in:
Yukai Li
2020-10-05 05:34:45 -06:00
committed by Gitea
parent c2375f95f4
commit 741fdbcbd2
3 changed files with 8 additions and 8 deletions

View File

@@ -68,7 +68,7 @@ public abstract class AbstractSendNotificationRequest extends Request {
int maxPayloadLength = NotificationCommand.MAX_PAYLOAD_LENGTH; int maxPayloadLength = NotificationCommand.MAX_PAYLOAD_LENGTH;
if (reserveSpaceForExtended) maxPayloadLength -= 1; if (reserveSpaceForExtended) maxPayloadLength -= 1;
maxPayloadLength = Math.min(maxPayloadLength, buffer.limit() - buffer.position()); maxPayloadLength = Math.min(maxPayloadLength, buffer.limit() - buffer.position());
if (maxPayloadLength == 0) break; if (maxPayloadLength == 0 && i != 0) break;
byte[] payload = new byte[maxPayloadLength]; byte[] payload = new byte[maxPayloadLength];
buffer.get(payload); buffer.get(payload);

View File

@@ -41,11 +41,11 @@ public class SendCallNotificationRequest extends AbstractSendNotificationRequest
@Override @Override
protected String getMessage() { protected String getMessage() {
String message = ""; String message = "";
if (callNotification.number != null) { if (callNotification.number != null &&!callNotification.number.isEmpty()) {
message = callNotification.number; message = callNotification.number;
} }
if (callNotification.name != null) { if (callNotification.name != null && !callNotification.name.isEmpty()) {
if (message.length() > 0) { if (message.length() > 0) {
message += " - "; message += " - ";
} }

View File

@@ -90,19 +90,19 @@ public class SendNotificationRequest extends AbstractSendNotificationRequest {
// Based on nodomain.freeyourgadget.gadgetbridge.service.devices.id115.SendNotificationOperation // Based on nodomain.freeyourgadget.gadgetbridge.service.devices.id115.SendNotificationOperation
String message = ""; String message = "";
if (notification.phoneNumber != null) { if (notification.phoneNumber != null && !notification.phoneNumber.isEmpty()) {
message += notification.phoneNumber + ": "; message += notification.phoneNumber + ": ";
} }
if (notification.sender != null) { if (notification.sender != null && !notification.sender.isEmpty()) {
message += notification.sender + " - "; message += notification.sender + " - ";
} else if (notification.title != null) { } else if (notification.title != null && !notification.title.isEmpty()) {
message += notification.title + " - "; message += notification.title + " - ";
} else if (notification.subject != null) { } else if (notification.subject != null && !notification.sender.isEmpty()) {
message += notification.subject + " - "; message += notification.subject + " - ";
} }
if (notification.body != null) { if (notification.body != null && !notification.body.isEmpty()) {
message += notification.body; message += notification.body;
} }