mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 08:39:22 +01:00
Show member labels in quotes.
This commit is contained in:
committed by
Michelle Tang
parent
e384a37fab
commit
cb05608422
@@ -1725,7 +1725,8 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
|
||||
quote.getAttachment(),
|
||||
isStoryReaction(current) ? current.getBody() : null,
|
||||
quote.getQuoteType(),
|
||||
false);
|
||||
false,
|
||||
conversationMessage.getQuoteMemberLabel());
|
||||
|
||||
quoteView.setWallpaperEnabled(hasWallpaper);
|
||||
quoteView.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -50,6 +50,7 @@ public class ConversationMessage {
|
||||
@Nullable private final MessageRecord originalMessage;
|
||||
@NonNull private final ComputedProperties computedProperties;
|
||||
@Nullable private final MemberLabel memberLabel;
|
||||
@Nullable private final MemberLabel quoteMemberLabel;
|
||||
|
||||
private ConversationMessage(@NonNull MessageRecord messageRecord,
|
||||
@Nullable CharSequence body,
|
||||
@@ -59,7 +60,8 @@ public class ConversationMessage {
|
||||
@NonNull Recipient threadRecipient,
|
||||
@Nullable MessageRecord originalMessage,
|
||||
@NonNull ComputedProperties computedProperties,
|
||||
@Nullable MemberLabel memberLabel)
|
||||
@Nullable MemberLabel memberLabel,
|
||||
@Nullable MemberLabel quoteMemberLabel)
|
||||
{
|
||||
this.messageRecord = messageRecord;
|
||||
this.hasBeenQuoted = hasBeenQuoted;
|
||||
@@ -69,6 +71,7 @@ public class ConversationMessage {
|
||||
this.originalMessage = originalMessage;
|
||||
this.computedProperties = computedProperties;
|
||||
this.memberLabel = memberLabel;
|
||||
this.quoteMemberLabel = quoteMemberLabel;
|
||||
|
||||
if (body != null) {
|
||||
this.body = SpannableString.valueOf(body);
|
||||
@@ -109,6 +112,10 @@ public class ConversationMessage {
|
||||
return memberLabel;
|
||||
}
|
||||
|
||||
public @Nullable MemberLabel getQuoteMemberLabel() {
|
||||
return quoteMemberLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -242,8 +249,9 @@ public class ConversationMessage {
|
||||
}
|
||||
}
|
||||
|
||||
FormattedDate formattedDate = getFormattedDate(context, messageRecord);
|
||||
MemberLabel memberLabel = getMemberLabel(messageRecord, threadRecipient);
|
||||
FormattedDate formattedDate = getFormattedDate(context, messageRecord);
|
||||
MemberLabel memberLabel = getMemberLabel(messageRecord, threadRecipient);
|
||||
MemberLabel quoteMemberLabel = getQuoteMemberLabel(messageRecord, threadRecipient);
|
||||
|
||||
return new ConversationMessage(messageRecord,
|
||||
styledAndMentionBody != null ? styledAndMentionBody : mentionsUpdate != null ? mentionsUpdate.getBody() : body,
|
||||
@@ -253,7 +261,8 @@ public class ConversationMessage {
|
||||
threadRecipient,
|
||||
originalMessage,
|
||||
new ComputedProperties(formattedDate),
|
||||
memberLabel);
|
||||
memberLabel,
|
||||
quoteMemberLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,5 +307,15 @@ public class ConversationMessage {
|
||||
}
|
||||
return MemberLabelRepository.getInstance().getLabelJava(threadRecipient.requireGroupId().requireV2(), messageRecord.getFromRecipient());
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private static @Nullable MemberLabel getQuoteMemberLabel(@NonNull MessageRecord messageRecord, @NonNull Recipient threadRecipient) {
|
||||
if (!threadRecipient.isPushV2Group() || !(messageRecord instanceof final MmsMessageRecord mmsMessage) || mmsMessage.getQuote() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Recipient quoteAuthor = Recipient.resolved(mmsMessage.getQuote().getAuthor());
|
||||
return MemberLabelRepository.getInstance().getLabelJava(threadRecipient.requireGroupId().requireV2(), quoteAuthor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ class SenderNameWithLabelView : AbstractComposeView {
|
||||
|
||||
private var senderName: String by mutableStateOf("")
|
||||
private var senderColor: Color by mutableStateOf(Color.Unspecified)
|
||||
private var labelTextColor: Color by mutableStateOf(Color.Unspecified)
|
||||
private var labelBackgroundColor: Color by mutableStateOf(Color.Unspecified)
|
||||
|
||||
private var memberLabel: MemberLabel? by mutableStateOf(null)
|
||||
|
||||
fun setSender(name: String, @ColorInt tintColor: Int) {
|
||||
@@ -39,16 +42,49 @@ class SenderNameWithLabelView : AbstractComposeView {
|
||||
senderColor = Color(tintColor)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label with colors derived from the sender name tint color.
|
||||
*/
|
||||
fun setLabel(label: MemberLabel?) {
|
||||
memberLabel = label
|
||||
labelTextColor = Color.Unspecified
|
||||
labelBackgroundColor = Color.Unspecified
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label with explicit text and background colors.
|
||||
*/
|
||||
fun setLabel(label: MemberLabel?, @ColorInt textColor: Int, @ColorInt backgroundColor: Int) {
|
||||
memberLabel = label
|
||||
labelTextColor = Color(textColor)
|
||||
labelBackgroundColor = Color(backgroundColor)
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to update the colors in response to theme changes (e.g., wallpaper enabled/disabled).
|
||||
*/
|
||||
fun updateColors(@ColorInt foregroundColor: Int, @ColorInt labelBackgroundColor: Int) {
|
||||
senderColor = Color(foregroundColor)
|
||||
labelTextColor = Color(foregroundColor)
|
||||
this.labelBackgroundColor = Color(labelBackgroundColor)
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
SenderNameWithLabel(
|
||||
senderName = senderName,
|
||||
senderColor = senderColor,
|
||||
label = memberLabel
|
||||
)
|
||||
if (labelTextColor != Color.Unspecified || labelBackgroundColor != Color.Unspecified) {
|
||||
SenderNameWithLabel(
|
||||
senderName = senderName,
|
||||
senderColor = senderColor,
|
||||
memberLabel = memberLabel,
|
||||
labelTextColor = labelTextColor,
|
||||
labelBackgroundColor = labelBackgroundColor
|
||||
)
|
||||
} else {
|
||||
SenderNameWithLabel(
|
||||
senderName = senderName,
|
||||
senderColor = senderColor,
|
||||
memberLabel = memberLabel
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,8 @@ class V2ConversationItemMediaViewHolder<Model : MappingModel<Model>>(
|
||||
quote.attachment,
|
||||
if (conversationMessage.messageRecord.isStoryReaction()) conversationMessage.messageRecord.body else null,
|
||||
quote.quoteType,
|
||||
false
|
||||
false,
|
||||
conversationMessage.quoteMemberLabel
|
||||
)
|
||||
|
||||
quoteView.setMessageType(
|
||||
|
||||
Reference in New Issue
Block a user