From fd959082ce1c0e5f01ee84e06e428461419be515 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Fri, 14 Aug 2026 10:05:04 +0300 Subject: [PATCH] Show contact name and label in call uri field when a suggestion is selected --- .../kotlin/com/tutpro/baresip/ChatsScreen.kt | 2 +- .../main/kotlin/com/tutpro/baresip/Contact.kt | 31 ++++++++----------- .../kotlin/com/tutpro/baresip/MainScreen.kt | 11 +++++-- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/ChatsScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/ChatsScreen.kt index 192c7982..3e06e908 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ChatsScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ChatsScreen.kt @@ -540,7 +540,7 @@ private fun NewChatPeer(navController: NavController, account: Account) { .fillMaxWidth() .clickable { val uri = matchingUri?.uri ?: contact.uris().firstOrNull()?.uri ?: contact.name() - newPeer = uri.substringAfter(":") + newPeer = Utils.friendlyUri(uri, account) showSuggestions = false } .padding(12.dp) diff --git a/app/src/main/kotlin/com/tutpro/baresip/Contact.kt b/app/src/main/kotlin/com/tutpro/baresip/Contact.kt index 16b23b61..818782ad 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Contact.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Contact.kt @@ -126,25 +126,20 @@ sealed class Contact { fun contactContactUris(name: String, tel: Boolean = false): List { synchronized(BaresipService.contacts) { - for (c in BaresipService.contacts) - when (c) { - is BaresipContact -> { - if (c.name.equals(name, ignoreCase = true)) { - return if (tel) - c.uris.filter { it.uri.startsWith("tel:") } - else - c.uris - } - } - is AndroidContact -> { - if (c.name == name) { - return if (tel) - c.uris.filter { it.uri.startsWith("tel:") } - else - c.uris - } - } + for (c in BaresipService.contacts) { + val contactUris = if (tel) + c.uris().filter { it.uri.startsWith("tel:") } + else + c.uris() + if (c.name().equals(name, ignoreCase = true)) + return contactUris + for (u in contactUris) { + val label = u.label + val nameWithLabel = if (label.isNotEmpty()) "${c.name()} $label" else c.name() + if (nameWithLabel.equals(name, ignoreCase = true)) + return listOf(u) } + } } return emptyList() } diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt index bf0bfb3d..ba6ea443 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt @@ -1339,7 +1339,14 @@ private fun CallUriRow( .fillMaxWidth() .clickable { val uri = matchingUri?.uri ?: contact.uris().firstOrNull()?.uri ?: contact.name() - dialerState.callUri.value = uri.substringAfter(":") + val aor = viewModel.selectedAor.value + val account = Account.ofAor(aor) + if (account != null) { + dialerState.callUri.value = Utils.friendlyUri(ctx, uri, account) + dialerState.redialUri = uri + } else { + dialerState.callUri.value = uri.substringAfter(":") + } dialerState.showSuggestions.value = false } .padding(12.dp) @@ -1752,7 +1759,7 @@ private fun CallRow( .fillMaxWidth() .clickable { val uri = matchingUri?.uri ?: contact.uris().firstOrNull()?.uri ?: contact.name() - transferUri = uri.substringAfter(":") + transferUri = Utils.friendlyUri(ctx, uri, call.ua.account) call.showSuggestions.value = false } .padding(12.dp)