From e3464f58fa467b00a9a2e4a57e3989b644e84686 Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 22 Jul 2021 15:39:13 +0200 Subject: [PATCH] Call notif: make end call notif better --- .../java/im/vector/app/core/services/CallService.kt | 10 ++++------ .../app/features/notifications/NotificationUtils.kt | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/services/CallService.kt b/vector/src/main/java/im/vector/app/core/services/CallService.kt index 916dc66718..d8cf8cf6b8 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallService.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallService.kt @@ -210,13 +210,11 @@ class CallService : VectorService() { myStopSelf() } val wasConnected = connectedCallIds.remove(callId) + val notification = notificationUtils.buildCallEndedNotification(terminatedCall.isVideoCall) + notificationManager.notify(callId.hashCode(), notification) if (!wasConnected && !terminatedCall.isOutgoing && !rejected && endCallReason != EndCallReason.ANSWERED_ELSEWHERE) { - val notification = notificationUtils.buildCallMissedNotification(terminatedCall) - notificationManager.cancel(callId.hashCode()) - notificationManager.notify(MISSED_CALL_TAG, terminatedCall.nativeRoomId.hashCode(), notification) - } else { - val notification = notificationUtils.buildCallEndedNotification(terminatedCall.isVideoCall) - notificationManager.notify(callId.hashCode(), notification) + val missedCallNotification = notificationUtils.buildCallMissedNotification(terminatedCall) + notificationManager.notify(MISSED_CALL_TAG, terminatedCall.nativeRoomId.hashCode(), missedCallNotification) } } diff --git a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt index 24a64f3cdb..cf13150e59 100755 --- a/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/app/features/notifications/NotificationUtils.kt @@ -468,7 +468,8 @@ class NotificationUtils @Inject constructor(private val context: Context, setSmallIcon(R.drawable.ic_call_answer) } } - .setTimeoutAfter(2000) + // This is a trick to make the previous notification with same id disappear as cancel notification is not working with Foreground Service. + .setTimeoutAfter(1) .setColor(ThemeUtils.getColor(context, android.R.attr.colorPrimary)) .setCategory(NotificationCompat.CATEGORY_CALL) .build()