From 94d373c2733568b9dffb05402d9892deb3dfd995 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Thu, 5 Mar 2020 04:45:01 +0200 Subject: [PATCH] - More work on string resources. - Always use alert heading Notice when user enters invalid input. --- .../com/tutpro/baresip/AccountActivity.kt | 3 ++- .../com/tutpro/baresip/AccountsActivity.kt | 2 +- .../com/tutpro/baresip/ChatsActivity.kt | 2 +- .../com/tutpro/baresip/ContactActivity.kt | 6 +++--- .../kotlin/com/tutpro/baresip/MainActivity.kt | 21 +++++++++++-------- app/src/main/res/values-bg/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-fi/strings.xml | 3 ++- app/src/main/res/values-nb-rNO/strings.xml | 2 +- app/src/main/res/values-ro/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 3 ++- 11 files changed, 28 insertions(+), 22 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt index aeea2253..0521692c 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt @@ -490,7 +490,8 @@ class AccountActivity : AppCompatActivity() { getString(R.string.outbound_proxies_help)) } findViewById(R.id.RegTitle) as TextView -> { - Utils.alertView(this, "Register", getString(R.string.register_help)) + Utils.alertView(this, getString(R.string.register), + getString(R.string.register_help)) } findViewById(R.id.AudioCodecsTitle) as TextView -> { Utils.alertView(this, getString(R.string.audio_codecs), diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountsActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountsActivity.kt index bee2976b..c407c6ab 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AccountsActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AccountsActivity.kt @@ -34,7 +34,7 @@ class AccountsActivity : AppCompatActivity() { val aor = newAorView.text.toString().trim() if (!Utils.checkAor(aor)) { Log.d("Baresip", "Invalid Address of Record $aor") - Utils.alertView(this, getString(R.string.error), + Utils.alertView(this, getString(R.string.notice), String.format(getString(R.string.invalid_aor), aor)) } else if (Account.exists(aor)) { Log.d("Baresip", "Account $aor already exists") diff --git a/app/src/main/kotlin/com/tutpro/baresip/ChatsActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ChatsActivity.kt index da63f962..7673cb50 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ChatsActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ChatsActivity.kt @@ -113,7 +113,7 @@ class ChatsActivity: AppCompatActivity() { } } if (!Utils.checkSipUri(uri)) { - Utils.alertView(this, getString(R.string.error), + Utils.alertView(this, getString(R.string.notice), getString(R.string.invalid_chat_peer_uri)) } else { peerUri.text.clear() diff --git a/app/src/main/kotlin/com/tutpro/baresip/ContactActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ContactActivity.kt index 7af88b22..b08eb4ad 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ContactActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ContactActivity.kt @@ -164,7 +164,7 @@ class ContactActivity : AppCompatActivity() { if (newName == "") newName = newUri if (!Utils.checkName(newName)) { - Utils.alertView(this, getString(R.string.error), + Utils.alertView(this, getString(R.string.notice), String.format(getString(R.string.invalid_contact), newName)) return false } @@ -175,7 +175,7 @@ class ContactActivity : AppCompatActivity() { alert = (Contact.contacts()[index].name != newName) && ContactsActivity.nameExists(newName, false) if (alert) { - Utils.alertView(this, getString(R.string.error), + Utils.alertView(this, getString(R.string.notice), String.format(getString(R.string.contact_already_exists), newName)) return false } @@ -188,7 +188,7 @@ class ContactActivity : AppCompatActivity() { } } if (!Utils.checkSipUri(newUri)) { - Utils.alertView(this, getString(R.string.error), + Utils.alertView(this, getString(R.string.notice), String.format(getString(R.string.invalid_contact_uri), newUri)) return false } diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt index f961aa82..0e0275f9 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt @@ -240,7 +240,8 @@ class MainActivity : AppCompatActivity() { } } if (!Utils.checkSipUri(uri)) { - Utils.alertView(this, getString(R.string.notice), "${getString(R.string.invalid_sip_uri)} '$uri'") + Utils.alertView(this, getString(R.string.notice), + String.format(getString(R.string.invalid_sip_uri), uri)) } else { callUri.isFocusable = false // Set audio mode to MODE_IN_COMMUNICATION and wait 2.5 sec before @@ -323,7 +324,6 @@ class MainActivity : AppCompatActivity() { } infoButton.setOnClickListener { - Log.d("Baresip", "Info Button was clicked") val ua = UserAgent.uas()[aorSpinner.selectedItemPosition] val calls = Call.uaCalls(ua, "") if (calls.size > 0) { @@ -341,7 +341,8 @@ class MainActivity : AppCompatActivity() { "${rxCodec[0]} ch ${rxCodec[2]}\n" + "${getString(R.string.rate)}: $rate") } else { - Utils.alertView(this, "Call Info", "No info available.") + Utils.alertView(this, getString(R.string.call_info), + getString(R.string.call_info_not_available)) } } } @@ -974,12 +975,14 @@ class MainActivity : AppCompatActivity() { val backupFilePath = BaresipService.downloadsPath + "/baresip.bs" val zipFilePath = BaresipService.filesPath + "/baresip.zip" if (!Utils.zip(files, "baresip.zip")) { - Utils.alertView(this, getString(R.string.error), "Failed to write zip file 'baresip.zip") + Log.w("Baresip", "Failed to write zip file 'baresip.zip") + Utils.alertView(this, getString(R.string.error), getString(R.string.backup_failed)) return } val content = Utils.getFileContents(zipFilePath) if (content == null) { - Utils.alertView(this, getString(R.string.error), "Failed to read zip file 'baresip.zip") + Log.w("Baresip", "Failed to read zip file 'baresip.zip") + Utils.alertView(this, getString(R.string.error), getString(R.string.backup_failed)) return } if (!Utils.encryptToFile(backupFilePath, content, password)) { @@ -999,13 +1002,13 @@ class MainActivity : AppCompatActivity() { return } if (!Utils.putFileContents(zipFilePath, zipData)) { - Utils.alertView(this, getString(R.string.error), - "Failed to write file 'baresip.zip'") + Log.w("Baresip", "Failed to write zip file 'baresip.zip") + Utils.alertView(this, getString(R.string.error), getString(R.string.restore_failed)) return } if (!Utils.unZip(zipFilePath)) { - Utils.alertView(this, getString(R.string.error), - "Failed to unzip file 'baresip.zip'") + Log.w("Baresip", "Failed to unzip file 'baresip.zip") + Utils.alertView(this, getString(R.string.error), getString(R.string.restore_failed)) return } Utils.deleteFile(File(zipFilePath)) diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 47cd0b41..2444de85 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -220,7 +220,7 @@ Изходящо повикване до… Входящо обаждане от… Прехвърляне на обаждане до… - Невалиден SIP URI + Невалиден SIP URI \'%1$s\' Набиране Затвори Задържане diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 535a223c..05cc0956 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -213,7 +213,7 @@ Llamada saliente a… Llamada entrante de … Transfiriendo llamada a … - URI de SIP no válido + URI de SIP no válido \'%1$s\' Destinatario Colgar Esperar diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 04b52a72..62cc32d2 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -297,12 +297,13 @@ Lähtevä puhelu … Tuleva puhelu … Siirtopuhelu … - Virheellinen SIP URI + Virheellinen SIP URI \'%1$s\' Puhelun kohde Lopeta Aseta puhelu pitoon DTMF Puhelutiedot + Ei saatavilla Kesto Koodekit Nopeus diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index df81b924..dcdcbd4e 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -148,7 +148,7 @@ Ugyldig SIP URI Ønsker du å ringe eller sende melding til \"%1$s\"\? Ditt har nådd ditt maksimale antall kontakter på %1$d. - Ugyldig SIP URI + Ugyldig SIP URI \'%1$s\' Ringer Legg på Sett på vent diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 65050dac..49aef605 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -105,7 +105,7 @@ Apel efectuat către … Apel primit de la … Transfer apel către … - Adresă SIP invalidă + Adresă SIP invalidă \'%1$s\' Apelat Închide Pune în așteptare @@ -165,4 +165,4 @@ Copie de rezervă Restaurare Codecurile audio furnizate de modulele bifate sunt disponibile pentru utilizare de către conturi. - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b67a04c8..7b4e8060 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -269,12 +269,13 @@ Outgoing call to … Incoming call from … Transferring call to … - Invalid SIP URI + Invalid SIP URI \'%1$s\' Callee Hangup Hold DTMF Call Info + No info available Duration Codecs Rate