From 8c86c14844dfdf71458675cc66f162361ca066cc Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Thu, 24 Apr 2025 08:10:15 +0300 Subject: [PATCH] User alert dialog instead of toast for no network/aec info --- .../com/tutpro/baresip/BaresipService.kt | 24 +++++++++++++------ .../kotlin/com/tutpro/baresip/MainActivity.kt | 6 +++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 06f8af23..a0f7b0d1 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -498,13 +498,23 @@ class BaresipService: Service() { ) } - var message = "" - if (linkAddresses.isEmpty()) - message = '\u2022' + " " + getString(R.string.no_network) + '\n' - if (!aecAvailable) - message = message + '\u2022' + " " + getString(R.string.no_aec) + '\n' - if (message != "") - toast(message.dropLast(1), Toast.LENGTH_LONG) + val message = if (linkAddresses.isEmpty()) { + if (!aecAvailable) + '\u2022' + " " + getString(R.string.no_network) + '\n' + + '\u2022' + " " + getString(R.string.no_aec) + else + getString(R.string.no_network) + } + else + if (!aecAvailable) getString(R.string.no_aec) else "" + if (message != "") { + 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", "no,$message") + startActivity(newIntent) + } } "Start Content Observer" -> { diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt index f15e1223..cba806ee 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt @@ -2187,6 +2187,12 @@ class MainActivity : ComponentActivity() { Log.d(TAG, "Handling intent '$action'") val ev = action.split(",") when (ev[0]) { + "no" -> { + alertTitle.value = getString(R.string.notice) + alertMessage.value = ev[1] + showAlert.value = true + return + } "call", "dial" -> { if (Call.inCall()) { Toast.makeText(applicationContext, getString(R.string.call_already_active),