Improved chat message & incall notification for Android >= 16
This commit is contained in:
parent
924597d0f4
commit
f562397686
1 changed files with 8 additions and 12 deletions
|
@ -36,30 +36,27 @@ public class ApiSixteenPlus {
|
|||
public static Notification createMessageNotification(Context context,
|
||||
int msgCount, String msgSender, String msg, Bitmap contactIcon,
|
||||
PendingIntent intent) {
|
||||
String title, summary;
|
||||
String title;
|
||||
if (msgCount == 1) {
|
||||
title = "Unread message from %s".replace("%s", msgSender);
|
||||
summary = "";
|
||||
title = msgSender;
|
||||
} else {
|
||||
title = "%i unread messages"
|
||||
.replace("%i", String.valueOf(msgCount));
|
||||
summary = "";
|
||||
}
|
||||
|
||||
Notification notif = new Notification.BigPictureStyle(
|
||||
new Notification.Builder(context)
|
||||
Notification notif = new Notification.Builder(context)
|
||||
.setContentTitle(title)
|
||||
.setContentText(msg)
|
||||
.setSmallIcon(R.drawable.chat_icon_over)
|
||||
.setAutoCancel(true)
|
||||
.setContentIntent(intent)
|
||||
.setDefaults(
|
||||
Notification.DEFAULT_LIGHTS
|
||||
| Notification.DEFAULT_SOUND
|
||||
| Notification.DEFAULT_VIBRATE)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setLargeIcon(contactIcon)).setSummaryText(summary)
|
||||
.setLargeIcon(contactIcon)
|
||||
.build();
|
||||
notif.contentIntent = intent;
|
||||
|
||||
return notif;
|
||||
}
|
||||
|
@ -68,13 +65,12 @@ public class ApiSixteenPlus {
|
|||
String title, String msg, int iconID, Bitmap contactIcon,
|
||||
String contactName, PendingIntent intent) {
|
||||
|
||||
Notification notif = new Notification.BigPictureStyle(
|
||||
new Notification.Builder(context).setContentTitle(contactName)
|
||||
Notification notif = new Notification.Builder(context).setContentTitle(contactName)
|
||||
.setContentText(msg).setSmallIcon(iconID)
|
||||
.setAutoCancel(false)
|
||||
.setContentIntent(intent)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setLargeIcon(contactIcon)).build();
|
||||
notif.contentIntent = intent;
|
||||
.setLargeIcon(contactIcon).build();
|
||||
|
||||
return notif;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue