mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-01 12:05:37 +02:00
Moyoung: Improve notifications
This commit is contained in:
parent
cf1733ff65
commit
d2b93a9912
@ -513,16 +513,21 @@ public class MoyoungDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
@Override
|
||||
public void onNotification(NotificationSpec notificationSpec) {
|
||||
String sender = StringUtils.getFirstOf(notificationSpec.sender, StringUtils.getFirstOf(notificationSpec.sourceName, notificationSpec.sourceAppId));
|
||||
if (sender.isEmpty())
|
||||
sender = "(unknown)";
|
||||
final String senderOrTitle = StringUtils.getFirstOf(notificationSpec.sender, notificationSpec.title);
|
||||
|
||||
String text = NotificationUtils.getPreferredTextFor(notificationSpec, 0, 75, getContext());
|
||||
if (text.isEmpty())
|
||||
text = StringUtils.getFirstOf(StringUtils.getFirstOf(notificationSpec.title, notificationSpec.subject), notificationSpec.body);
|
||||
String message = StringUtils.truncate(senderOrTitle, 32) + ":";
|
||||
if (notificationSpec.subject != null) {
|
||||
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
|
||||
sendNotification(MoyoungConstants.notificationType(notificationSpec.type), sender + ":" + text);
|
||||
sendNotification(MoyoungConstants.notificationType(notificationSpec.type), message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user