Contact selection list now contains only those Android contacts that have
exactly one URI
This commit is contained in:
@@ -62,12 +62,10 @@ sealed class Contact {
|
|||||||
}
|
}
|
||||||
is AndroidContact -> {
|
is AndroidContact -> {
|
||||||
if (c.name == name) {
|
if (c.name == name) {
|
||||||
if (c.uris.isNotEmpty()) {
|
return if (c.uris.isNotEmpty())
|
||||||
for (u in c.uris)
|
c.uris.first()
|
||||||
if (u.startsWith("sip:"))
|
else
|
||||||
return u
|
null
|
||||||
return c.uris.first()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +147,7 @@ sealed class Contact {
|
|||||||
}
|
}
|
||||||
cur?.close()
|
cur?.close()
|
||||||
for ((_, value) in contacts)
|
for ((_, value) in contacts)
|
||||||
if (value.name != "")
|
if (value.name != "" && value.uris.isNotEmpty())
|
||||||
BaresipService.androidContacts.add(value)
|
BaresipService.androidContacts.add(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,6 +206,18 @@ sealed class Contact {
|
|||||||
BaresipService.contactUpdate.postValue(System.nanoTime())
|
BaresipService.contactUpdate.postValue(System.nanoTime())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun generateContactNames () {
|
||||||
|
BaresipService.contactNames.clear()
|
||||||
|
for (c in BaresipService.contacts)
|
||||||
|
when (c) {
|
||||||
|
is BaresipContact ->
|
||||||
|
BaresipService.contactNames.add(c.name)
|
||||||
|
is AndroidContact ->
|
||||||
|
if (c.uris.size == 1)
|
||||||
|
BaresipService.contactNames.add(c.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun sortContacts() {
|
private fun sortContacts() {
|
||||||
BaresipService.contacts.sortBy{ when (it) {
|
BaresipService.contacts.sortBy{ when (it) {
|
||||||
is BaresipContact -> it.name
|
is BaresipContact -> it.name
|
||||||
@@ -215,14 +225,5 @@ sealed class Contact {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateContactNames () {
|
|
||||||
BaresipService.contactNames.clear()
|
|
||||||
BaresipService.contactNames.addAll(
|
|
||||||
BaresipService.contacts.map {
|
|
||||||
when (it) {
|
|
||||||
is BaresipContact -> it.name
|
|
||||||
is AndroidContact -> it.name
|
|
||||||
}})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ class ContactListAdapter(private val ctx: Context, private val rows: ArrayList<C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Contact.contacts().removeAt(position)
|
Contact.contacts().removeAt(position)
|
||||||
Contact.contactNames().removeAt(position)
|
Contact.generateContactNames()
|
||||||
Contact.saveBaresipContacts()
|
Contact.saveBaresipContacts()
|
||||||
this.notifyDataSetChanged()
|
this.notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user