diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-05-09 20:34:04 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-05-09 20:34:04 +0200 |
commit | 1eec39c87c1f0cb5d092793ba104ffaff2bbf1e2 (patch) | |
tree | e9c80a861ddcab2d090aa959b77b7073e471e125 /src/main/java/de/pixart/messenger | |
parent | ce86dfb58f8db458e474d1b06825d8df53cf60e7 (diff) |
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.
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/NotificationService.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index ce9a9e528..e6c3fb052 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/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; @@ -443,8 +444,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 { @@ -472,6 +471,15 @@ public class NotificationService { } } } + /** message preview for Android Auto **/ + for (Message message : messages) { + Pair<String, Boolean> 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<Message> messages) { |