diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/NotificationService.java | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index e042d76db..c38c35600 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -5,6 +5,7 @@ import android.app.PendingIntent; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; +import android.graphics.Typeface; import android.net.Uri; import android.os.Build; import android.os.SystemClock; @@ -13,7 +14,8 @@ import android.support.v4.app.NotificationCompat.BigPictureStyle; import android.support.v4.app.NotificationCompat.Builder; import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.RemoteInput; -import android.text.Html; +import android.text.SpannableString; +import android.text.style.StyleSpan; import android.util.DisplayMetrics; import android.util.Log; @@ -280,12 +282,16 @@ public class NotificationService { if (messages.size() > 0) { conversation = messages.get(0).getConversation(); final String name = conversation.getName(); + SpannableString styledString; if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) { int count = messages.size(); - style.addLine(Html.fromHtml("<b>" + name + "</b>: " + mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count))); + styledString = new SpannableString(name + ": " + mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count)); + styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0); + style.addLine(styledString); } else { - style.addLine(Html.fromHtml("<b>" + name + "</b>: " - + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first)); + styledString = new SpannableString(name + ": " + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first); + styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0); + style.addLine(styledString); } names.append(name); names.append(", "); @@ -406,8 +412,28 @@ public class NotificationService { } builder.setStyle(messagingStyle); } else { - builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages))); - builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get((messages.size() - 1))).first); + if (messages.get(0).getConversation().getMode() == Conversation.MODE_SINGLE) { + builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages))); + builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get((messages.size() - 1))).first); + } else { + final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); + SpannableString styledString; + for (Message message : messages) { + final String name = UIHelper.getMessageDisplayName(message); + styledString = new SpannableString(name + ": " + message.getBody()); + styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0); + style.addLine(styledString); + } + builder.setStyle(style); + if (messages.size() == 1) { + final String name = UIHelper.getMessageDisplayName(messages.get(0)); + styledString = new SpannableString(name + ": " + messages.get(0).getBody()); + styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0); + builder.setContentText(styledString); + } else { + builder.setContentText(messages.size() + " " + mXmppConnectionService.getString(R.string.unread_conversations)); + } + } } } |