1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-12 02:45:49 +01:00

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;
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);

View File

@ -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 += " - ";
}

View File

@ -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;
}