Missed call: make some changes on notification

This commit is contained in:
ganfra 2021-07-20 09:40:09 +02:00
parent f7e2e741c0
commit c59967fb6c
3 changed files with 11 additions and 12 deletions

View File

@ -200,6 +200,10 @@ class CallService : VectorService() {
return
}
knownCalls.remove(terminatedCall)
if (knownCalls.isEmpty()) {
mediaSession?.isActive = false
myStopSelf()
}
val wasOngoing = ongoingCallIds.remove(callId)
if (wasOngoing || isRejected) {
val notification = notificationUtils.buildCallEndedNotification()
@ -207,15 +211,10 @@ class CallService : VectorService() {
} else {
val notification = notificationUtils.buildCallMissedNotification(
roomId = terminatedCall.nativeRoomId,
caller = terminatedCall.matrixItem?.getBestName() ?: terminatedCall.opponentUserId
title = terminatedCall.matrixItem?.getBestName() ?: terminatedCall.opponentUserId
)
notificationManager.cancel(callId.hashCode())
notificationManager.notify(MISSED_CALL_TAG, callId.hashCode(), notification)
}
if (knownCalls.isEmpty()) {
mediaSession?.isActive = false
myStopSelf()
notificationManager.notify(MISSED_CALL_TAG, terminatedCall.nativeRoomId.hashCode(), notification)
}
}

View File

@ -462,10 +462,10 @@ class NotificationUtils @Inject constructor(private val context: Context,
/**
* Build notification for the CallService, when a call is missed
*/
fun buildCallMissedNotification(roomId: String, caller: String): Notification {
val builder = NotificationCompat.Builder(context, SILENT_NOTIFICATION_CHANNEL_ID)
.setContentTitle(caller)
.setContentText(stringProvider.getString(R.string.call_missed, caller))
fun buildCallMissedNotification(roomId: String, title: String): Notification {
val builder = NotificationCompat.Builder(context, NOISY_NOTIFICATION_CHANNEL_ID)
.setContentTitle(title)
.setContentText(stringProvider.getString(R.string.call_missed))
.setSmallIcon(R.drawable.ic_material_call_end_grey)
.setAutoCancel(true)
.setCategory(NotificationCompat.CATEGORY_CALL)

View File

@ -727,7 +727,7 @@
<string name="call_connected">Call connected</string>
<string name="call_connecting">Call connecting…</string>
<string name="call_ended">Call ended</string>
<string name="call_missed">You missed a call from %s</string>
<string name="call_missed">Missed call</string>
<string name="call_ring">Calling…</string>
<string name="incoming_call">Incoming Call</string>
<string name="incoming_video_call">Incoming Video Call</string>