mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 02:58:45 +00:00
Display existing group members in alphabetical order on add to groups screen.
This commit is contained in:
@@ -576,14 +576,19 @@ open class ContactSearchAdapter(
|
||||
if (getRecipient(model).isGroup) {
|
||||
number.text = getRecipient(model).participantIds
|
||||
.take(10)
|
||||
.map { id -> Recipient.resolved(id) }
|
||||
.sortedWith(IsSelfComparator()).joinToString(", ") {
|
||||
if (it.isSelf) {
|
||||
context.getString(R.string.ConversationTitleView_you)
|
||||
} else {
|
||||
it.getShortDisplayName(context)
|
||||
}
|
||||
.map { id ->
|
||||
val recipient = Recipient.resolved(id)
|
||||
RecipientDisplayName(
|
||||
recipient = recipient,
|
||||
displayName = if (recipient.isSelf) {
|
||||
context.getString(R.string.ConversationTitleView_you)
|
||||
} else {
|
||||
recipient.getShortDisplayName(context)
|
||||
}
|
||||
)
|
||||
}
|
||||
.sortedWith(compareBy({ it.recipient.isSelf }, { it.displayName }))
|
||||
.joinToString(", ") { it.displayName }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,21 +766,6 @@ open class ContactSearchAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
private class IsSelfComparator : Comparator<Recipient> {
|
||||
override fun compare(lhs: Recipient?, rhs: Recipient?): Int {
|
||||
val isLeftSelf = lhs?.isSelf == true
|
||||
val isRightSelf = rhs?.isSelf == true
|
||||
|
||||
return if (isLeftSelf == isRightSelf) {
|
||||
0
|
||||
} else if (isLeftSelf) {
|
||||
1
|
||||
} else {
|
||||
-1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface StoryContextMenuCallbacks {
|
||||
fun onOpenStorySettings(story: ContactSearchData.Story)
|
||||
fun onRemoveGroupStory(story: ContactSearchData.Story, isSelected: Boolean)
|
||||
@@ -813,6 +803,7 @@ open class ContactSearchAdapter(
|
||||
fun onUnknownRecipientClicked(view: View, unknownRecipient: ContactSearchData.UnknownRecipient, isSelected: Boolean) {
|
||||
throw NotImplementedError()
|
||||
}
|
||||
|
||||
fun onChatTypeClicked(view: View, chatTypeRow: ContactSearchData.ChatTypeRow, isSelected: Boolean)
|
||||
}
|
||||
|
||||
@@ -834,3 +825,5 @@ open class ContactSearchAdapter(
|
||||
override fun onKnownRecipientLongClick(view: View, data: ContactSearchData.KnownRecipient): Boolean = false
|
||||
}
|
||||
}
|
||||
|
||||
private data class RecipientDisplayName(val recipient: Recipient, val displayName: String)
|
||||
|
||||
Reference in New Issue
Block a user