Moyoung: Improve notifications

This commit is contained in:
Arjan Schrijver 2024-08-30 21:47:51 +02:00
parent b3f8490995
commit bff6fcca56

View File

@ -513,16 +513,21 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
@Override @Override
public void onNotification(NotificationSpec notificationSpec) { public void onNotification(NotificationSpec notificationSpec) {
String sender = StringUtils.getFirstOf(notificationSpec.sender, StringUtils.getFirstOf(notificationSpec.sourceName, notificationSpec.sourceAppId)); final String senderOrTitle = StringUtils.getFirstOf(notificationSpec.sender, notificationSpec.title);
if (sender.isEmpty())
sender = "(unknown)";
String text = NotificationUtils.getPreferredTextFor(notificationSpec, 0, 75, getContext()); String message = StringUtils.truncate(senderOrTitle, 32) + ":";
if (text.isEmpty()) if (notificationSpec.subject != null) {
text = StringUtils.getFirstOf(StringUtils.getFirstOf(notificationSpec.title, notificationSpec.subject), notificationSpec.body); message += StringUtils.truncate(notificationSpec.subject, 128) + "\n\n";
}
if (notificationSpec.body != null) {
message += StringUtils.truncate(notificationSpec.body, 512);
}
if (notificationSpec.body == null && notificationSpec.subject == null) {
message += " ";
}
// The notification is split at first : into sender and text // The notification is split at first : into sender and text
sendNotification(MoyoungConstants.notificationType(notificationSpec.type), sender + ":" + text); sendNotification(MoyoungConstants.notificationType(notificationSpec.type), message);
} }
@Override @Override