mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-02-05 05:24:12 +01:00
Moyoung: Improve notifications
This commit is contained in:
parent
b3f8490995
commit
bff6fcca56
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user