Display contact name or username in call notification
This commit is contained in:
parent
6e207f19ac
commit
45bd91b7a6
3 changed files with 32 additions and 29 deletions
|
@ -239,7 +239,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
} catch (Exception e) {
|
||||
bm = BitmapFactory.decodeResource(getResources(), R.drawable.unknown_small);
|
||||
}
|
||||
mIncallNotif = Compatibility.createInCallNotification(getApplicationContext(), mNotificationTitle, getString(notificationTextId), inconId, bm, mNotifContentIntent);
|
||||
String name = address.getDisplayName() == null ? address.getUserName() : address.getDisplayName();
|
||||
mIncallNotif = Compatibility.createInCallNotification(getApplicationContext(), mNotificationTitle, getString(notificationTextId), inconId, bm, name, mNotifContentIntent);
|
||||
|
||||
notifyWrapper(INCALL_NOTIF_ID, mIncallNotif);
|
||||
}
|
||||
|
|
|
@ -11,47 +11,49 @@ import android.graphics.Bitmap;
|
|||
@TargetApi(16)
|
||||
public class ApiSixteenPlus {
|
||||
|
||||
public static Notification createMessageNotification(Context context, int msgCount, String msgSender, String msg, Bitmap contactIcon, PendingIntent intent) {
|
||||
public static Notification createMessageNotification(Context context,
|
||||
int msgCount, String msgSender, String msg, Bitmap contactIcon,
|
||||
PendingIntent intent) {
|
||||
String title, summary;
|
||||
if (msgCount == 1) {
|
||||
title = "Unread message from %s".replace("%s", msgSender);
|
||||
summary = "";
|
||||
} else {
|
||||
title = "%i unread messages".replace("%i", String.valueOf(msgCount));
|
||||
summary = "+" + (msgCount - 1) + " more";
|
||||
title = "%i unread messages"
|
||||
.replace("%i", String.valueOf(msgCount));
|
||||
summary = "";
|
||||
}
|
||||
|
||||
|
||||
Notification notif = new Notification.BigPictureStyle(
|
||||
new Notification.Builder(context)
|
||||
.setContentTitle(title)
|
||||
.setContentText(msg)
|
||||
.setSmallIcon(R.drawable.chat_icon_default)
|
||||
.setAutoCancel(true)
|
||||
.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setLargeIcon(contactIcon))
|
||||
.setSummaryText(summary)
|
||||
.build();
|
||||
new Notification.Builder(context)
|
||||
.setContentTitle(title)
|
||||
.setContentText(msg)
|
||||
.setSmallIcon(R.drawable.chat_icon_over)
|
||||
.setAutoCancel(true)
|
||||
.setDefaults(
|
||||
Notification.DEFAULT_LIGHTS
|
||||
| Notification.DEFAULT_SOUND
|
||||
| Notification.DEFAULT_VIBRATE)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setLargeIcon(contactIcon)).setSummaryText(summary)
|
||||
.build();
|
||||
notif.contentIntent = intent;
|
||||
|
||||
|
||||
return notif;
|
||||
}
|
||||
|
||||
public static Notification createInCallNotification(Context context,
|
||||
String title, String msg, int iconID, Bitmap contactIcon,
|
||||
PendingIntent intent) {
|
||||
|
||||
String contactName, PendingIntent intent) {
|
||||
|
||||
Notification notif = new Notification.BigPictureStyle(
|
||||
new Notification.Builder(context)
|
||||
.setContentTitle(title)
|
||||
.setContentText(msg)
|
||||
.setSmallIcon(iconID)
|
||||
.setAutoCancel(false)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setLargeIcon(contactIcon))
|
||||
.build();
|
||||
new Notification.Builder(context).setContentTitle(contactName)
|
||||
.setContentText(msg).setSmallIcon(iconID)
|
||||
.setAutoCancel(false)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setLargeIcon(contactIcon)).build();
|
||||
notif.contentIntent = intent;
|
||||
|
||||
|
||||
return notif;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,11 +152,11 @@ public class Compatibility {
|
|||
return notif;
|
||||
}
|
||||
|
||||
public static Notification createInCallNotification(Context context, String title, String msg, int iconID, Bitmap contactIcon, PendingIntent intent) {
|
||||
public static Notification createInCallNotification(Context context, String title, String msg, int iconID, Bitmap contactIcon, String contactName, PendingIntent intent) {
|
||||
Notification notif = null;
|
||||
|
||||
if (Version.sdkAboveOrEqual(16)) {
|
||||
notif = ApiSixteenPlus.createInCallNotification(context, title, msg, iconID, contactIcon, intent);
|
||||
notif = ApiSixteenPlus.createInCallNotification(context, title, msg, iconID, contactIcon, contactName, intent);
|
||||
} else {
|
||||
notif = new Notification();
|
||||
notif.iconLevel = 0;
|
||||
|
|
Loading…
Reference in a new issue