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,
|
public static Notification createMessageNotification(Context context,
|
||||||
int msgCount, String msgSender, String msg, Bitmap contactIcon,
|
int msgCount, String msgSender, String msg, Bitmap contactIcon,
|
||||||
PendingIntent intent) {
|
PendingIntent intent) {
|
||||||
String title, summary;
|
String title;
|
||||||
if (msgCount == 1) {
|
if (msgCount == 1) {
|
||||||
title = "Unread message from %s".replace("%s", msgSender);
|
title = msgSender;
|
||||||
summary = "";
|
|
||||||
} else {
|
} else {
|
||||||
title = "%i unread messages"
|
title = "%i unread messages"
|
||||||
.replace("%i", String.valueOf(msgCount));
|
.replace("%i", String.valueOf(msgCount));
|
||||||
summary = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification notif = new Notification.BigPictureStyle(
|
Notification notif = new Notification.Builder(context)
|
||||||
new Notification.Builder(context)
|
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
.setContentText(msg)
|
.setContentText(msg)
|
||||||
.setSmallIcon(R.drawable.chat_icon_over)
|
.setSmallIcon(R.drawable.chat_icon_over)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
|
.setContentIntent(intent)
|
||||||
.setDefaults(
|
.setDefaults(
|
||||||
Notification.DEFAULT_LIGHTS
|
Notification.DEFAULT_LIGHTS
|
||||||
| Notification.DEFAULT_SOUND
|
| Notification.DEFAULT_SOUND
|
||||||
| Notification.DEFAULT_VIBRATE)
|
| Notification.DEFAULT_VIBRATE)
|
||||||
.setWhen(System.currentTimeMillis())
|
.setWhen(System.currentTimeMillis())
|
||||||
.setLargeIcon(contactIcon)).setSummaryText(summary)
|
.setLargeIcon(contactIcon)
|
||||||
.build();
|
.build();
|
||||||
notif.contentIntent = intent;
|
|
||||||
|
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
@ -68,13 +65,12 @@ public class ApiSixteenPlus {
|
||||||
String title, String msg, int iconID, Bitmap contactIcon,
|
String title, String msg, int iconID, Bitmap contactIcon,
|
||||||
String contactName, PendingIntent intent) {
|
String contactName, PendingIntent intent) {
|
||||||
|
|
||||||
Notification notif = new Notification.BigPictureStyle(
|
Notification notif = new Notification.Builder(context).setContentTitle(contactName)
|
||||||
new Notification.Builder(context).setContentTitle(contactName)
|
|
||||||
.setContentText(msg).setSmallIcon(iconID)
|
.setContentText(msg).setSmallIcon(iconID)
|
||||||
.setAutoCancel(false)
|
.setAutoCancel(false)
|
||||||
|
.setContentIntent(intent)
|
||||||
.setWhen(System.currentTimeMillis())
|
.setWhen(System.currentTimeMillis())
|
||||||
.setLargeIcon(contactIcon)).build();
|
.setLargeIcon(contactIcon).build();
|
||||||
notif.contentIntent = intent;
|
|
||||||
|
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue