From adff2baa4a1583243c529eef09d54ca07af7a720 Mon Sep 17 00:00:00 2001 From: Johannes Morgenroth Date: Sat, 29 Apr 2017 19:25:57 +0200 Subject: [PATCH] Add messages to Notification for Android Auto on Android M and older In the previous implementation for Android Auto, messages are only added on Android N and above. In order to support older Android versions, the messages need to be added always. --- .../conversations/services/NotificationService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index ee0d23e63..c7d80b549 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -20,6 +20,7 @@ import android.text.SpannableString; import android.text.style.StyleSpan; import android.util.DisplayMetrics; import android.util.Log; +import android.util.Pair; import java.io.FileNotFoundException; import java.util.ArrayList; @@ -433,8 +434,6 @@ public class NotificationService { for (Message message : messages) { String sender = message.getStatus() == Message.STATUS_RECEIVED ? UIHelper.getMessageDisplayName(message) : null; messagingStyle.addMessage(UIHelper.getMessagePreview(mXmppConnectionService,message).first, message.getTimeSent(), sender); - uBuilder.addMessage(UIHelper.getMessagePreview(mXmppConnectionService,message).first); - uBuilder.setLatestTimestamp(message.getTimeSent()); } builder.setStyle(messagingStyle); } else { @@ -462,6 +461,15 @@ public class NotificationService { } } } + /** message preview for Android Auto **/ + for (Message message : messages) { + Pair preview = UIHelper.getMessagePreview(mXmppConnectionService, message); + // only show user written text + if (preview.second == false) { + uBuilder.addMessage(preview.first); + uBuilder.setLatestTimestamp(message.getTimeSent()); + } + } } private Message getImage(final Iterable messages) {