Show diverter (if exists) also in incoming call notification

This commit is contained in:
Juha Heinanen
2026-05-03 16:52:50 +03:00
parent 8e5e1254e4
commit d431206786
3 changed files with 16 additions and 7 deletions

View File

@ -1806,7 +1806,6 @@ class BaresipService: Service() {
val nb = NotificationCompat.Builder(this, channelId)
val caller = Utils.friendlyUri(this, peerUri, ua.account)
val callerContact = Contact.findContact(peerUri)
val personBuilder = Person.Builder().setName(caller)
val contactColor = callerContact?.color() ?: "#B0B0B0"
val initial = if (caller.isNotEmpty()) caller.take(1) else "?"
val textAvatarBitmap = Utils.createTextAvatar(initial, contactColor)
@ -1815,8 +1814,9 @@ class BaresipService: Service() {
if (callerContact is Contact.BaresipContact) {
if (callerContact.avatarImage != null)
icon = IconCompat.createWithBitmap(callerContact.avatarImage!!.toCircle())
} else if (callerContact is Contact.AndroidContact) {
if (callerContact.thumbnailUri != null) {
}
else if (callerContact is Contact.AndroidContact)
if (callerContact.thumbnailUri != null)
try {
val source = ImageDecoder.createSource(contentResolver, callerContact.thumbnailUri!!)
val bitmap = ImageDecoder.decodeBitmap(source) { decoder, _, _ ->
@ -1826,21 +1826,28 @@ class BaresipService: Service() {
} catch (e: Exception) {
Log.e(TAG, "Failed to load Android contact avatar: $e")
}
}
}
val person = personBuilder.setIcon(icon).build()
val person = Person.Builder().setName(caller).setIcon(icon).build()
val diverterUri = call.diverterUri()
val contentText = if (diverterUri != "")
"${getString(R.string.is_calling)} " +
"(${getString(R.string.diverted_by)} " +
"${Utils.friendlyUri(this, diverterUri, ua.account)})"
else
getString(R.string.is_calling)
nb.setSmallIcon(R.drawable.ic_notification_call)
.setColor(ContextCompat.getColor(this, R.color.colorPrimary))
.setContentIntent(pi)
.setCategory(Notification.CATEGORY_CALL)
.setAutoCancel(false)
.setOngoing(true)
.setContentText(getString(R.string.is_calling))
.setContentText(contentText)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(NotificationCompat.PRIORITY_MAX)
.addPerson(person)
nb.setFullScreenIntent(pi, true)

View File

@ -519,6 +519,7 @@
<string name="outgoing_call_to_dots">Puhelu ulos …</string>
<string name="incoming_call_from_dots">Puhelu sisään …</string>
<string name="diverted_by_dots">Siirtäjä …</string>
<string name="diverted_by">siirtäjä</string>
<string name="no_telephony_provider">Tilille \'%1$s\' ei ole konfiguroitu puhelinpalvelun
tarjoajaa</string>
<string name="video_call">Videopuhelu</string>

View File

@ -503,6 +503,7 @@
<string name="outgoing_call_to_dots">Call to …</string>
<string name="incoming_call_from_dots">Call from …</string>
<string name="diverted_by_dots">Diverted by …</string>
<string name="diverted_by">diverted by</string>
<string name="no_telephony_provider">Account \'%1$s\' has no Telephony Provider</string>
<string name="video_call">Video call</string>
<string name="video_request">Video Request</string>