- Allow changing of contact name also when only case of letters differ.
- When restoring contacts, do not require that URI is surrounded by angle brackets.
This commit is contained in:
@ -62,8 +62,13 @@ class ContactActivity : AppCompatActivity() {
|
|||||||
String.format(getString(R.string.invalid_contact), newName))
|
String.format(getString(R.string.invalid_contact), newName))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if ((new || (Contact.contacts()[index].name != newName)) &&
|
var alert = false
|
||||||
ContactsActivity.nameExists(newName)) {
|
if (new)
|
||||||
|
alert = ContactsActivity.nameExists(newName, true)
|
||||||
|
else
|
||||||
|
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.error),
|
||||||
String.format(getString(R.string.contact_already_exists), newName))
|
String.format(getString(R.string.contact_already_exists), newName))
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -109,7 +109,9 @@ class ContactsActivity : AppCompatActivity() {
|
|||||||
val parts = it.split("\"")
|
val parts = it.split("\"")
|
||||||
if (parts.size == 3) {
|
if (parts.size == 3) {
|
||||||
val name = parts[1]
|
val name = parts[1]
|
||||||
val uri = parts[2].trim().substringAfter("<").substringBefore(">")
|
var uri = parts[2].trim()
|
||||||
|
if (uri.startsWith("<"))
|
||||||
|
uri = uri.substringAfter("<").substringBefore(">")
|
||||||
// Currently no need to make baresip aware of the contact
|
// Currently no need to make baresip aware of the contact
|
||||||
// Api.contact_add("\"$name\" $uri")
|
// Api.contact_add("\"$name\" $uri")
|
||||||
Contact.contacts().add(Contact(name, uri))
|
Contact.contacts().add(Contact(name, uri))
|
||||||
@ -127,9 +129,9 @@ class ContactsActivity : AppCompatActivity() {
|
|||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
fun nameExists(name: String): Boolean {
|
fun nameExists(name: String, ignoreCase: Boolean): Boolean {
|
||||||
for (c in Contact.contacts())
|
for (c in Contact.contacts())
|
||||||
if (c.name.equals(name, ignoreCase = true)) return true
|
if (c.name.equals(name, ignoreCase = ignoreCase)) return true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user