diff --git a/app/src/main/kotlin/com/tutpro/baresip/AudioActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/AudioActivity.kt index edf1b250..40bcc035 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AudioActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AudioActivity.kt @@ -18,6 +18,7 @@ class AudioActivity : AppCompatActivity() { private lateinit var opusBitRate: EditText private lateinit var opusPacketLoss: EditText private lateinit var aec: CheckBox + private lateinit var speakerPhone: CheckBox private lateinit var audioDelay: EditText private var save = false @@ -73,6 +74,9 @@ class AudioActivity : AppCompatActivity() { } } + speakerPhone = binding.SpeakerPhone + speakerPhone.isChecked = BaresipService.speakerPhone + val modules = Config.variables("module") val audioModulesList = binding.AudioModulesList @@ -175,6 +179,13 @@ class AudioActivity : AppCompatActivity() { save = true } + if (speakerPhone.isChecked != BaresipService.speakerPhone) { + BaresipService.speakerPhone = speakerPhone.isChecked + Config.replaceVariable("speaker_phone", + if (BaresipService.speakerPhone) "yes" else "no") + save = true + } + var id = 1001 for (module in audioModules) { val box = findViewById(id++) @@ -287,6 +298,10 @@ class AudioActivity : AppCompatActivity() { Utils.alertView(this, getString(R.string.default_call_volume), getString(R.string.default_call_volume_help)) } + binding.SpeakerPhoneTitle.setOnClickListener { + Utils.alertView(this, getString(R.string.speaker_phone), + getString(R.string.speaker_phone_help)) + } binding.AudioModulesTitle.setOnClickListener { Utils.alertView(this, getString(R.string.audio_modules_title), getString(R.string.audio_modules_help)) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 79f0aea7..7966ea4e 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -682,6 +682,8 @@ class BaresipService: Service() { break stopMediaPlayer() setCallVolume() + if (speakerPhone && !Utils.isSpeakerPhoneOn(am)) + Utils.toggleSpeakerPhone(ContextCompat.getMainExecutor(this), am) proximitySensing(true) return } @@ -728,22 +730,23 @@ class BaresipService: Service() { ua.account.missedCalls = true } return + } + Log.d(TAG, "Incoming call $uap/$callp/$peerUri") + Call(callp, ua, peerUri, "in", "incoming", Utils.dtmfWatcher(callp)).add() + if (speakerPhone && !Utils.isSpeakerPhoneOn(am)) + Utils.toggleSpeakerPhone(ContextCompat.getMainExecutor(this), am) + if (ua.account.answerMode == Api.ANSWERMODE_MANUAL) { + Log.d(TAG, "CurrentInterruptionFilter ${nm.currentInterruptionFilter}") + if (nm.currentInterruptionFilter <= NotificationManager.INTERRUPTION_FILTER_ALL) + startRinging() } else { - Log.d(TAG, "Incoming call $uap/$callp/$peerUri") - Call(callp, ua, peerUri, "in", "incoming", Utils.dtmfWatcher(callp)).add() - if (ua.account.answerMode == Api.ANSWERMODE_MANUAL) { - Log.d(TAG, "CurrentInterruptionFilter ${nm.currentInterruptionFilter}") - if (nm.currentInterruptionFilter <= NotificationManager.INTERRUPTION_FILTER_ALL) - startRinging() - } else { - val newIntent = Intent(this, MainActivity::class.java) - newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or - Intent.FLAG_ACTIVITY_NEW_TASK - newIntent.putExtra("action", "call answer") - newIntent.putExtra("callp", callp) - startActivity(newIntent) - return - } + val newIntent = Intent(this, MainActivity::class.java) + newIntent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or + Intent.FLAG_ACTIVITY_NEW_TASK + newIntent.putExtra("action", "call answer") + newIntent.putExtra("callp", callp) + startActivity(newIntent) + return } if (!Utils.isVisible()) { val piFlags = PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT @@ -1558,6 +1561,7 @@ class BaresipService: Service() { var isConfigInitialized = false var libraryLoaded = false var callVolume = 0 + var speakerPhone = false var audioDelay = if (VERSION.SDK_INT < 31) 1500L else 500L var dynDns = false var filesPath = "" diff --git a/app/src/main/kotlin/com/tutpro/baresip/Config.kt b/app/src/main/kotlin/com/tutpro/baresip/Config.kt index afbc2e1d..e7a69980 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Config.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Config.kt @@ -137,6 +137,14 @@ object Config { config = "${config}call_volume ${BaresipService.callVolume}\n" } + val speakerPhone = previousVariable("speaker_phone") + if (speakerPhone != "") { + config = "${config}speaker_phone $speakerPhone\n" + BaresipService.speakerPhone = speakerPhone == "yes" + } else { + config = "${config}speaker_phone no\n" + } + val previousModules = previousVariables("module") for (module in AudioActivity.audioModules) if ("${module}.so" in previousModules) diff --git a/app/src/main/res/layout/activity_audio.xml b/app/src/main/res/layout/activity_audio.xml index 7a77564b..d5941e79 100644 --- a/app/src/main/res/layout/activity_audio.xml +++ b/app/src/main/res/layout/activity_audio.xml @@ -40,6 +40,31 @@ + + + + + + + Audio Audio-asetukset + Kaiutin + Jos merkitty, kaiutin kytketään sutomaattisesti päälle + kun puhelu alkaa. + Audio-modulit Merkittyjen modulien tarjoamat audio-koodekit ovat tilien käytettävissä. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cfdb3a22..090c5b5c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -334,6 +334,9 @@ Download folder. Audio Audio Settings + Speaker Phone + If checked, speaker phone is turned automatically on + when call starts. Audio Modules Audio codecs provided by the checked modules are available for use by the accounts.