mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-04-23 22:17:22 +02:00
convert letters to numbers at search only if we show letters at dialpad
This commit is contained in:
parent
ad3f5b6725
commit
4071ecbf16
@ -169,10 +169,10 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
(dialpad_list.adapter as? ContactsAdapter)?.finishActMode()
|
(dialpad_list.adapter as? ContactsAdapter)?.finishActMode()
|
||||||
val filtered = contacts.filter {
|
val filtered = contacts.filter {
|
||||||
val convertedName = PhoneNumberUtils.convertKeypadLettersToDigits(it.getNameToDisplay())
|
val convertedName = PhoneNumberUtils.convertKeypadLettersToDigits(it.getNameToDisplay())
|
||||||
it.doesContainPhoneNumber(text) || (showLetters && convertedName.contains(text, true))
|
it.doesContainPhoneNumber(text, showLetters) || (showLetters && convertedName.contains(text, true))
|
||||||
}.sortedWith(compareBy {
|
}.sortedWith(compareBy {
|
||||||
if (showLetters) {
|
if (showLetters) {
|
||||||
!it.doesContainPhoneNumber(text)
|
!it.doesContainPhoneNumber(text, showLetters)
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -228,11 +228,12 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
|
|
||||||
fun onSearchQueryChanged(text: String) {
|
fun onSearchQueryChanged(text: String) {
|
||||||
val shouldNormalize = text.normalizeString() == text
|
val shouldNormalize = text.normalizeString() == text
|
||||||
|
val convertLetters = config.showDialpadLetters
|
||||||
(fragment_list.adapter as? ContactsAdapter)?.apply {
|
(fragment_list.adapter as? ContactsAdapter)?.apply {
|
||||||
val filtered = contactsIgnoringSearch.filter {
|
val filtered = contactsIgnoringSearch.filter {
|
||||||
getProperText(it.getNameToDisplay(), shouldNormalize).contains(text, true) ||
|
getProperText(it.getNameToDisplay(), shouldNormalize).contains(text, true) ||
|
||||||
getProperText(it.nickname, shouldNormalize).contains(text, true) ||
|
getProperText(it.nickname, shouldNormalize).contains(text, true) ||
|
||||||
it.doesContainPhoneNumber(text) ||
|
it.doesContainPhoneNumber(text, convertLetters) ||
|
||||||
it.emails.any { it.value.contains(text, true) } ||
|
it.emails.any { it.value.contains(text, true) } ||
|
||||||
it.addresses.any { getProperText(it.value, shouldNormalize).contains(text, true) } ||
|
it.addresses.any { getProperText(it.value, shouldNormalize).contains(text, true) } ||
|
||||||
it.IMs.any { it.value.contains(text, true) } ||
|
it.IMs.any { it.value.contains(text, true) } ||
|
||||||
|
@ -127,9 +127,9 @@ data class Contact(var id: Int, var prefix: String, var firstName: String, var m
|
|||||||
|
|
||||||
fun isABusinessContact() = prefix.isEmpty() && firstName.isEmpty() && middleName.isEmpty() && surname.isEmpty() && suffix.isEmpty() && organization.isNotEmpty()
|
fun isABusinessContact() = prefix.isEmpty() && firstName.isEmpty() && middleName.isEmpty() && surname.isEmpty() && suffix.isEmpty() && organization.isNotEmpty()
|
||||||
|
|
||||||
fun doesContainPhoneNumber(text: String): Boolean {
|
fun doesContainPhoneNumber(text: String, convertLetters: Boolean): Boolean {
|
||||||
return if (text.isNotEmpty()) {
|
return if (text.isNotEmpty()) {
|
||||||
val normalizedText = text.normalizeNumber()
|
val normalizedText = if (convertLetters) text.normalizeNumber() else text
|
||||||
phoneNumbers.any {
|
phoneNumbers.any {
|
||||||
PhoneNumberUtils.compare(it.normalizedNumber, normalizedText) ||
|
PhoneNumberUtils.compare(it.normalizedNumber, normalizedText) ||
|
||||||
it.value.contains(text) ||
|
it.value.contains(text) ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user