mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 03:16:51 +01:00
Merge branch 'notification-refactor' of https://github.com/Freeyourgadget/Gadgetbridge into notification-refactor
This commit is contained in:
commit
bdeb215fe0
@ -31,6 +31,7 @@ import android.content.pm.PackageManager;
|
||||
import android.media.MediaMetadata;
|
||||
import android.media.session.PlaybackState;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.os.PowerManager;
|
||||
import android.os.RemoteException;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
@ -260,11 +261,33 @@ public class NotificationListener extends NotificationListenerService {
|
||||
}
|
||||
|
||||
CharSequence contentCS = null;
|
||||
if (extras.containsKey(Notification.EXTRA_MESSAGES)) {
|
||||
Parcelable[] parcelables = extras.getParcelableArray(NotificationCompat.EXTRA_MESSAGES);
|
||||
String contentBuilder = "";
|
||||
CharSequence sender;
|
||||
CharSequence prevSender = "";
|
||||
CharSequence message;
|
||||
for (Parcelable p : parcelables) {
|
||||
if (!(p instanceof Bundle))
|
||||
continue;
|
||||
sender = ((Bundle) p).getCharSequence("sender");
|
||||
message = ((Bundle) p).getCharSequence("text");
|
||||
if (sender == null || message == null)
|
||||
continue;
|
||||
if (!sender.equals(prevSender) && !sender.equals(notificationSpec.title)) {
|
||||
contentBuilder += sender.toString() + ": ";
|
||||
prevSender = sender;
|
||||
}
|
||||
contentBuilder += message.toString() + "\n";
|
||||
}
|
||||
contentCS = contentBuilder;
|
||||
} else {
|
||||
if (preferBigText && extras.containsKey(Notification.EXTRA_BIG_TEXT)) {
|
||||
contentCS = extras.getCharSequence(NotificationCompat.EXTRA_BIG_TEXT);
|
||||
} else if (extras.containsKey(Notification.EXTRA_TEXT)) {
|
||||
contentCS = extras.getCharSequence(NotificationCompat.EXTRA_TEXT);
|
||||
}
|
||||
}
|
||||
if (contentCS != null) {
|
||||
notificationSpec.body = contentCS.toString();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user