From a98982c2ed182b9bd223f7c3a432e79224b031c0 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Mon, 6 Mar 2023 07:15:44 +0200 Subject: [PATCH] Require that the active account has telephony provider when making call to tel uri --- .../kotlin/com/tutpro/baresip/MainActivity.kt | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt index c9cefdae..ae900518 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt @@ -1751,14 +1751,14 @@ class MainActivity : AppCompatActivity() { } } - private fun makeCall(lookContact: Boolean = true) { + private fun makeCall(lookForContact: Boolean = true) { callUri.setAdapter(null) val ua = BaresipService.uas[aorSpinner.selectedItemPosition] val aor = ua.account.aor if (Call.calls().isEmpty()) { var uriText = callUri.text.toString().trim() if (uriText.isNotEmpty()) { - if (lookContact) { + if (lookForContact) { val uris = Contact.contactUris(uriText) if (uris.size == 1) uriText = uris[0] @@ -1780,33 +1780,17 @@ class MainActivity : AppCompatActivity() { uriText = "tel:$uriText" val uri = if (Utils.isTelUri(uriText)) { if (ua.account.telProvider == "") { - val telAccounts = Account.telProviderAccounts() - if (telAccounts.isEmpty()) { - Utils.alertView(this, getString(R.string.notice), - getString(R.string.no_telephony_providers)) - } else { - val builder = MaterialAlertDialogBuilder(this, R.style.AlertDialogTheme) - with(builder) { - setTitle(getString(R.string.choose_telephony_provider_account)) - setItems(telAccounts) { _, which -> - spinToAor("sip:${telAccounts[which]}") - makeCall() - } - setNeutralButton("Cancel") { _: DialogInterface, _: Int -> } - show() - } - } + Utils.alertView(this, getString(R.string.notice), + getString(R.string.no_telephony_provider)) return } Utils.telToSip(uriText, ua.account) } else { Utils.uriComplete(uriText, aor) } - Log.d(TAG, "********* uriText = $uriText") if (!Utils.checkUri(uri)) { Utils.alertView(this, getString(R.string.notice), - String.format(getString(R.string.invalid_sip_or_tel_uri), uri) - ) + String.format(getString(R.string.invalid_sip_or_tel_uri), uri)) } else { callUri.isFocusable = false uaAdapter.notifyDataSetChanged()