fix: properly highlight search results with accents and diacritics (#435)

Refs: https://github.com/FossifyOrg/Contacts/issues/12
This commit is contained in:
Jan
2025-12-14 14:26:22 +01:00
committed by GitHub
parent 0f30e9f6da
commit 2274085fc3
2 changed files with 5 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- Fixed invisible navigation bars in contact viewer ([#415])
- Fixed search highlighting for characters with accents and diacritics ([#12])
## [1.4.0] - 2025-10-29
### Changed
@@ -98,6 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial release
[#12]: https://github.com/FossifyOrg/Contacts/issues/12
[#30]: https://github.com/FossifyOrg/Contacts/issues/30
[#78]: https://github.com/FossifyOrg/Contacts/issues/78
[#201]: https://github.com/FossifyOrg/Contacts/issues/201

View File

@@ -391,7 +391,9 @@ class ContactsAdapter(
findViewById<ConstraintLayout>(org.fossify.commons.R.id.item_contact_frame)?.isSelected = selectedKeys.contains(contact.id)
val fullName = contact.getNameToDisplay()
findViewById<TextView>(org.fossify.commons.R.id.item_contact_name).text = if (textToHighlight.isEmpty()) fullName else {
if (fullName.contains(textToHighlight, true)) {
val normalizedFullName = fullName.normalizeString()
val normalizedSearchText = textToHighlight.normalizeString()
if (normalizedFullName.contains(normalizedSearchText, true)) {
fullName.highlightTextPart(textToHighlight, properPrimaryColor)
} else {
fullName.highlightTextFromNumbers(textToHighlight, properPrimaryColor)