- 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

View File

@ -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),

View File

@ -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")

View File

@ -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()

View File

@ -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
}

View File

@ -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))

View File

@ -220,7 +220,7 @@
<string name="outgoing_call_to_dots">Изходящо повикване до…</string>
<string name="incoming_call_from_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="hangup">Затвори</string>
<string name="hold">Задържане</string>

View File

@ -213,7 +213,7 @@
<string name="outgoing_call_to_dots">Llamada saliente a…</string>
<string name="incoming_call_from_dots">Llamada entrante de …</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="hangup">Colgar</string>
<string name="hold">Esperar</string>

View File

@ -297,12 +297,13 @@
<string name="outgoing_call_to_dots">Lähtevä puhelu …</string>
<string name="incoming_call_from_dots">Tuleva puhelu …</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="hangup">Lopeta</string>
<string name="hold">Aseta puhelu pitoon</string>
<string name="dtmf">DTMF</string>
<string name="call_info">Puhelutiedot</string>
<string name="call_info_not_available">Ei saatavilla</string>
<string name="duration">Kesto</string>
<string name="codecs">Koodekit</string>
<string name="rate">Nopeus</string>

View File

@ -148,7 +148,7 @@
<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="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="hangup">Legg på</string>
<string name="hold">Sett på vent</string>

View File

@ -105,7 +105,7 @@
<string name="outgoing_call_to_dots">Apel efectuat către …</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="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="hangup">Închide</string>
<string name="hold">Pune în așteptare</string>
@ -165,4 +165,4 @@
<string name="backup">Copie de rezervă</string>
<string name="restore">Restaurare</string>
<string name="audio_modules_help">Codecurile audio furnizate de modulele bifate sunt disponibile pentru utilizare de către conturi.</string>
</resources>
</resources>

View File

@ -269,12 +269,13 @@
<string name="outgoing_call_to_dots">Outgoing call to …</string>
<string name="incoming_call_from_dots">Incoming call from …</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="hangup">Hangup</string>
<string name="hold">Hold</string>
<string name="dtmf">DTMF</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="codecs">Codecs</string>
<string name="rate">Rate</string>