- More work on strings.

This commit is contained in:
Juha Heinanen
2019-05-10 12:00:36 +03:00
parent 1e95cb8b2d
commit c061c5d2f9
8 changed files with 80 additions and 61 deletions
@@ -39,7 +39,8 @@ class AccountListAdapter(private val cxt: Context, private val rows: ArrayList<A
actionView.setOnClickListener { _ -> actionView.setOnClickListener { _ ->
Log.d("Baresip", "Delete button clicked") Log.d("Baresip", "Delete button clicked")
val deleteDialog = AlertDialog.Builder(cxt) val deleteDialog = AlertDialog.Builder(cxt)
deleteDialog.setMessage("${cxt.getString(R.string.delete_account)} ${ua.account.aor}?") deleteDialog.setMessage(String.format(cxt.getString(R.string.delete_account),
ua.account.aor))
deleteDialog.setPositiveButton(cxt.getText(R.string.cancel)) { dialog, _ -> deleteDialog.setPositiveButton(cxt.getText(R.string.cancel)) { dialog, _ ->
dialog.dismiss() dialog.dismiss()
} }
@@ -39,21 +39,21 @@ class AccountsActivity : AppCompatActivity() {
if (!aor.startsWith("sip:")) aor = "sip:$aor" if (!aor.startsWith("sip:")) aor = "sip:$aor"
if (!Utils.checkAorUri(aor)) { if (!Utils.checkAorUri(aor)) {
Log.d("Baresip", "Invalid SIP Address of Record $aor") Log.d("Baresip", "Invalid SIP Address of Record $aor")
Utils.alertView(this, "Notice", Utils.alertView(this, getString(R.string.notice),
"Invalid SIP Address of Record: $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")
Utils.alertView(this, "Notice", Utils.alertView(this, getString(R.string.notice),
"Account $aor already exists") String.format(getString(R.string.account_exists), aor))
} else { } else {
val ua = UserAgent.uaAlloc("<$aor>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0") val ua = UserAgent.uaAlloc("<$aor>;stunserver=\"stun:stun.l.google.com:19302\";regq=0.5;pubint=0;regint=0")
if (ua == null) { if (ua == null) {
Log.e("Baresip", "Failed to allocate UA for $aor") Log.e("Baresip", "Failed to allocate UA for $aor")
Utils.alertView(this, "Notice", Utils.alertView(this, getString(R.string.notice),
"Failed to allocate new account.") getString(R.string.account_allocation_failure))
} else { } else {
newAorView.setText("") newAorView.setText("")
newAorView.hint = "SIP URI user@domain" newAorView.hint = getString(R.string.sip_uri_user_domain)
newAorView.clearFocus() newAorView.clearFocus()
UserAgent.add(ua, R.drawable.dot_yellow) UserAgent.add(ua, R.drawable.dot_yellow)
generateAccounts() generateAccounts()
@@ -88,14 +88,13 @@ class AccountsActivity : AppCompatActivity() {
R.id.export_accounts -> { R.id.export_accounts -> {
if (Utils.requestPermission(this, if (Utils.requestPermission(this,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE)) android.Manifest.permission.WRITE_EXTERNAL_STORAGE))
askPassword("Encrypt Password") askPassword(getString(R.string.encrypt_password))
} }
R.id.import_accounts -> { R.id.import_accounts -> {
if (Utils.requestPermission(this, if (Utils.requestPermission(this,
android.Manifest.permission.READ_EXTERNAL_STORAGE)) { android.Manifest.permission.READ_EXTERNAL_STORAGE))
askPassword("Decrypt Password") askPassword(getString(R.string.decrypt_password))
}
} }
android.R.id.home -> { android.R.id.home -> {
Log.d("Baresip", "Back array was pressed at Accounts") Log.d("Baresip", "Back array was pressed at Accounts")
@@ -120,23 +119,20 @@ class AccountsActivity : AppCompatActivity() {
dialog.dismiss() dialog.dismiss()
password = input.text.toString() password = input.text.toString()
if (password != "") { if (password != "") {
if (title == "Encrypt Password") { if (title == getString(R.string.encrypt_password)) {
if (exportAccounts(dir, password)) if (exportAccounts(dir, password))
Utils.alertView(this, "Info", Utils.alertView(this, getString(R.string.info),
"Exported accounts to Download folder file 'accounts.bs'.") getString(R.string.exported_accounts))
else else
Utils.alertView(this, "Error", Utils.alertView(this, getString(R.string.error),
"Failed to export accounts to Download folder.") getString(R.string.export_accounts_error))
} else { } else {
if (importAccounts(dir, password)) if (importAccounts(dir, password))
Utils.alertView(this, "Info", Utils.alertView(this, getString(R.string.info),
"Imported accounts from Download folder file " + getString(R.string.imported_accounts))
"'accounts.bs'. You need to restart baresip.")
else else
Utils.alertView(this, "Error", Utils.alertView(this, getString(R.string.error),
"Failed to import accounts from Download folder. " + getString(R.string.import_accounts_error))
"Either file 'accounts.bs' doesn't exist or " +
"you gave wrong Decrypt Password.")
} }
} }
} }
@@ -59,7 +59,7 @@ class ChatActivity : AppCompatActivity() {
else else
chatPeer = chatPeer.substring(4) chatPeer = chatPeer.substring(4)
} }
setTitle("${getString(R.string.chat_with)} $chatPeer") setTitle(String.format(getString(R.string.chat_with), chatPeer))
val headerView = findViewById(R.id.account) as TextView val headerView = findViewById(R.id.account) as TextView
val headerText = "${getString(R.string.account)} ${aor.substringAfter(":")}" val headerText = "${getString(R.string.account)} ${aor.substringAfter(":")}"
@@ -91,7 +91,7 @@ class ChatsActivity: AppCompatActivity() {
.setNeutralButton(getText(R.string.add_contact), dialogClickListener) .setNeutralButton(getText(R.string.add_contact), dialogClickListener)
.show() .show()
else else
builder.setMessage("${getString(R.string.short_chat_question)} '$peer'?") builder.setMessage(String.format(getString(R.string.short_chat_question), peer))
.setPositiveButton(getText(R.string.cancel), dialogClickListener) .setPositiveButton(getText(R.string.cancel), dialogClickListener)
.setNegativeButton(getText(R.string.delete), dialogClickListener) .setNegativeButton(getText(R.string.delete), dialogClickListener)
.show() .show()
@@ -53,8 +53,8 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
} }
} }
val builder = AlertDialog.Builder(cxt, R.style.Theme_AppCompat) val builder = AlertDialog.Builder(cxt, R.style.Theme_AppCompat)
builder.setMessage(cxt.getString(R.string.contact_action_question) + builder.setMessage(String.format(cxt.getString(R.string.contact_action_question),
" '${Contact.contacts()[pos].name}'?") Contact.contacts()[pos].name))
.setNeutralButton(cxt.getText(R.string.call), dialogClickListener) .setNeutralButton(cxt.getText(R.string.call), dialogClickListener)
.setNegativeButton(cxt.getText(R.string.send_message), dialogClickListener) .setNegativeButton(cxt.getText(R.string.send_message), dialogClickListener)
.setPositiveButton(cxt.getText(R.string.cancel), dialogClickListener) .setPositiveButton(cxt.getText(R.string.cancel), dialogClickListener)
@@ -74,8 +74,8 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList<C
} }
} }
val builder = AlertDialog.Builder(cxt, R.style.Theme_AppCompat) val builder = AlertDialog.Builder(cxt, R.style.Theme_AppCompat)
builder.setMessage(cxt.getString(R.string.contact_delete_question) + builder.setMessage(String.format(cxt.getString(R.string.contact_delete_question),
" '${Contact.contacts()[pos].name}'?") Contact.contacts()[pos].name))
.setNegativeButton(cxt.getText(R.string.delete), dialogClickListener) .setNegativeButton(cxt.getText(R.string.delete), dialogClickListener)
.setPositiveButton(cxt.getText(R.string.cancel), dialogClickListener) .setPositiveButton(cxt.getText(R.string.cancel), dialogClickListener)
.show() .show()
@@ -30,9 +30,8 @@ class ContactsActivity : AppCompatActivity() {
val plusButton = findViewById(R.id.plusButton) as ImageButton val plusButton = findViewById(R.id.plusButton) as ImageButton
plusButton.setOnClickListener { plusButton.setOnClickListener {
if (Contact.contacts().size >= Contact.CONTACTS_SIZE) { if (Contact.contacts().size >= Contact.CONTACTS_SIZE) {
Utils.alertView(this, "Notice", Utils.alertView(this, getString(R.string.notice),
"Your maximum number of contacts " + String.format(getString(R.string.contacts_exceeded), Contact.CONTACTS_SIZE))
"(${Contact.CONTACTS_SIZE}) has been exceeded.")
} else { } else {
val i = Intent(this, ContactActivity::class.java) val i = Intent(this, ContactActivity::class.java)
val b = Bundle() val b = Bundle()
@@ -58,12 +57,10 @@ class ContactsActivity : AppCompatActivity() {
when (item.itemId) { when (item.itemId) {
R.id.export_contacts -> { R.id.export_contacts -> {
if (saveContacts(dir)) if (saveContacts(dir))
Utils.alertView(this,"", Utils.alertView(this,"", getString(R.string.exported_contacts))
"Exported contacts to Download folder as 'contacts.bs'.")
else else
Utils.alertView(this,"Error", Utils.alertView(this,getString(R.string.error),
"Failed to export contacts to Download folder. " + getString(R.string.export_error))
"Check Apps -> baresip -> Permissions -> Storage.")
} }
R.id.import_contacts -> { R.id.import_contacts -> {
if (restoreContacts(dir)) { if (restoreContacts(dir)) {
@@ -72,10 +69,8 @@ class ContactsActivity : AppCompatActivity() {
clAdapter.notifyDataSetChanged() clAdapter.notifyDataSetChanged()
saveContacts(applicationContext.filesDir) saveContacts(applicationContext.filesDir)
} else } else
Utils.alertView(this,"Error", Utils.alertView(this,getString(R.string.error),
"Failed to import contacts from Download folder. " + getString(R.string.import_error))
"Check Apps -> baresip -> Permissions -> Storage and that " +
"the file exists in the folder.")
} }
android.R.id.home -> { android.R.id.home -> {
Log.d("Baresip", "Back array was pressed at Contacts") Log.d("Baresip", "Back array was pressed at Contacts")
@@ -703,7 +703,8 @@ class MainActivity : AppCompatActivity() {
} }
val verifyDialog = AlertDialog.Builder(this@MainActivity) val verifyDialog = AlertDialog.Builder(this@MainActivity)
verifyDialog.setTitle(getString(R.string.verify)) verifyDialog.setTitle(getString(R.string.verify))
verifyDialog.setMessage("${getString(R.string.verify_sas)} <${ev[1]}> <${ev[2]}>?") verifyDialog.setMessage(String.format(getString(R.string.verify_sas),
ev[1], ev[2]))
verifyDialog.setPositiveButton(getString(R.string.yes)) { dialog, _ -> verifyDialog.setPositiveButton(getString(R.string.yes)) { dialog, _ ->
val security: Int val security: Int
if (Api.cmd_exec("zrtp_verify ${ev[3]}") != 0) { if (Api.cmd_exec("zrtp_verify ${ev[3]}") != 0) {
@@ -760,7 +761,8 @@ class MainActivity : AppCompatActivity() {
val transferDialog = AlertDialog.Builder(this) val transferDialog = AlertDialog.Builder(this)
val target = Utils.friendlyUri(ContactsActivity.contactName(ev[1]), val target = Utils.friendlyUri(ContactsActivity.contactName(ev[1]),
Utils.aorDomain(aor)) Utils.aorDomain(aor))
transferDialog.setMessage("${getString(R.string.transfer_query)} $target?") transferDialog.setMessage(String.format(getString(R.string.transfer_query),
target))
transferDialog.setPositiveButton(getString(R.string.yes)) { dialog, _ -> transferDialog.setPositiveButton(getString(R.string.yes)) { dialog, _ ->
if (call in Call.calls()) if (call in Call.calls())
Api.ua_hangup(uap, callp, 0, "") Api.ua_hangup(uap, callp, 0, "")
+42 -17
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">baresip</string> <string name="app_name" translatable="false">baresip</string>
<!-- About Activity --> <!-- About Activity -->
<string name="about_title">About baresip</string> <string name="about_title">About baresip</string>
@@ -78,10 +78,25 @@
<!-- Accounts Activity --> <!-- Accounts Activity -->
<string name="accounts">Accounts</string> <string name="accounts">Accounts</string>
<string name="sip_uri_user_domain">SIP URI user@domain</string> <string name="sip_uri_user_domain">SIP Address user@domain</string>
<string name="invalid_aor">Invalid SIP Addess \'%1$s\'.</string>
<string name="account_exists">Account \'%1$s\' already exists.</string>
<string name="account_allocation_failure">"Failed to allocate new account.</string>
<string name="encrypt_password">Encrypt Password</string>
<string name="decrypt_password">Decrypt Password</string>
<string name="export_accounts">Export</string> <string name="export_accounts">Export</string>
<string name="exported_accounts">Exported accounts to Download folder file \'accounts.bs\'.</string>
<string name="export_accounts_error">"Failed to export accounts to Download folder.
Check Apps -> baresip -> Permissions -> Storage."
</string>
<string name="import_accounts">Import</string> <string name="import_accounts">Import</string>
<string name="delete_account">Do you want to delete account</string> <string name="imported_accounts">Imported accounts from Download folder. You need to restart
baresip.</string>
<string name="import_accounts_error">Failed to import accounts from Download folder file.
Check Apps -> baresip -> Permissions -> Storage and that file \'contacts.bs\' exists in
the folder and, if so, you gave correct Decrypt Password."
</string>
<string name="delete_account">Do you want to delete account \'%1$s\'?</string>
<!-- Baresip Service --> <!-- Baresip Service -->
<string name="answer">Answer</string> <string name="answer">Answer</string>
@@ -95,9 +110,9 @@
<!-- Chat Activity --> <!-- Chat Activity -->
<string name="chat">Chat Messages</string> <string name="chat">Chat Messages</string>
<string name="chat_with">Chat with</string> <string name="chat_with">Chat with %1$s</string>
<string name="new_message">New message</string> <string name="new_message">New message</string>
<string name="long_message_question">Do you want to delete message or add peer %1$s to contacts?</string> <string name="long_message_question">Do you want to delete message or add peer \'%1$s\' to contacts?</string>
<string name="short_message_question">Do you want to delete message?</string> <string name="short_message_question">Do you want to delete message?</string>
<string name="add_contact">Add Contact</string> <string name="add_contact">Add Contact</string>
<string name="message_failed">Sending of message failed</string> <string name="message_failed">Sending of message failed</string>
@@ -105,9 +120,9 @@
<!-- Chats Activity --> <!-- Chats Activity -->
<string name="chats">Chat History</string> <string name="chats">Chat History</string>
<string name="new_chat_peer">New Chat Peer</string> <string name="new_chat_peer">New Chat Peer</string>
<string name="long_chat_question">Do you want to delete chat with peer %1$s or <string name="long_chat_question">Do you want to delete chat with peer \'%1$s\' or
add peer to contacts?</string> add peer to contacts?</string>
<string name="short_chat_question">Do you want to delete chat with</string> <string name="short_chat_question">Do you want to delete chat with \'%1$s\'?</string>
<!-- Config Activity --> <!-- Config Activity -->
<string name="configuration">Configuration</string> <string name="configuration">Configuration</string>
@@ -120,7 +135,7 @@
available addresses. If left empty (factory default), baresip listens at port 5060 of available addresses. If left empty (factory default), baresip listens at port 5060 of
all available addresses. all available addresses.
</string> </string>
<string name="_0_0_0_0_5060">0.0.0.0:5060</string> <string name="_0_0_0_0_5060" translatable="false">0.0.0.0:5060</string>
<string name="prefer_ipv6">Prefer IPv6</string> <string name="prefer_ipv6">Prefer IPv6</string>
<string name="prefer_ipv6_help">Prefer IPv6 if both IPv4 and IPv6 are available.</string> <string name="prefer_ipv6_help">Prefer IPv6 if both IPv4 and IPv6 are available.</string>
<string name="dns_servers">DNS Servers</string> <string name="dns_servers">DNS Servers</string>
@@ -128,11 +143,11 @@
\'server:port\'. If server is an IPv6 address, the address must be written inside brackets []. \'server:port\'. If server is an IPv6 address, the address must be written inside brackets [].
Factory default value is \'8.8.8.8:53,[2001:4860:4860::8888]:53\' pointing to public Google Factory default value is \'8.8.8.8:53,[2001:4860:4860::8888]:53\' pointing to public Google
DNS servers.</string> DNS servers.</string>
<string name="_8_8_8_8_53">8.8.8.8:53</string> <string name="_8_8_8_8_53" translatable="false">8.8.8.8:53</string>
<string name="opus_bit_rate">Opus Bit Rate</string> <string name="opus_bit_rate">Opus Bit Rate</string>
<string name="opus_bit_rate_help">Average maximum bit rate used by Opus audio stream. <string name="opus_bit_rate_help">Average maximum bit rate used by Opus audio stream.
Valid value are 6000-510000. Factory default is 28000.</string> Valid value are 6000-510000. Factory default is 28000.</string>
<string name="_28000">28000</string> <string name="_28000" translatable="false">28000</string>
<string name="ice_lite_mode">ICE Lite Mode</string> <string name="ice_lite_mode">ICE Lite Mode</string>
<string name="ice_lite_mode_help">If checked, ICE Lite Mode is used.</string> <string name="ice_lite_mode_help">If checked, ICE Lite Mode is used.</string>
<string name="default_call_volume">Default Call Volume</string> <string name="default_call_volume">Default Call Volume</string>
@@ -150,9 +165,18 @@
<!-- Contacts Activity --> <!-- Contacts Activity -->
<string name="contacts">Contacts</string> <string name="contacts">Contacts</string>
<string name="contact_action_question">Do you want to call or send message to</string> <string name="contact_action_question">Do you want to call or send message to \'%1$s\'?</string>
<string name="send_message">Send Message</string> <string name="send_message">Send Message</string>
<string name="contact_delete_question">Do you want to delete contact</string> <string name="contact_delete_question">Do you want to delete contact \'%1$s\'?</string>
<string name="contacts_exceeded">Your maximum number of contacts %1%d has been exceeded.</string>
<string name="exported_contacts">Exported contacts to Download folder file \'contacts.bs\'.</string>
<string name="export_error">"Failed to export contacts to Download folder.
Check Apps -> baresip -> Permissions -> Storage."
</string>
<string name="imported_contacts">Imported contacts from Download folder.</string>
<string name="import_error">Failed to import contacts from Download folder. Check Apps ->
baresip -> Permissions -> Storage and that file \'contacts.bs\' exists in the folder.
</string>
<!-- Generic --> <!-- Generic -->
<string name="alert">Alert</string> <string name="alert">Alert</string>
@@ -167,13 +191,14 @@
<string name="deny">Deny</string> <string name="deny">Deny</string>
<string name="user_id">User ID</string> <string name="user_id">User ID</string>
<string name="password">Password</string> <string name="password">Password</string>
<string name="sip_uri">SIP URI</string> <string name="sip_uri" translatable="false">SIP URI</string>
<string name="add">Add</string> <string name="add">Add</string>
<string name="delete">Delete</string> <string name="delete">Delete</string>
<string name="edit">Edit</string> <string name="edit">Edit</string>
<string name="send">Send</string> <string name="send">Send</string>
<string name="status">Status</string> <string name="status">Status</string>
<string name="dots">&#8230;</string> <string name="error">Error</string>
<string name="dots" translatable="false">&#8230;</string>
<!-- Main Activity --> <!-- Main Activity -->
<string name="about">About</string> <string name="about">About</string>
@@ -198,11 +223,11 @@
<string name="call_already_active">You already have an active call!</string> <string name="call_already_active">You already have an active call!</string>
<string name="start_failed">Baresip failed to start! Listen Address was reset. <string name="start_failed">Baresip failed to start! Listen Address was reset.
Restart baresip.</string> Restart baresip.</string>
<string name="registering_failed">Registering of %1$s failed</string> <string name="registering_failed">Registering of \`%1$s\` failed.</string>
<string name="no_microphone_permission">You have not granted microphone permission.</string> <string name="no_microphone_permission">You have not granted microphone permission.</string>
<string name="verify">Verify</string> <string name="verify">Verify</string>
<string name="verify_sas">Do you want to verify SAS</string> <string name="verify_sas">Do you want to verify SAS &lt;%1$s&gt; &lt;%2$s&gt;?</string>
<string name="transfer_query">Do you accept to transfer call to</string> <string name="transfer_query">Do you accept to transfer call to \'%1$s\'?</string>
<string name="call_failed">Call failed</string> <string name="call_failed">Call failed</string>
<string name="call_closed">Call closed</string> <string name="call_closed">Call closed</string>
<string name="restart_needed">You need to restart baresip in order to activate the new config!</string> <string name="restart_needed">You need to restart baresip in order to activate the new config!</string>