mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-03 23:15:44 +01:00
Show member labels on the admin sheet.
This commit is contained in:
@@ -65,5 +65,17 @@ class MemberLabelPillView : AbstractComposeView {
|
||||
val horizontalPadding: Dp = 12.dp,
|
||||
val verticalPadding: Dp = 2.dp,
|
||||
val textStyle: @Composable () -> TextStyle = { MemberLabelPill.textStyleNormal }
|
||||
)
|
||||
) {
|
||||
companion object {
|
||||
@JvmField
|
||||
val Normal = Style()
|
||||
|
||||
@JvmField
|
||||
val Compact = Style(
|
||||
horizontalPadding = 8.dp,
|
||||
verticalPadding = 2.dp,
|
||||
textStyle = { MemberLabelPill.textStyleCompact }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,12 @@ class MemberLabelRepository private constructor(
|
||||
@WorkerThread
|
||||
fun getLabelJava(groupId: GroupId.V2, recipient: Recipient): MemberLabel? = runBlocking { getLabel(groupId, recipient) }
|
||||
|
||||
/**
|
||||
* Gets member labels for a list of recipients in a group (blocking version for Java compatibility).
|
||||
*/
|
||||
@WorkerThread
|
||||
fun getLabelsJava(groupId: GroupId.V2, recipients: List<Recipient>): Map<RecipientId, MemberLabel> = runBlocking { getLabels(groupId, recipients) }
|
||||
|
||||
/**
|
||||
* Gets the member label for a specific recipient in the group.
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,8 @@ import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import org.signal.libsignal.zkgroup.groups.UuidCiphertext;
|
||||
import org.thoughtcrime.securesms.conversation.colors.NameColor;
|
||||
import org.thoughtcrime.securesms.groups.memberlabel.MemberLabel;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.DefaultValueLiveData;
|
||||
|
||||
@@ -69,12 +71,20 @@ public abstract class GroupMemberEntry {
|
||||
|
||||
public final static class FullMember extends GroupMemberEntry {
|
||||
|
||||
private final Recipient member;
|
||||
private final boolean isAdmin;
|
||||
private final Recipient member;
|
||||
private final boolean isAdmin;
|
||||
@Nullable private final MemberLabel memberLabel;
|
||||
@Nullable private final NameColor nameColor;
|
||||
|
||||
public FullMember(@NonNull Recipient member, boolean isAdmin) {
|
||||
this.member = member;
|
||||
this.isAdmin = isAdmin;
|
||||
this(member, isAdmin, null, null);
|
||||
}
|
||||
|
||||
public FullMember(@NonNull Recipient member, boolean isAdmin, @Nullable MemberLabel memberLabel, @Nullable NameColor nameColor) {
|
||||
this.member = member;
|
||||
this.isAdmin = isAdmin;
|
||||
this.memberLabel = memberLabel;
|
||||
this.nameColor = nameColor;
|
||||
}
|
||||
|
||||
public Recipient getMember() {
|
||||
@@ -85,6 +95,14 @@ public abstract class GroupMemberEntry {
|
||||
return isAdmin;
|
||||
}
|
||||
|
||||
public @Nullable MemberLabel getMemberLabel() {
|
||||
return memberLabel;
|
||||
}
|
||||
|
||||
public @Nullable NameColor getNameColor() {
|
||||
return nameColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean sameId(@NonNull GroupMemberEntry newItem) {
|
||||
if (getClass() != newItem.getClass()) return false;
|
||||
@@ -98,12 +116,14 @@ public abstract class GroupMemberEntry {
|
||||
|
||||
FullMember other = (FullMember) obj;
|
||||
return other.member.equals(member) &&
|
||||
other.isAdmin == isAdmin;
|
||||
other.isAdmin == isAdmin &&
|
||||
Objects.equals(other.memberLabel, memberLabel) &&
|
||||
Objects.equals(other.nameColor, nameColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return member.hashCode() * 31 + (isAdmin ? 1 : 0);
|
||||
return ((member.hashCode() * 31 + (isAdmin ? 1 : 0)) * 31 + Objects.hashCode(memberLabel)) * 31 + Objects.hashCode(nameColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +194,8 @@ public abstract class GroupMemberEntry {
|
||||
|
||||
public UnknownPendingMemberCount(@NonNull Recipient inviter,
|
||||
@NonNull Collection<UuidCiphertext> ciphertexts,
|
||||
boolean cancellable) {
|
||||
boolean cancellable)
|
||||
{
|
||||
this.inviter = inviter;
|
||||
this.ciphertexts = ciphertexts;
|
||||
this.cancellable = cancellable;
|
||||
|
||||
@@ -19,6 +19,9 @@ import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.badges.BadgeImageView;
|
||||
import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiTextView;
|
||||
import org.thoughtcrime.securesms.conversation.colors.NameColor;
|
||||
import org.thoughtcrime.securesms.groups.memberlabel.MemberLabel;
|
||||
import org.thoughtcrime.securesms.groups.memberlabel.MemberLabelPillView;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.signal.core.util.Util;
|
||||
|
||||
@@ -194,6 +197,8 @@ final class GroupMemberListAdapter extends RecyclerView.Adapter<GroupMemberListA
|
||||
final View popupMenuContainer;
|
||||
final ProgressBar busyProgress;
|
||||
@Nullable final View admin;
|
||||
@Nullable final MemberLabelPillView memberLabelView;
|
||||
@Nullable final View addMemberLabel;
|
||||
final SelectionChangeListener selectionChangeListener;
|
||||
@Nullable final RecipientClickListener recipientClickListener;
|
||||
@Nullable final AdminActionsListener adminActionsListener;
|
||||
@@ -224,6 +229,8 @@ final class GroupMemberListAdapter extends RecyclerView.Adapter<GroupMemberListA
|
||||
this.popupMenuContainer = itemView.findViewById(R.id.popupMenuProgressContainer);
|
||||
this.busyProgress = itemView.findViewById(R.id.menuBusyProgress);
|
||||
this.admin = itemView.findViewById(R.id.admin);
|
||||
this.memberLabelView = itemView.findViewById(R.id.recipient_member_label);
|
||||
this.addMemberLabel = itemView.findViewById(R.id.add_member_label);
|
||||
this.recipientClickListener = recipientClickListener;
|
||||
this.recipientLongClickListener = recipientLongClickListener;
|
||||
this.adminActionsListener = adminActionsListener;
|
||||
@@ -296,6 +303,9 @@ final class GroupMemberListAdapter extends RecyclerView.Adapter<GroupMemberListA
|
||||
if (admin != null) {
|
||||
admin.setVisibility(View.GONE);
|
||||
}
|
||||
if (addMemberLabel != null) {
|
||||
addMemberLabel.setVisibility(View.GONE);
|
||||
}
|
||||
hideMenu();
|
||||
|
||||
itemView.setOnClickListener(null);
|
||||
@@ -346,6 +356,19 @@ final class GroupMemberListAdapter extends RecyclerView.Adapter<GroupMemberListA
|
||||
if (admin != null) {
|
||||
admin.setVisibility(fullMember.isAdmin() ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
|
||||
MemberLabel label = fullMember.getMemberLabel();
|
||||
NameColor nameColor = fullMember.getNameColor();
|
||||
if (memberLabelView != null) {
|
||||
if (label != null && nameColor != null) {
|
||||
memberLabelView.setStyle(MemberLabelPillView.Style.Compact);
|
||||
memberLabelView.setLabel(label, nameColor.getColor(context));
|
||||
memberLabelView.setVisibility(View.VISIBLE);
|
||||
if (about != null) about.setVisibility(View.GONE);
|
||||
} else {
|
||||
memberLabelView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final static class NewGroupInviteeViewHolder extends ViewHolder {
|
||||
|
||||
Reference in New Issue
Block a user