diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c6e8f0cfb..2a97f4120 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -87,6 +87,17 @@ + + + + + + + + + + + { handleSendIntent(intent, true) } + Intent.ACTION_VIEW, Intent.ACTION_DIAL, Intent.ACTION_CALL -> { + handleCallIntent(intent) + } } } + @MainThread private fun handleMainIntent(intent: Intent, defaultDestination: Int, isNewIntent: Boolean) { val navGraph = findNavController().navInflater.inflate(R.navigation.main_nav_graph) if (intent.hasExtra("Chat")) { @@ -373,6 +379,7 @@ class MainActivity : GenericActivity() { } } + @MainThread private fun handleSendIntent(intent: Intent, multiple: Boolean) { val parcelablesUri = arrayListOf() @@ -462,6 +469,34 @@ class MainActivity : GenericActivity() { } } + @MainThread + private fun handleCallIntent(intent: Intent) { + val uri = intent.data?.toString() + if (uri.isNullOrEmpty()) { + Log.e("$TAG Intent data is null or empty, can't process [${intent.action}] intent") + return + } + + Log.i("$TAG Found URI [$uri] as data for intent [${intent.action}]") + val sipUriToCall = if (uri.startsWith("tel:")) { + uri.substring("tel:".length) + } else { + uri + }.replace("%40", "@") // Unescape @ character if needed + + coreContext.postOnCoreThread { + val applyPrefix = LinphoneUtils.getDefaultAccount()?.params?.useInternationalPrefixForCallsAndChats ?: false + val address = coreContext.core.interpretUrl( + sipUriToCall, + applyPrefix + ) + Log.i("$TAG Interpreted SIP URI is [${address?.asStringUriOnly()}]") + if (address != null) { + coreContext.startCall(address) + } + } + } + private fun loadContacts() { coreContext.contactsManager.loadContacts(this)