Sort all contact names and keep them in up to date list
This commit is contained in:
@@ -187,6 +187,7 @@ class AndroidContactsActivity : AppCompatActivity() {
|
|||||||
for ((_, value) in contacts)
|
for ((_, value) in contacts)
|
||||||
if (value.name != "")
|
if (value.name != "")
|
||||||
BaresipService.androidContacts.add(value)
|
BaresipService.androidContacts.add(value)
|
||||||
|
Utils.reloadContactNames()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1440,6 +1440,7 @@ class BaresipService: Service() {
|
|||||||
val registrationUpdate = MutableLiveData<Long>()
|
val registrationUpdate = MutableLiveData<Long>()
|
||||||
val contacts = ArrayList<Contact>()
|
val contacts = ArrayList<Contact>()
|
||||||
val androidContacts = ArrayList<AndroidContact>()
|
val androidContacts = ArrayList<AndroidContact>()
|
||||||
|
val contactNames = mutableListOf<String>()
|
||||||
val chatTexts: MutableMap<String, String> = mutableMapOf()
|
val chatTexts: MutableMap<String, String> = mutableMapOf()
|
||||||
val activities = mutableListOf<String>()
|
val activities = mutableListOf<String>()
|
||||||
var dnsServers = listOf<InetAddress>()
|
var dnsServers = listOf<InetAddress>()
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ class Contact(var name: String, var uri: String, var color: Int, val id: Long) {
|
|||||||
BaresipService.contacts.add(contact)
|
BaresipService.contacts.add(contact)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Utils.reloadContactNames()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -328,9 +328,15 @@ object Utils {
|
|||||||
return ContactsActivity.contactUri(name) ?: AndroidContactsActivity.contactUri(name)
|
return ContactsActivity.contactUri(name) ?: AndroidContactsActivity.contactUri(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun reloadContactNames() {
|
||||||
|
BaresipService.contactNames.clear()
|
||||||
|
BaresipService.contactNames.addAll(Contact.contacts().map{Contact -> Contact.name})
|
||||||
|
BaresipService.contactNames.addAll(AndroidContact.contacts().map{AndroidContact -> AndroidContact.name})
|
||||||
|
BaresipService.contactNames.sort()
|
||||||
|
}
|
||||||
|
|
||||||
fun contactNames() : List<String> {
|
fun contactNames() : List<String> {
|
||||||
return Contact.contacts().map{Contact -> Contact.name} +
|
return BaresipService.contactNames
|
||||||
AndroidContact.contacts().map{AndroidContact -> AndroidContact.name}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setAvatar(ctx: Context, imageView: ImageView, textView: TextView, uri: String) {
|
fun setAvatar(ctx: Context, imageView: ImageView, textView: TextView, uri: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user