Contact selection list now contains only those Android contacts that have

exactly one URI
This commit is contained in:
Juha Heinanen
2022-02-21 11:30:25 +02:00
parent 8e8bb09c57
commit 664d857a5d
2 changed files with 18 additions and 17 deletions

View File

@ -62,12 +62,10 @@ sealed class Contact {
}
is AndroidContact -> {
if (c.name == name) {
if (c.uris.isNotEmpty()) {
for (u in c.uris)
if (u.startsWith("sip:"))
return u
return c.uris.first()
}
return if (c.uris.isNotEmpty())
c.uris.first()
else
null
}
}
}
@ -149,7 +147,7 @@ sealed class Contact {
}
cur?.close()
for ((_, value) in contacts)
if (value.name != "")
if (value.name != "" && value.uris.isNotEmpty())
BaresipService.androidContacts.add(value)
}
@ -208,6 +206,18 @@ sealed class Contact {
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() {
BaresipService.contacts.sortBy{ when (it) {
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
}})
}
}
}

View File

@ -173,7 +173,7 @@ class ContactListAdapter(private val ctx: Context, private val rows: ArrayList<C
}
}
Contact.contacts().removeAt(position)
Contact.contactNames().removeAt(position)
Contact.generateContactNames()
Contact.saveBaresipContacts()
this.notifyDataSetChanged()
}