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) {
|
if (getRecipient(model).isGroup) {
|
||||||
number.text = getRecipient(model).participantIds
|
number.text = getRecipient(model).participantIds
|
||||||
.take(10)
|
.take(10)
|
||||||
.map { id -> Recipient.resolved(id) }
|
.map { id ->
|
||||||
.sortedWith(IsSelfComparator()).joinToString(", ") {
|
val recipient = Recipient.resolved(id)
|
||||||
if (it.isSelf) {
|
RecipientDisplayName(
|
||||||
context.getString(R.string.ConversationTitleView_you)
|
recipient = recipient,
|
||||||
} else {
|
displayName = if (recipient.isSelf) {
|
||||||
it.getShortDisplayName(context)
|
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 {
|
interface StoryContextMenuCallbacks {
|
||||||
fun onOpenStorySettings(story: ContactSearchData.Story)
|
fun onOpenStorySettings(story: ContactSearchData.Story)
|
||||||
fun onRemoveGroupStory(story: ContactSearchData.Story, isSelected: Boolean)
|
fun onRemoveGroupStory(story: ContactSearchData.Story, isSelected: Boolean)
|
||||||
@@ -813,6 +803,7 @@ open class ContactSearchAdapter(
|
|||||||
fun onUnknownRecipientClicked(view: View, unknownRecipient: ContactSearchData.UnknownRecipient, isSelected: Boolean) {
|
fun onUnknownRecipientClicked(view: View, unknownRecipient: ContactSearchData.UnknownRecipient, isSelected: Boolean) {
|
||||||
throw NotImplementedError()
|
throw NotImplementedError()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onChatTypeClicked(view: View, chatTypeRow: ContactSearchData.ChatTypeRow, isSelected: Boolean)
|
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
|
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