mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-30 16:06:13 +00:00
Show member count in contact selection list.
This commit is contained in:
@@ -112,10 +112,14 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void setText(@Nullable Recipient recipient, int type, String name, String number, String label) {
|
||||
if (number == null || number.isEmpty() || GroupId.isEncodedGroup(number)) {
|
||||
if (number == null || number.isEmpty()) {
|
||||
this.nameView.setEnabled(false);
|
||||
this.numberView.setText("");
|
||||
this.labelView.setVisibility(View.GONE);
|
||||
} else if (recipient != null && recipient.isGroup()) {
|
||||
this.nameView.setEnabled(false);
|
||||
this.numberView.setText(getGroupMemberCount(recipient));
|
||||
this.labelView.setVisibility(View.GONE);
|
||||
} else if (type == ContactRepository.PUSH_TYPE) {
|
||||
this.numberView.setText(number);
|
||||
this.nameView.setEnabled(true);
|
||||
@@ -149,6 +153,14 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF
|
||||
return chipName;
|
||||
}
|
||||
|
||||
private String getGroupMemberCount(@NonNull Recipient recipient) {
|
||||
if (!recipient.isGroup()) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
int memberCount = recipient.getParticipants().size();
|
||||
return getContext().getResources().getQuantityString(R.plurals.contact_selection_list_item__number_of_members, memberCount, memberCount);
|
||||
}
|
||||
|
||||
public @Nullable LiveRecipient getRecipient() {
|
||||
return recipient;
|
||||
}
|
||||
@@ -165,5 +177,8 @@ public class ContactSelectionListItem extends LinearLayout implements RecipientF
|
||||
public void onRecipientChanged(@NonNull Recipient recipient) {
|
||||
contactPhotoImage.setAvatar(glideRequests, recipient, false);
|
||||
nameView.setText(recipient);
|
||||
if (recipient.isGroup()) {
|
||||
numberView.setText(getGroupMemberCount(recipient));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user