fix: don't limit search to 32bit ints (#592)

* fix: don't limit search to 32bit ints

This is a quick fix. Will do a proper rewrite later.

Refs: https://github.com/FossifyOrg/General-Discussion/issues/718

* docs: update changelog
This commit is contained in:
Naveen Singh
2025-09-29 17:30:27 +05:30
committed by GitHub
parent 72db893979
commit 46db447e00
4 changed files with 7 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Fixed wrong contact photo in call history for some contacts ([#585])
- Fixed search not matching full phone numbers
## [1.7.1] - 2025-09-12
### Changed

View File

@@ -162,7 +162,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
val filtered = allContacts.filter { contact ->
getProperText(contact.getNameToDisplay(), shouldNormalize).contains(fixedText, true) ||
getProperText(contact.nickname, shouldNormalize).contains(fixedText, true) ||
(fixedText.toIntOrNull() != null && contact.doesContainPhoneNumber(fixedText, true)) ||
(fixedText.toLongOrNull() != null && contact.doesContainPhoneNumber(fixedText, true)) ||
contact.emails.any { it.value.contains(fixedText, true) } ||
contact.addresses.any { getProperText(it.value, shouldNormalize).contains(fixedText, true) } ||
contact.IMs.any { it.value.contains(fixedText, true) } ||

View File

@@ -199,7 +199,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
override fun onSearchQueryChanged(text: String) {
val fixedText = text.trim().replace("\\s+".toRegex(), " ")
val contacts = allContacts.filter {
it.name.contains(fixedText, true) || (text.toIntOrNull() != null && it.doesContainPhoneNumber(fixedText))
it.name.contains(fixedText, true) || (text.toLongOrNull() != null && it.doesContainPhoneNumber(fixedText))
}.sortedByDescending {
it.name.startsWith(fixedText, true)
}.toMutableList() as ArrayList<Contact>

View File

@@ -27,12 +27,12 @@ data class RecentCall(
val dayCode = startTS.getDayCode()
fun doesContainPhoneNumber(text: String): Boolean {
return if (text.toIntOrNull() != null) {
return if (text.toLongOrNull() != null) {
val normalizedText = text.normalizePhoneNumber()
PhoneNumberUtils.compare(phoneNumber.normalizePhoneNumber(), normalizedText) ||
phoneNumber.contains(text) ||
phoneNumber.normalizePhoneNumber().contains(normalizedText) ||
phoneNumber.contains(normalizedText)
phoneNumber.contains(text) ||
phoneNumber.normalizePhoneNumber().contains(normalizedText) ||
phoneNumber.contains(normalizedText)
} else {
false
}