In contact search, ignore diacritic characters
This commit is contained in:
@@ -240,11 +240,12 @@ private fun ContactsContent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val filteredContacts = remember(BaresipService.contacts, searchQuery) {
|
val filteredContacts = remember(BaresipService.contacts, searchQuery) {
|
||||||
if (searchQuery.isBlank()) {
|
if (searchQuery.isBlank())
|
||||||
BaresipService.contacts
|
BaresipService.contacts
|
||||||
} else {
|
else {
|
||||||
|
val normalizedQuery = Utils.unaccent(searchQuery)
|
||||||
BaresipService.contacts.filter { contact ->
|
BaresipService.contacts.filter { contact ->
|
||||||
contact.name().contains(searchQuery, ignoreCase = true)
|
Utils.unaccent(contact.name()).contains(normalizedQuery, ignoreCase = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1357,6 +1357,7 @@ private fun CallUriRow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun CallTimer(
|
private fun CallTimer(
|
||||||
initialDurationSeconds: Long,
|
initialDurationSeconds: Long,
|
||||||
|
|||||||
@@ -419,6 +419,11 @@ object Utils {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun unaccent(input: String): String {
|
||||||
|
val normalized = java.text.Normalizer.normalize(input, java.text.Normalizer.Form.NFD)
|
||||||
|
return "\\p{InCombiningDiacriticalMarks}+".toRegex().replace(normalized, "")
|
||||||
|
}
|
||||||
|
|
||||||
fun isVisible(): Boolean {
|
fun isVisible(): Boolean {
|
||||||
return ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)
|
return ProcessLifecycleOwner.get().lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user