Use telephony provider also when sending message to tel URI

This commit is contained in:
Juha Heinanen
2023-02-26 05:52:07 +02:00
parent fd25cc0bfd
commit 3eac700fb5
3 changed files with 26 additions and 9 deletions
@@ -2,6 +2,7 @@ package com.tutpro.baresip
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.SystemClock import android.os.SystemClock
@@ -17,6 +18,7 @@ import android.widget.Toast
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tutpro.baresip.databinding.ActivityChatBinding import com.tutpro.baresip.databinding.ActivityChatBinding
class ChatActivity : AppCompatActivity() { class ChatActivity : AppCompatActivity() {
@@ -121,16 +123,28 @@ class ChatActivity : AppCompatActivity() {
val msg = Message(aor, peerUri, msgText, time, R.drawable.arrow_up_yellow, val msg = Message(aor, peerUri, msgText, time, R.drawable.arrow_up_yellow,
0, "", true) 0, "", true)
msg.add() msg.add()
var msgUri = ""
chatMessages.add(msg) chatMessages.add(msg)
if (Api.message_send(ua.uap, peerUri, msgText, time.toString()) != 0) { if (Utils.isTelUri(peerUri))
Toast.makeText(applicationContext, "${getString(R.string.message_failed)}!", if (ua.account.telProvider == "") {
Toast.LENGTH_SHORT).show() Utils.alertView(this, getString(R.string.notice),
msg.direction = R.drawable.arrow_up_red String.format(getString(R.string.no_telephony_provider),
msg.responseReason = getString(R.string.message_failed) Utils.plainAor(aor)))
} else { } else {
newMessage.text.clear() msgUri = Utils.telToSip(peerUri, ua.account)
BaresipService.chatTexts.remove("$aor::$peerUri") }
} 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() mlAdapter.notifyDataSetChanged()
} }
} }
+2
View File
@@ -465,6 +465,8 @@
<string name="invalid_sip_uri">Virheellinen SIP URI \'%1$s\'</string> <string name="invalid_sip_uri">Virheellinen SIP URI \'%1$s\'</string>
<string name="no_telephony_providers">Millekään tilille ei ole konfiguroitu puhelinpalvelun <string name="no_telephony_providers">Millekään tilille ei ole konfiguroitu puhelinpalvelun
tarjoajaa</string> tarjoajaa</string>
<string name="no_telephony_provider">Tilille \'%1$s\' ei ole konfiguroitu puhelinpalvelun
tarjoajaa</string>
<string name="callee">Puhelun kohde</string> <string name="callee">Puhelun kohde</string>
<string name="hangup">Lopeta</string> <string name="hangup">Lopeta</string>
<string name="video_call">Videopuhelu</string> <string name="video_call">Videopuhelu</string>
+1
View File
@@ -437,6 +437,7 @@
<string name="diverted_by_dots">Diverted by …</string> <string name="diverted_by_dots">Diverted by …</string>
<string name="transferring_call_to_dots">Transferring call to …</string> <string name="transferring_call_to_dots">Transferring call to …</string>
<string name="invalid_sip_uri">Invalid SIP URI \'%1$s\'</string> <string name="invalid_sip_uri">Invalid SIP URI \'%1$s\'</string>
<string name="no_telephony_provider">Account \'%1$s\' has no Telephony Provider</string>
<string name="no_telephony_providers">Telephony Provider has not been configured for any account.</string> <string name="no_telephony_providers">Telephony Provider has not been configured for any account.</string>
<string name="choose_telephony_provider_account">Choose Telephony Provider account</string> <string name="choose_telephony_provider_account">Choose Telephony Provider account</string>
<string name="callee">Callee</string> <string name="callee">Callee</string>