diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index c83136d3..497d7642 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/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; @@ -14,6 +15,8 @@ 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; @@ -268,12 +271,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(""+name+": "+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("" + name + ": " - + 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(", "); @@ -394,8 +401,30 @@ 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)); + } + } } }