Show member count in contact selection list.
This commit is contained in:
parent
2751fd7efc
commit
cea6a83d8a
2 changed files with 22 additions and 1 deletions
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1417,6 +1417,12 @@
|
|||
<string name="contact_selection_list_fragment__signal_needs_access_to_your_contacts_in_order_to_display_them">Signal needs access to your contacts in order to display them.</string>
|
||||
<string name="contact_selection_list_fragment__show_contacts">Show Contacts</string>
|
||||
|
||||
<!-- contact_selection_list_item -->
|
||||
<plurals name="contact_selection_list_item__number_of_members">
|
||||
<item quantity="one">%1$d member</item>
|
||||
<item quantity="other">%1$d members</item>
|
||||
</plurals>
|
||||
|
||||
<!-- conversation_activity -->
|
||||
<string name="conversation_activity__type_message_push">Signal message</string>
|
||||
<string name="conversation_activity__type_message_sms_insecure">Unsecured SMS</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue