- 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))
}
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),
@@ -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")
@@ -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()
@@ -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
}
@@ -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))