1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-27 02:55:50 +01:00

Limit characters in heading and subheading to 32 (or else casio won't display the notification)

This commit is contained in:
foxstidious 2023-10-13 16:21:33 -04:00 committed by José Rebelo
parent 40af20a176
commit deeaf28de4

View File

@ -324,21 +324,32 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared
} }
} }
// Make sure title and sender are less than 32 characters
byte[] titleBytes = new byte[0]; byte[] titleBytes = new byte[0];
if(title != null) if(title != null) {
if (title.length() > 32) {
title = title.substring(0, 30) + "..";
}
titleBytes = title.getBytes(StandardCharsets.UTF_8); titleBytes = title.getBytes(StandardCharsets.UTF_8);
}
byte[] messageBytes = new byte[0]; byte[] messageBytes = new byte[0];
if(message != null) if(message != null) {
messageBytes = message.getBytes(StandardCharsets.UTF_8); messageBytes = message.getBytes(StandardCharsets.UTF_8);
}
byte[] senderBytes = new byte[0]; byte[] senderBytes = new byte[0];
if(sender != null) if(sender != null) {
if (sender.length() > 32) {
sender = sender.substring(0, 30) + "..";
}
senderBytes = sender.getBytes(StandardCharsets.UTF_8); senderBytes = sender.getBytes(StandardCharsets.UTF_8);
}
byte[] subtitleBytes = new byte[0]; byte[] subtitleBytes = new byte[0];
if (subtitle != null) if (subtitle != null) {
subtitleBytes = subtitle.getBytes(StandardCharsets.UTF_8); subtitleBytes = subtitle.getBytes(StandardCharsets.UTF_8);
}
byte[] arr = new byte[22]; byte[] arr = new byte[22];
arr[0] = (byte)(id & 0xff); arr[0] = (byte)(id & 0xff);