Synched contacts handling
This commit is contained in:
@@ -89,51 +89,57 @@ sealed class Contact {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return URIs of contact name
|
|
||||||
fun contactUris(name: String, tel: Boolean = false): ArrayList<String> {
|
fun contactUris(name: String, tel: Boolean = false): ArrayList<String> {
|
||||||
val uris = ArrayList<String>()
|
val uris = ArrayList<String>()
|
||||||
for (c in BaresipService.contacts)
|
synchronized(BaresipService.contacts) {
|
||||||
when (c) {
|
for (c in BaresipService.contacts)
|
||||||
is BaresipContact -> {
|
when (c) {
|
||||||
if (c.name.equals(name, ignoreCase = true)) {
|
is BaresipContact -> {
|
||||||
for (u in c.uris) {
|
if (c.name.equals(name, ignoreCase = true)) {
|
||||||
if (tel && !u.startsWith("tel:"))
|
for (u in c.uris) {
|
||||||
continue
|
if (tel && !u.startsWith("tel:"))
|
||||||
uris.add(u)
|
continue
|
||||||
|
uris.add(u)
|
||||||
|
}
|
||||||
|
return uris
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is AndroidContact -> {
|
||||||
|
if (c.name == name) {
|
||||||
|
for (u in c.uris) {
|
||||||
|
if (tel && !u.startsWith("tel:"))
|
||||||
|
continue
|
||||||
|
uris.add(u)
|
||||||
|
}
|
||||||
|
return uris
|
||||||
}
|
}
|
||||||
return uris
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is AndroidContact -> {
|
}
|
||||||
if (c.name == name) {
|
|
||||||
for (u in c.uris) {
|
|
||||||
if (tel && !u.startsWith("tel:"))
|
|
||||||
continue
|
|
||||||
uris.add(u)
|
|
||||||
}
|
|
||||||
return uris
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return uris
|
return uris
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findContact(uri: String): Contact? {
|
fun findContact(uri: String): Contact? {
|
||||||
for (c in BaresipService.contacts)
|
synchronized(BaresipService.contacts) {
|
||||||
when (c) {
|
for (c in BaresipService.contacts)
|
||||||
is BaresipContact -> {
|
when (c) {
|
||||||
for (u in c.uris)
|
is BaresipContact -> {
|
||||||
if (Utils.uriMatch(u, uri))
|
for (u in c.uris)
|
||||||
return c
|
if (Utils.uriMatch(u, uri))
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
is AndroidContact -> {
|
||||||
|
val cleanUri = uri.filterNot { setOf('-', ' ', '(', ')').contains(it) }
|
||||||
|
for (u in c.uris)
|
||||||
|
if (Utils.uriMatch(
|
||||||
|
u.filterNot { setOf('-', ' ', '(', ')').contains(it) },
|
||||||
|
cleanUri
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return c
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is AndroidContact -> {
|
}
|
||||||
val cleanUri = uri.filterNot{setOf('-', ' ', '(', ')').contains(it)}
|
|
||||||
for (u in c.uris)
|
|
||||||
if (Utils.uriMatch(u.filterNot{setOf('-', ' ', '(', ')').contains(it)},
|
|
||||||
cleanUri))
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user