mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-27 19:22:15 -05:00
Merge branch 'dev' of https://github.com/badarsh2/Conversations into badarsh2-dev
This commit is contained in:
commit
5b17734287
@ -5,6 +5,7 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.SystemClock;
|
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.NotificationManagerCompat;
|
||||||
import android.support.v4.app.RemoteInput;
|
import android.support.v4.app.RemoteInput;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.style.StyleSpan;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@ -268,12 +271,16 @@ public class NotificationService {
|
|||||||
if (messages.size() > 0) {
|
if (messages.size() > 0) {
|
||||||
conversation = messages.get(0).getConversation();
|
conversation = messages.get(0).getConversation();
|
||||||
final String name = conversation.getName();
|
final String name = conversation.getName();
|
||||||
|
SpannableString styledString;
|
||||||
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
|
||||||
int count = messages.size();
|
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 {
|
} else {
|
||||||
style.addLine(Html.fromHtml("<b>" + name + "</b>: "
|
styledString = new SpannableString(name + ": " + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
|
||||||
+ 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(name);
|
||||||
names.append(", ");
|
names.append(", ");
|
||||||
@ -394,8 +401,30 @@ public class NotificationService {
|
|||||||
}
|
}
|
||||||
builder.setStyle(messagingStyle);
|
builder.setStyle(messagingStyle);
|
||||||
} else {
|
} else {
|
||||||
|
if(messages.get(0).getConversation().getMode() == Conversation.MODE_SINGLE) {
|
||||||
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages)));
|
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages)));
|
||||||
builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get((messages.size()-1))).first);
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user