From ea7b443bb407bc0b2bf1636daf0fd0db3a0a6e50 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sat, 4 Mar 2023 03:37:00 +0200 Subject: [PATCH] Improved contectName function --- app/src/main/kotlin/com/tutpro/baresip/Contact.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/Contact.kt b/app/src/main/kotlin/com/tutpro/baresip/Contact.kt index 5bc153e6..e35b73e5 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Contact.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Contact.kt @@ -34,11 +34,12 @@ sealed class Contact { // Return contact name of uri or uri itself if contact with uri is not found fun contactName(uri: String): String { - val userPart = Utils.uriUserPart(uri) - val contact = if (Utils.isTelNumber(userPart)) - findContact("tel:$userPart") - else - findContact(uri) + var contact = findContact(uri) + if (contact == null) { + val userPart = Utils.uriUserPart(uri) + if (Utils.isTelNumber(userPart)) + contact = findContact("tel:$userPart") + } if (contact != null) { return when (contact) { is BaresipContact ->