Merge pull request #2468 from morgenroth/feature/Android-auto-support

Fix: Add messages to Notifications for Android Auto on Android M and older
This commit is contained in:
Daniel Gultsch 2017-04-29 21:47:21 +02:00 committed by GitHub
commit 7ba81177c6

View File

@ -20,6 +20,7 @@ import android.text.SpannableString;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.util.Pair;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
@ -433,8 +434,6 @@ public class NotificationService {
for (Message message : messages) { for (Message message : messages) {
String sender = message.getStatus() == Message.STATUS_RECEIVED ? UIHelper.getMessageDisplayName(message) : null; String sender = message.getStatus() == Message.STATUS_RECEIVED ? UIHelper.getMessageDisplayName(message) : null;
messagingStyle.addMessage(UIHelper.getMessagePreview(mXmppConnectionService,message).first, message.getTimeSent(), sender); messagingStyle.addMessage(UIHelper.getMessagePreview(mXmppConnectionService,message).first, message.getTimeSent(), sender);
uBuilder.addMessage(UIHelper.getMessagePreview(mXmppConnectionService,message).first);
uBuilder.setLatestTimestamp(message.getTimeSent());
} }
builder.setStyle(messagingStyle); builder.setStyle(messagingStyle);
} else { } else {
@ -462,6 +461,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) { private Message getImage(final Iterable<Message> messages) {