Skip to content
Snippets Groups Projects
Commit 2dec5414 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

notifications: fix crash

Change-Id: I8e51e2ca92cdd79c7be314af72cbe137f054d015
parent ed9feeb4
No related branches found
No related tags found
No related merge requests found
...@@ -8,8 +8,8 @@ android { ...@@ -8,8 +8,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 173 versionCode 174
versionName "20190704-01" versionName "20190706-01"
} }
sourceSets { sourceSets {
......
...@@ -207,7 +207,6 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -207,7 +207,6 @@ public class NotificationServiceImpl implements NotificationService {
} }
SipCall call = conference.getParticipants().get(0); SipCall call = conference.getParticipants().get(0);
CallContact contact = call.getContact();
final int notificationId = call.getCallId().hashCode(); final int notificationId = call.getCallId().hashCode();
notificationManager.cancel(notificationId); notificationManager.cancel(notificationId);
...@@ -227,8 +226,8 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -227,8 +226,8 @@ public class NotificationServiceImpl implements NotificationService {
return; return;
} }
NotificationCompat.Builder messageNotificationBuilder = null; CallContact contact = call.getContact();
NotificationCompat.Builder messageNotificationBuilder;
if (conference.isOnGoing()) { if (conference.isOnGoing()) {
messageNotificationBuilder = new NotificationCompat.Builder(mContext, NOTIF_CHANNEL_CALL_IN_PROGRESS); messageNotificationBuilder = new NotificationCompat.Builder(mContext, NOTIF_CHANNEL_CALL_IN_PROGRESS);
messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_current_call_title, contact.getDisplayName())) messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_current_call_title, contact.getDisplayName()))
...@@ -247,7 +246,6 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -247,7 +246,6 @@ public class NotificationServiceImpl implements NotificationService {
} else if (conference.isRinging()) { } else if (conference.isRinging()) {
if (conference.isIncoming()) { if (conference.isIncoming()) {
messageNotificationBuilder = new NotificationCompat.Builder(mContext, NOTIF_CHANNEL_INCOMING_CALL); messageNotificationBuilder = new NotificationCompat.Builder(mContext, NOTIF_CHANNEL_INCOMING_CALL);
Bundle extras = new Bundle();
messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_incoming_call_title, contact.getDisplayName())) messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_incoming_call_title, contact.getDisplayName()))
.setPriority(NotificationCompat.PRIORITY_MAX) .setPriority(NotificationCompat.PRIORITY_MAX)
.setContentText(mContext.getText(R.string.notif_incoming_call)) .setContentText(mContext.getText(R.string.notif_incoming_call))
...@@ -264,8 +262,7 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -264,8 +262,7 @@ public class NotificationServiceImpl implements NotificationService {
new Intent(DRingService.ACTION_CALL_ACCEPT) new Intent(DRingService.ACTION_CALL_ACCEPT)
.setClass(mContext, DRingService.class) .setClass(mContext, DRingService.class)
.putExtra(KEY_CALL_ID, call.getCallId()), .putExtra(KEY_CALL_ID, call.getCallId()),
PendingIntent.FLAG_ONE_SHOT)) PendingIntent.FLAG_ONE_SHOT));
.addExtras(extras);
} else { } else {
messageNotificationBuilder = new NotificationCompat.Builder(mContext, NOTIF_CHANNEL_CALL_IN_PROGRESS); messageNotificationBuilder = new NotificationCompat.Builder(mContext, NOTIF_CHANNEL_CALL_IN_PROGRESS);
messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_outgoing_call_title, contact.getDisplayName())) messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_outgoing_call_title, contact.getDisplayName()))
...@@ -273,6 +270,8 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -273,6 +270,8 @@ public class NotificationServiceImpl implements NotificationService {
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(gotoIntent) .setContentIntent(gotoIntent)
.setSound(null) .setSound(null)
.setColorized(true)
.setColor(mContext.getResources().getColor(R.color.color_primary_light))
.addAction(R.drawable.baseline_call_end_24, mContext.getText(R.string.action_call_hangup), .addAction(R.drawable.baseline_call_end_24, mContext.getText(R.string.action_call_hangup),
PendingIntent.getService(mContext, random.nextInt(), PendingIntent.getService(mContext, random.nextInt(),
new Intent(DRingService.ACTION_CALL_END) new Intent(DRingService.ACTION_CALL_END)
...@@ -280,6 +279,8 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -280,6 +279,8 @@ public class NotificationServiceImpl implements NotificationService {
.putExtra(KEY_CALL_ID, call.getCallId()), .putExtra(KEY_CALL_ID, call.getCallId()),
PendingIntent.FLAG_ONE_SHOT)); PendingIntent.FLAG_ONE_SHOT));
} }
} else {
return;
} }
messageNotificationBuilder.setOngoing(true) messageNotificationBuilder.setOngoing(true)
...@@ -287,12 +288,7 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -287,12 +288,7 @@ public class NotificationServiceImpl implements NotificationService {
.setSmallIcon(R.drawable.ic_ring_logo_white); .setSmallIcon(R.drawable.ic_ring_logo_white);
setContactPicture(contact, messageNotificationBuilder); setContactPicture(contact, messageNotificationBuilder);
messageNotificationBuilder.setColor(ResourcesCompat.getColor(mContext.getResources(),
R.color.color_primary_dark, null));
notificationManager.notify(notificationId, messageNotificationBuilder.build()); notificationManager.notify(notificationId, messageNotificationBuilder.build());
mNotificationBuilders.put(notificationId, messageNotificationBuilder);
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment