From 3eac700fb5d1c3d94dc37df2f0b11541ee16d19d Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sun, 26 Feb 2023 05:52:07 +0200 Subject: [PATCH] Use telephony provider also when sending message to tel URI --- .../kotlin/com/tutpro/baresip/ChatActivity.kt | 32 +++++++++++++------ app/src/main/res/values-fi/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt index 6e07837b..2c66dd29 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ChatActivity.kt @@ -2,6 +2,7 @@ package com.tutpro.baresip import android.app.Activity import android.content.Context +import android.content.DialogInterface import android.content.Intent import android.os.Bundle import android.os.SystemClock @@ -17,6 +18,7 @@ import android.widget.Toast import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.Observer +import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.tutpro.baresip.databinding.ActivityChatBinding class ChatActivity : AppCompatActivity() { @@ -121,16 +123,28 @@ class ChatActivity : AppCompatActivity() { val msg = Message(aor, peerUri, msgText, time, R.drawable.arrow_up_yellow, 0, "", true) msg.add() + var msgUri = "" chatMessages.add(msg) - if (Api.message_send(ua.uap, peerUri, msgText, time.toString()) != 0) { - Toast.makeText(applicationContext, "${getString(R.string.message_failed)}!", - Toast.LENGTH_SHORT).show() - msg.direction = R.drawable.arrow_up_red - msg.responseReason = getString(R.string.message_failed) - } else { - newMessage.text.clear() - BaresipService.chatTexts.remove("$aor::$peerUri") - } + if (Utils.isTelUri(peerUri)) + if (ua.account.telProvider == "") { + Utils.alertView(this, getString(R.string.notice), + String.format(getString(R.string.no_telephony_provider), + Utils.plainAor(aor))) + } else { + msgUri = Utils.telToSip(peerUri, ua.account) + } + else + msgUri = peerUri + if (msgUri != "") + if (Api.message_send(ua.uap, msgUri, msgText, time.toString()) != 0) { + Toast.makeText(applicationContext, "${getString(R.string.message_failed)}!", + Toast.LENGTH_SHORT).show() + msg.direction = R.drawable.arrow_up_red + msg.responseReason = getString(R.string.message_failed) + } else { + newMessage.text.clear() + BaresipService.chatTexts.remove("$aor::$peerUri") + } mlAdapter.notifyDataSetChanged() } } diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 74b0b6a7..c8bc875e 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -465,6 +465,8 @@ Virheellinen SIP URI \'%1$s\' Millekään tilille ei ole konfiguroitu puhelinpalvelun tarjoajaa + Tilille \'%1$s\' ei ole konfiguroitu puhelinpalvelun + tarjoajaa Puhelun kohde Lopeta Videopuhelu diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c8078468..1e67a33b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -437,6 +437,7 @@ Diverted by … Transferring call to … Invalid SIP URI \'%1$s\' + Account \'%1$s\' has no Telephony Provider Telephony Provider has not been configured for any account. Choose Telephony Provider account Callee