Fixed wrong missed call number on app badge

This commit is contained in:
Sylvain Berfini 2019-11-04 16:26:06 +01:00
parent 0c75dbd9dd
commit 372e408fbb
5 changed files with 14 additions and 8 deletions

View file

@ -437,7 +437,8 @@ public class CallActivity extends LinphoneGenericActivity
Call call = mCore.getCurrentCall(); Call call = mCore.getCurrentCall();
boolean videoEnabled = boolean videoEnabled =
LinphonePreferences.instance().isVideoEnabled() LinphonePreferences.instance().isVideoEnabled()
&& call != null && call.getCurrentParams().videoEnabled(); && call != null
&& call.getCurrentParams().videoEnabled();
if (videoEnabled) { if (videoEnabled) {
mAudioManager = LinphoneManager.getAudioManager(); mAudioManager = LinphoneManager.getAudioManager();
@ -825,7 +826,8 @@ public class CallActivity extends LinphoneGenericActivity
boolean videoEnabled = boolean videoEnabled =
LinphonePreferences.instance().isVideoEnabled() LinphonePreferences.instance().isVideoEnabled()
&& call != null && call.getCurrentParams().videoEnabled(); && call != null
&& call.getCurrentParams().videoEnabled();
showVideoControls(videoEnabled); showVideoControls(videoEnabled);
} }

View file

@ -183,7 +183,7 @@ class ApiTwentyOnePlus {
} }
public static Notification createMissedCallNotification( public static Notification createMissedCallNotification(
Context context, String title, String text, PendingIntent intent) { Context context, String title, String text, PendingIntent intent, int count) {
return new Notification.Builder(context) return new Notification.Builder(context)
.setContentTitle(title) .setContentTitle(title)
@ -201,6 +201,7 @@ class ApiTwentyOnePlus {
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis()) .setWhen(System.currentTimeMillis())
.setShowWhen(true) .setShowWhen(true)
.setNumber(count)
.build(); .build();
} }

View file

@ -255,7 +255,7 @@ class ApiTwentySixPlus {
} }
public static Notification createMissedCallNotification( public static Notification createMissedCallNotification(
Context context, String title, String text, PendingIntent intent) { Context context, String title, String text, PendingIntent intent, int count) {
return new Notification.Builder( return new Notification.Builder(
context, context.getString(R.string.notification_channel_id)) context, context.getString(R.string.notification_channel_id))
.setContentTitle(title) .setContentTitle(title)
@ -269,6 +269,7 @@ class ApiTwentySixPlus {
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis()) .setWhen(System.currentTimeMillis())
.setShowWhen(true) .setShowWhen(true)
.setNumber(count)
.setColor(context.getColor(R.color.notification_led_color)) .setColor(context.getColor(R.color.notification_led_color))
.build(); .build();
} }

View file

@ -103,11 +103,12 @@ public class Compatibility {
} }
public static Notification createMissedCallNotification( public static Notification createMissedCallNotification(
Context context, String title, String text, PendingIntent intent) { Context context, String title, String text, PendingIntent intent, int count) {
if (Version.sdkAboveOrEqual(Version.API26_O_80)) { if (Version.sdkAboveOrEqual(Version.API26_O_80)) {
return ApiTwentySixPlus.createMissedCallNotification(context, title, text, intent); return ApiTwentySixPlus.createMissedCallNotification(
context, title, text, intent, count);
} }
return ApiTwentyOnePlus.createMissedCallNotification(context, title, text, intent); return ApiTwentyOnePlus.createMissedCallNotification(context, title, text, intent, count);
} }
public static Notification createInCallNotification( public static Notification createInCallNotification(

View file

@ -521,7 +521,8 @@ public class NotificationsManager {
mContext, mContext,
mContext.getString(R.string.missed_calls_notif_title), mContext.getString(R.string.missed_calls_notif_title),
body, body,
pendingIntent); pendingIntent,
missedCallCount);
sendNotification(MISSED_CALLS_NOTIF_ID, notif); sendNotification(MISSED_CALLS_NOTIF_ID, notif);
} }