- 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 -> {
|
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)) {
|
if (!Utils.checkName(newName)) {
|
||||||
Utils.alertView(this, getString(R.string.error),
|
Utils.alertView(this, getString(R.string.error),
|
||||||
String.format(getString(R.string.invalid_contact), newName))
|
String.format(getString(R.string.invalid_contact), newName))
|
||||||
@@ -89,7 +93,6 @@ class ContactActivity : AppCompatActivity() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var newUri = uriView.text.toString().trim()
|
|
||||||
if (!newUri.startsWith("sip:")) {
|
if (!newUri.startsWith("sip:")) {
|
||||||
if (newUri.contains("@") || (BaresipService.uas.size != 1)) {
|
if (newUri.contains("@") || (BaresipService.uas.size != 1)) {
|
||||||
newUri = "sip:$newUri"
|
newUri = "sip:$newUri"
|
||||||
|
|||||||
@@ -214,11 +214,8 @@ object Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun checkName(name: String): Boolean {
|
fun checkName(name: String): Boolean {
|
||||||
if (name.length < 2) return false
|
return name.isNotEmpty() && name == String(name.toByteArray(), Charsets.UTF_8) &&
|
||||||
for (c in name) {
|
name.lines().size == 1
|
||||||
if (!c.isLetterOrDigit() && !(c in "-.!%*_+`'~ ")) return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkIfName(name: String): Boolean {
|
fun checkIfName(name: String): Boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user