- If contact's name is empty, use contact's SIP URI as contact's name.
- Relaxed checking of contact's name.
This commit is contained in:
@ -71,7 +71,11 @@ class ContactActivity : AppCompatActivity() {
|
||||
|
||||
R.id.checkIcon -> {
|
||||
|
||||
val newName = nameView.text.toString().trim()
|
||||
var newName = nameView.text.toString().trim()
|
||||
var newUri = uriView.text.toString().trim()
|
||||
|
||||
if (newName == "") newName = newUri
|
||||
|
||||
if (!Utils.checkName(newName)) {
|
||||
Utils.alertView(this, getString(R.string.error),
|
||||
String.format(getString(R.string.invalid_contact), newName))
|
||||
@ -89,7 +93,6 @@ class ContactActivity : AppCompatActivity() {
|
||||
return false
|
||||
}
|
||||
|
||||
var newUri = uriView.text.toString().trim()
|
||||
if (!newUri.startsWith("sip:")) {
|
||||
if (newUri.contains("@") || (BaresipService.uas.size != 1)) {
|
||||
newUri = "sip:$newUri"
|
||||
|
||||
@ -214,11 +214,8 @@ object Utils {
|
||||
}
|
||||
|
||||
fun checkName(name: String): Boolean {
|
||||
if (name.length < 2) return false
|
||||
for (c in name) {
|
||||
if (!c.isLetterOrDigit() && !(c in "-.!%*_+`'~ ")) return false
|
||||
}
|
||||
return true
|
||||
return name.isNotEmpty() && name == String(name.toByteArray(), Charsets.UTF_8) &&
|
||||
name.lines().size == 1
|
||||
}
|
||||
|
||||
fun checkIfName(name: String): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user