- More work on string resources.

- Always use alert heading Notice when user enters invalid input.
This commit is contained in:
Juha Heinanen
2020-03-05 04:45:01 +02:00
parent 73d6388fb0
commit 94d373c273
11 changed files with 28 additions and 22 deletions
@@ -490,7 +490,8 @@ class AccountActivity : AppCompatActivity() {
getString(R.string.outbound_proxies_help)) getString(R.string.outbound_proxies_help))
} }
findViewById(R.id.RegTitle) as TextView -> { 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 -> { findViewById(R.id.AudioCodecsTitle) as TextView -> {
Utils.alertView(this, getString(R.string.audio_codecs), Utils.alertView(this, getString(R.string.audio_codecs),
@@ -34,7 +34,7 @@ class AccountsActivity : AppCompatActivity() {
val aor = newAorView.text.toString().trim() val aor = newAorView.text.toString().trim()
if (!Utils.checkAor(aor)) { if (!Utils.checkAor(aor)) {
Log.d("Baresip", "Invalid Address of Record $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)) String.format(getString(R.string.invalid_aor), aor))
} else if (Account.exists(aor)) { } else if (Account.exists(aor)) {
Log.d("Baresip", "Account $aor already exists") Log.d("Baresip", "Account $aor already exists")
@@ -113,7 +113,7 @@ class ChatsActivity: AppCompatActivity() {
} }
} }
if (!Utils.checkSipUri(uri)) { 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)) getString(R.string.invalid_chat_peer_uri))
} else { } else {
peerUri.text.clear() peerUri.text.clear()
@@ -164,7 +164,7 @@ class ContactActivity : AppCompatActivity() {
if (newName == "") newName = newUri if (newName == "") newName = newUri
if (!Utils.checkName(newName)) { 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)) String.format(getString(R.string.invalid_contact), newName))
return false return false
} }
@@ -175,7 +175,7 @@ class ContactActivity : AppCompatActivity() {
alert = (Contact.contacts()[index].name != newName) && alert = (Contact.contacts()[index].name != newName) &&
ContactsActivity.nameExists(newName, false) ContactsActivity.nameExists(newName, false)
if (alert) { 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)) String.format(getString(R.string.contact_already_exists), newName))
return false return false
} }
@@ -188,7 +188,7 @@ class ContactActivity : AppCompatActivity() {
} }
} }
if (!Utils.checkSipUri(newUri)) { 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)) String.format(getString(R.string.invalid_contact_uri), newUri))
return false return false
} }
@@ -240,7 +240,8 @@ class MainActivity : AppCompatActivity() {
} }
} }
if (!Utils.checkSipUri(uri)) { 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 { } else {
callUri.isFocusable = false callUri.isFocusable = false
// Set audio mode to MODE_IN_COMMUNICATION and wait 2.5 sec before // Set audio mode to MODE_IN_COMMUNICATION and wait 2.5 sec before
@@ -323,7 +324,6 @@ class MainActivity : AppCompatActivity() {
} }
infoButton.setOnClickListener { infoButton.setOnClickListener {
Log.d("Baresip", "Info Button was clicked")
val ua = UserAgent.uas()[aorSpinner.selectedItemPosition] val ua = UserAgent.uas()[aorSpinner.selectedItemPosition]
val calls = Call.uaCalls(ua, "") val calls = Call.uaCalls(ua, "")
if (calls.size > 0) { if (calls.size > 0) {
@@ -341,7 +341,8 @@ class MainActivity : AppCompatActivity() {
"${rxCodec[0]} ch ${rxCodec[2]}\n" + "${rxCodec[0]} ch ${rxCodec[2]}\n" +
"${getString(R.string.rate)}: $rate") "${getString(R.string.rate)}: $rate")
} else { } 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 backupFilePath = BaresipService.downloadsPath + "/baresip.bs"
val zipFilePath = BaresipService.filesPath + "/baresip.zip" val zipFilePath = BaresipService.filesPath + "/baresip.zip"
if (!Utils.zip(files, "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 return
} }
val content = Utils.getFileContents(zipFilePath) val content = Utils.getFileContents(zipFilePath)
if (content == null) { 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 return
} }
if (!Utils.encryptToFile(backupFilePath, content, password)) { if (!Utils.encryptToFile(backupFilePath, content, password)) {
@@ -999,13 +1002,13 @@ class MainActivity : AppCompatActivity() {
return return
} }
if (!Utils.putFileContents(zipFilePath, zipData)) { if (!Utils.putFileContents(zipFilePath, zipData)) {
Utils.alertView(this, getString(R.string.error), Log.w("Baresip", "Failed to write zip file 'baresip.zip")
"Failed to write file 'baresip.zip'") Utils.alertView(this, getString(R.string.error), getString(R.string.restore_failed))
return return
} }
if (!Utils.unZip(zipFilePath)) { if (!Utils.unZip(zipFilePath)) {
Utils.alertView(this, getString(R.string.error), Log.w("Baresip", "Failed to unzip file 'baresip.zip")
"Failed to unzip file 'baresip.zip'") Utils.alertView(this, getString(R.string.error), getString(R.string.restore_failed))
return return
} }
Utils.deleteFile(File(zipFilePath)) Utils.deleteFile(File(zipFilePath))
+1 -1
View File
@@ -220,7 +220,7 @@
<string name="outgoing_call_to_dots">Изходящо повикване до…</string> <string name="outgoing_call_to_dots">Изходящо повикване до…</string>
<string name="incoming_call_from_dots">Входящо обаждане от…</string> <string name="incoming_call_from_dots">Входящо обаждане от…</string>
<string name="transferring_call_to_dots">Прехвърляне на обаждане до…</string> <string name="transferring_call_to_dots">Прехвърляне на обаждане до…</string>
<string name="invalid_sip_uri">Невалиден SIP URI</string> <string name="invalid_sip_uri">Невалиден SIP URI \'%1$s\'</string>
<string name="callee">Набиране</string> <string name="callee">Набиране</string>
<string name="hangup">Затвори</string> <string name="hangup">Затвори</string>
<string name="hold">Задържане</string> <string name="hold">Задържане</string>
+1 -1
View File
@@ -213,7 +213,7 @@
<string name="outgoing_call_to_dots">Llamada saliente a…</string> <string name="outgoing_call_to_dots">Llamada saliente a…</string>
<string name="incoming_call_from_dots">Llamada entrante de …</string> <string name="incoming_call_from_dots">Llamada entrante de …</string>
<string name="transferring_call_to_dots">Transfiriendo llamada a …</string> <string name="transferring_call_to_dots">Transfiriendo llamada a …</string>
<string name="invalid_sip_uri">URI de SIP no válido</string> <string name="invalid_sip_uri">URI de SIP no válido \'%1$s\'</string>
<string name="callee">Destinatario</string> <string name="callee">Destinatario</string>
<string name="hangup">Colgar</string> <string name="hangup">Colgar</string>
<string name="hold">Esperar</string> <string name="hold">Esperar</string>
+2 -1
View File
@@ -297,12 +297,13 @@
<string name="outgoing_call_to_dots">Lähtevä puhelu …</string> <string name="outgoing_call_to_dots">Lähtevä puhelu …</string>
<string name="incoming_call_from_dots">Tuleva puhelu …</string> <string name="incoming_call_from_dots">Tuleva puhelu …</string>
<string name="transferring_call_to_dots">Siirtopuhelu …</string> <string name="transferring_call_to_dots">Siirtopuhelu …</string>
<string name="invalid_sip_uri">Virheellinen SIP URI</string> <string name="invalid_sip_uri">Virheellinen SIP URI \'%1$s\'</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="hold">Aseta puhelu pitoon</string> <string name="hold">Aseta puhelu pitoon</string>
<string name="dtmf">DTMF</string> <string name="dtmf">DTMF</string>
<string name="call_info">Puhelutiedot</string> <string name="call_info">Puhelutiedot</string>
<string name="call_info_not_available">Ei saatavilla</string>
<string name="duration">Kesto</string> <string name="duration">Kesto</string>
<string name="codecs">Koodekit</string> <string name="codecs">Koodekit</string>
<string name="rate">Nopeus</string> <string name="rate">Nopeus</string>
+1 -1
View File
@@ -148,7 +148,7 @@
<string name="invalid_contact_uri">Ugyldig SIP URI</string> <string name="invalid_contact_uri">Ugyldig SIP URI</string>
<string name="contact_action_question">Ønsker du å ringe eller sende melding til \"%1$s\"\?</string> <string name="contact_action_question">Ønsker du å ringe eller sende melding til \"%1$s\"\?</string>
<string name="contacts_exceeded">Ditt har nådd ditt maksimale antall kontakter på %1$d.</string> <string name="contacts_exceeded">Ditt har nådd ditt maksimale antall kontakter på %1$d.</string>
<string name="invalid_sip_uri">Ugyldig SIP URI</string> <string name="invalid_sip_uri">Ugyldig SIP URI \'%1$s\'</string>
<string name="callee">Ringer</string> <string name="callee">Ringer</string>
<string name="hangup">Legg på</string> <string name="hangup">Legg på</string>
<string name="hold">Sett på vent</string> <string name="hold">Sett på vent</string>
+1 -1
View File
@@ -105,7 +105,7 @@
<string name="outgoing_call_to_dots">Apel efectuat către …</string> <string name="outgoing_call_to_dots">Apel efectuat către …</string>
<string name="incoming_call_from_dots">Apel primit de la …</string> <string name="incoming_call_from_dots">Apel primit de la …</string>
<string name="transferring_call_to_dots">Transfer apel către …</string> <string name="transferring_call_to_dots">Transfer apel către …</string>
<string name="invalid_sip_uri">Adresă SIP invalidă</string> <string name="invalid_sip_uri">Adresă SIP invalidă \'%1$s\'</string>
<string name="callee">Apelat</string> <string name="callee">Apelat</string>
<string name="hangup">Închide</string> <string name="hangup">Închide</string>
<string name="hold">Pune în așteptare</string> <string name="hold">Pune în așteptare</string>
+2 -1
View File
@@ -269,12 +269,13 @@
<string name="outgoing_call_to_dots">Outgoing call to …</string> <string name="outgoing_call_to_dots">Outgoing call to …</string>
<string name="incoming_call_from_dots">Incoming call from …</string> <string name="incoming_call_from_dots">Incoming call from …</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</string> <string name="invalid_sip_uri">Invalid SIP URI \'%1$s\'</string>
<string name="callee">Callee</string> <string name="callee">Callee</string>
<string name="hangup">Hangup</string> <string name="hangup">Hangup</string>
<string name="hold">Hold</string> <string name="hold">Hold</string>
<string name="dtmf">DTMF</string> <string name="dtmf">DTMF</string>
<string name="call_info">Call Info</string> <string name="call_info">Call Info</string>
<string name="call_info_not_available">No info available</string>
<string name="duration">Duration</string> <string name="duration">Duration</string>
<string name="codecs">Codecs</string> <string name="codecs">Codecs</string>
<string name="rate">Rate</string> <string name="rate">Rate</string>