fix #91, try sorting search results smarter

This commit is contained in:
tibbi 2021-05-23 10:20:07 +02:00
parent 5c89288f6b
commit 30c178e803
3 changed files with 6 additions and 0 deletions

View File

@ -137,6 +137,8 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
it.name.contains(text, true) ||
it.name.normalizeString().contains(text, true) ||
it.name.contains(text.normalizeString(), true)
}.sortedByDescending {
it.name.startsWith(text, true)
}.toMutableList() as ArrayList<SimpleContact>
fragment_placeholder.beVisibleIf(contacts.isEmpty())

View File

@ -115,6 +115,8 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
override fun onSearchQueryChanged(text: String) {
val contacts = allContacts.filter {
it.name.contains(text, true) || it.doesContainPhoneNumber(text)
}.sortedByDescending {
it.name.startsWith(text, true)
}.toMutableList() as ArrayList<SimpleContact>
fragment_placeholder.beVisibleIf(contacts.isEmpty())

View File

@ -124,6 +124,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
override fun onSearchQueryChanged(text: String) {
val recentCalls = allRecentCalls.filter {
it.name.contains(text, true) || it.doesContainPhoneNumber(text)
}.sortedByDescending {
it.name.startsWith(text, true)
}.toMutableList() as ArrayList<RecentCall>
recents_placeholder.beVisibleIf(recentCalls.isEmpty())