Skip to content

Commit

Permalink
Show member count in contact selection list.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-signal committed Jun 9, 2020
1 parent 2751fd7 commit cea6a83
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Expand Up @@ -112,10 +112,14 @@ public void unbind(GlideRequests glideRequests) {

@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);
Expand Down Expand Up @@ -149,6 +153,14 @@ public String getChipName() {
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;
}
Expand All @@ -165,5 +177,8 @@ public Optional<RecipientId> getRecipientId() {
public void onRecipientChanged(@NonNull Recipient recipient) {
contactPhotoImage.setAvatar(glideRequests, recipient, false);
nameView.setText(recipient);
if (recipient.isGroup()) {
numberView.setText(getGroupMemberCount(recipient));
}
}
}
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Expand Up @@ -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>
Expand Down

0 comments on commit cea6a83

Please sign in to comment.