mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Unknown contact should go under #
This commit is contained in:
parent
39f9b959ce
commit
ca66d115a3
@ -291,7 +291,10 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
|||||||
if (result.query.isEmpty()) {
|
if (result.query.isEmpty()) {
|
||||||
class NamedValue<T>(val name: String?, val value: T)
|
class NamedValue<T>(val name: String?, val value: T)
|
||||||
|
|
||||||
val unknown = resources.getString(R.string.unknown)
|
// Unknown is temporarily to be grouped together with numbers title.
|
||||||
|
// https://optf.atlassian.net/browse/SES-2287
|
||||||
|
val numbersTitle = "#"
|
||||||
|
val unknownTitle = numbersTitle
|
||||||
|
|
||||||
listOf(
|
listOf(
|
||||||
GlobalSearchAdapter.Model.Header(R.string.contacts),
|
GlobalSearchAdapter.Model.Header(R.string.contacts),
|
||||||
@ -305,12 +308,12 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
|
|||||||
.let { name -> NamedValue(name?.uppercase(), it) } }
|
.let { name -> NamedValue(name?.uppercase(), it) } }
|
||||||
// Digits are all grouped under a #, the rest are grouped by their first character.uppercased()
|
// Digits are all grouped under a #, the rest are grouped by their first character.uppercased()
|
||||||
// If there is no name, they go under Unknown
|
// If there is no name, they go under Unknown
|
||||||
.groupBy { it.name?.run { first().takeUnless(Char::isDigit)?.toString() ?: "#" } ?: unknown }
|
.groupBy { it.name?.run { first().takeUnless(Char::isDigit)?.toString() ?: numbersTitle } ?: unknownTitle }
|
||||||
// place the # at the end, after all the names starting with alphabetic chars
|
// place the # at the end, after all the names starting with alphabetic chars
|
||||||
.toSortedMap(compareBy {
|
.toSortedMap(compareBy {
|
||||||
when (it) {
|
when (it) {
|
||||||
unknown -> Char.MAX_VALUE
|
unknownTitle -> Char.MAX_VALUE
|
||||||
"#" -> Char.MAX_VALUE - 1
|
numbersTitle -> Char.MAX_VALUE - 1
|
||||||
else -> it.first()
|
else -> it.first()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user