Update group update margins.

This commit is contained in:
Michelle Tang 2026-06-16 17:00:54 -04:00 committed by Greyson Parrelli
parent c500d8ecbd
commit 3924f65cbe
3 changed files with 90 additions and 105 deletions

View File

@ -94,6 +94,7 @@ public final class ConversationUpdateItem extends FrameLayout
private TextView body;
private MaterialButton actionButton;
private View background;
private View bodyBackground;
private ConversationMessage conversationMessage;
private Recipient conversationRecipient;
private Optional<MessageRecord> previousMessageRecord;
@ -119,6 +120,7 @@ public final class ConversationUpdateItem extends FrameLayout
private int latestFrame;
private SpannableString displayBody;
private ExpirationTimer timer;
private boolean hasWallpaper;
private final PassthroughClickListener passthroughClickListener = new PassthroughClickListener();
@ -138,6 +140,7 @@ public final class ConversationUpdateItem extends FrameLayout
this.body = findViewById(R.id.conversation_update_body);
this.actionButton = findViewById(R.id.conversation_update_action);
this.background = findViewById(R.id.conversation_update_background);
this.bodyBackground = findViewById(R.id.conversation_update_body_background);
this.collapsedButton = findViewById(R.id.conversation_update_collapsed);
body.setOnClickListener(v -> {
@ -198,6 +201,7 @@ public final class ConversationUpdateItem extends FrameLayout
this.nextMessageRecord = nextMessageRecord;
this.conversationRecipient = conversationRecipient;
this.isMessageRequestAccepted = isMessageRequestAccepted;
this.hasWallpaper = hasWallpaper;
senderObserver.observe(lifecycleOwner, messageRecord.getFromRecipient());
@ -209,9 +213,11 @@ public final class ConversationUpdateItem extends FrameLayout
groupObserver.observe(lifecycleOwner, null);
}
int textColor = ContextCompat.getColor(getContext(), R.color.conversation_item_update_text_color);
if (ThemeUtil.isDarkTheme(getContext()) && hasWallpaper) {
textColor = ContextCompat.getColor(getContext(), R.color.core_grey_15);
int textColor;
if (hasWallpaper) {
textColor = ContextCompat.getColor(getContext(), org.signal.core.ui.R.color.signal_colorOnSurfaceVariant);
} else {
textColor = ContextCompat.getColor(getContext(), R.color.conversation_item_update_text_color);
}
UpdateDescription updateDescription = Objects.requireNonNull(messageRecord.getUpdateDisplayBody(getContext(), eventListener::onRecipientNameClicked));
@ -227,13 +233,10 @@ public final class ConversationUpdateItem extends FrameLayout
present(conversationMessage, nextMessageRecord, conversationRecipient, isMessageRequestAccepted);
presentTimer(updateDescription);
presentBackground(shouldCollapse(messageRecord, previousMessageRecord),
shouldCollapse(messageRecord, nextMessageRecord),
hasWallpaper,
donationRequest);
presentBackground(hasWallpaper, donationRequest);
presentActionButton(hasWallpaper, donationRequest);
presentCollapsedHead(conversationMessage.getMessageRecord().getCollapsedState());
presentCollapsedHead(hasWallpaper, conversationMessage.getMessageRecord().getCollapsedState());
updateSelectedState();
}
@ -247,12 +250,11 @@ public final class ConversationUpdateItem extends FrameLayout
}
}
private static boolean shouldCollapse(@NonNull MessageRecord current, @NonNull Optional<MessageRecord> candidate)
private static boolean isSameDayUpdate(@NonNull MessageRecord current, @NonNull Optional<MessageRecord> candidate)
{
return candidate.isPresent() &&
candidate.get().isUpdate() &&
DateUtils.isSameDay(current.getTimestamp(), candidate.get().getTimestamp()) &&
isSameType(current, candidate.get());
DateUtils.isSameDay(current.getTimestamp(), candidate.get().getTimestamp());
}
/** After a short delay, if the main data hasn't shown yet, then a loading message is displayed. */
@ -414,6 +416,7 @@ public final class ConversationUpdateItem extends FrameLayout
private void update() {
present(conversationMessage, nextMessageRecord, conversationRecipient, isMessageRequestAccepted);
presentBackground(hasWallpaper, conversationMessage.getMessageRecord().isReleaseChannelDonationRequest());
}
}
@ -791,72 +794,43 @@ public final class ConversationUpdateItem extends FrameLayout
(messageRecord.isGroupV2JoinRequest(toBlock.requireServiceId()) && previousMessageRecord.map(m -> m.isCollapsedGroupV2JoinUpdate(toBlock.requireServiceId())).orElse(false));
}
private void presentBackground(boolean collapseAbove, boolean collapseBelow, boolean hasWallpaper, boolean isDonationRequest) {
int marginDefault = getContext().getResources().getDimensionPixelOffset(R.dimen.conversation_update_vertical_margin);
int marginCollapsed = 0;
int paddingDefault = getContext().getResources().getDimensionPixelOffset(R.dimen.conversation_update_vertical_padding);
int paddingCollapsed = getContext().getResources().getDimensionPixelOffset(R.dimen.conversation_update_vertical_padding_collapsed);
private void presentBackground(boolean hasWallpaper, boolean isDonationRequest) {
int marginCompact;
int marginDefault;
int topMargin;
int bottomMargin;
if (!hasWallpaper) {
marginCompact = getContext().getResources().getDimensionPixelOffset(R.dimen.conversation_update_margin_compact);
marginDefault = getContext().getResources().getDimensionPixelOffset(R.dimen.conversation_update_margin);
} else {
marginCompact = getContext().getResources().getDimensionPixelOffset(R.dimen.conversation_update_margin_compact_wallpaper);
marginDefault = getContext().getResources().getDimensionPixelOffset(R.dimen.conversation_update_margin_wallpaper);
}
topMargin = isSameDayUpdate(messageRecord, previousMessageRecord) ? marginCompact : marginDefault;
bottomMargin = isSameDayUpdate(messageRecord, nextMessageRecord) ? marginCompact : marginDefault;
if (collapseAbove && collapseBelow) {
ViewUtil.setTopMargin(background, marginCollapsed);
ViewUtil.setBottomMargin(background, marginCollapsed);
int verticalPadding;
if (actionButton.getVisibility() == View.VISIBLE) {
verticalPadding = getContext().getResources().getDimensionPixelOffset(R.dimen.conversation_update_vertical_margin_action);
} else if (hasWallpaper) {
verticalPadding = getContext().getResources().getDimensionPixelOffset(R.dimen.conversation_update_vertical_margin);
} else {
verticalPadding = 0;
}
ViewUtil.setPaddingTop(background, paddingCollapsed);
ViewUtil.setPaddingBottom(background, paddingCollapsed);
ViewUtil.setTopMargin(background, topMargin);
ViewUtil.setBottomMargin(background, bottomMargin);
ViewUtil.setPaddingTop(bodyBackground, verticalPadding);
ViewUtil.setPaddingBottom(bodyBackground, verticalPadding);
ViewUtil.updateLayoutParams(background, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
if (hasWallpaper) {
background.setBackgroundResource(R.drawable.conversation_update_wallpaper_background_middle);
if (hasWallpaper && !conversationMessage.isActiveCollapsedHead()) {
if (isDonationRequest) {
bodyBackground.setBackgroundResource(R.drawable.conversation_update_release_note_background);
} else {
background.setBackground(null);
}
} else if (collapseAbove) {
ViewUtil.setTopMargin(background, marginCollapsed);
ViewUtil.setBottomMargin(background, marginDefault);
ViewUtil.setPaddingTop(background, paddingDefault);
ViewUtil.setPaddingBottom(background, paddingDefault);
ViewUtil.updateLayoutParams(background, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
if (hasWallpaper) {
background.setBackgroundResource(R.drawable.conversation_update_wallpaper_background_bottom);
} else {
background.setBackground(null);
}
} else if (collapseBelow) {
ViewUtil.setTopMargin(background, marginDefault);
ViewUtil.setBottomMargin(background, marginCollapsed);
ViewUtil.setPaddingTop(background, paddingDefault);
ViewUtil.setPaddingBottom(background, paddingCollapsed);
ViewUtil.updateLayoutParams(background, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
if (hasWallpaper) {
background.setBackgroundResource(R.drawable.conversation_update_wallpaper_background_top);
} else {
background.setBackground(null);
bodyBackground.setBackgroundResource(R.drawable.conversation_update_wallpaper_background_singular);
}
} else {
ViewUtil.setTopMargin(background, marginDefault);
ViewUtil.setBottomMargin(background, marginDefault);
ViewUtil.setPaddingTop(background, paddingDefault);
ViewUtil.setPaddingBottom(background, paddingDefault);
ViewUtil.updateLayoutParams(background, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
if (hasWallpaper) {
if (isDonationRequest) {
background.setBackgroundResource(R.drawable.conversation_update_release_note_background);
} else {
background.setBackgroundResource(R.drawable.conversation_update_wallpaper_background_singular);
}
} else {
background.setBackground(null);
}
bodyBackground.setBackground(null);
}
}
@ -873,7 +847,7 @@ public final class ConversationUpdateItem extends FrameLayout
}
}
private void presentCollapsedHead(CollapsedState collapsedState) {
private void presentCollapsedHead(boolean hasWallpaper, CollapsedState collapsedState) {
if (!conversationMessage.isActiveCollapsibleHead()) {
collapsedButton.setVisibility(GONE);
} else {
@ -898,6 +872,15 @@ public final class ConversationUpdateItem extends FrameLayout
}
});
ViewUtil.setBottomMargin(collapsedButton, (int) DimensionUnit.DP.toPixels(conversationMessage.isActiveCollapsedHead() ? 0 : 12));
if (hasWallpaper) {
collapsedButton.setBackgroundResource(R.drawable.conversation_update_wallpaper_background_singular);
collapsedButton.setBackgroundTintList(null);
} else {
collapsedButton.setBackgroundResource(R.drawable.rounded_rectangle_38);
collapsedButton.setBackgroundTintList(AppCompatResources.getColorStateList(getContext(), org.signal.core.ui.R.color.signal_colorSurface1));
}
collapsedButton.setVisibility(VISIBLE);
} else {
Log.w(TAG, "Found a message that is a collapsible head but does not have a collapsible type.");
@ -925,14 +908,6 @@ public final class ConversationUpdateItem extends FrameLayout
};
}
private static boolean isSameType(@NonNull MessageRecord current, @NonNull MessageRecord candidate) {
return (current.isGroupUpdate() && candidate.isGroupUpdate()) ||
(current.isProfileChange() && candidate.isProfileChange()) ||
(current.isGroupCall() && candidate.isGroupCall()) ||
(current.isExpirationTimerUpdate() && candidate.isExpirationTimerUpdate()) ||
(current.isChangeNumber() && candidate.isChangeNumber());
}
private void presentTimer(UpdateDescription updateDescription) {
if (updateDescription.hasExpiration() && messageRecord.getExpiresIn() > 0 && messageRecord.getExpireStarted() > 0) {
timer = new ExpirationTimer(messageRecord.getExpireStarted(), messageRecord.getExpiresIn());
@ -984,6 +959,7 @@ public final class ConversationUpdateItem extends FrameLayout
if (recipient.getId() == conversationRecipient.getId() && (conversationRecipient == null || !conversationRecipient.hasSameContent(recipient))) {
conversationRecipient = recipient;
present(conversationMessage, nextMessageRecord, conversationRecipient, isMessageRequestAccepted);
presentBackground(hasWallpaper, conversationMessage.getMessageRecord().isReleaseChannelDonationRequest());
}
}
}

View File

@ -15,14 +15,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/conversation_update_vertical_margin"
android:layout_marginBottom="@dimen/conversation_update_vertical_margin"
android:orientation="vertical"
android:gravity="center"
android:paddingTop="@dimen/conversation_update_vertical_padding"
android:paddingBottom="@dimen/conversation_update_vertical_padding"
android:paddingStart="16dp"
android:paddingEnd="16dp">
android:gravity="center">
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/conversation_update_collapsed"
@ -32,31 +26,43 @@
android:paddingVertical="6dp"
android:textSize="13sp"
android:background="@drawable/rounded_rectangle_38"
android:paddingHorizontal="16dp"
android:paddingHorizontal="12dp"
android:textColor="@color/signal_colorOnSurfaceVariant"
android:textAllCaps="false"
style="?android:attr/borderlessButtonStyle"
android:backgroundTint="@color/signal_colorSurface1"
tools:text="12 group updates" />
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/conversation_update_body"
style="@style/Signal.Text.BodySmall"
<LinearLayout
android:id="@+id/conversation_update_body_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/conversation_item_update_text_color"
tools:text="Gwen Stacy set the disappearing message timer to 1 hour" />
android:layout_gravity="center"
android:orientation="vertical"
android:paddingHorizontal="12dp"
android:gravity="center" >
<com.google.android.material.button.MaterialButton
android:id="@+id/conversation_update_action"
style="@style/Widget.Signal.Button.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:visibility="gone"
tools:text="Learn more"
tools:visibility="visible" />
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/conversation_update_body"
style="@style/Signal.Text.BodySmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:includeFontPadding="false"
android:textColor="@color/conversation_item_update_text_color"
tools:text="Gwen Stacy set the disappearing message timer to 1 hour" />
<com.google.android.material.button.MaterialButton
android:id="@+id/conversation_update_action"
style="@style/Widget.Signal.Button.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:visibility="gone"
tools:text="Learn more"
tools:visibility="visible" />
</LinearLayout>
</LinearLayout>

View File

@ -156,9 +156,12 @@
<dimen name="wave_form_bar_width">2dp</dimen>
<dimen name="conversation_update_margin">12dp</dimen>
<dimen name="conversation_update_margin_wallpaper">8dp</dimen>
<dimen name="conversation_update_margin_compact">8dp</dimen>
<dimen name="conversation_update_margin_compact_wallpaper">4dp</dimen>
<dimen name="conversation_update_vertical_margin">4dp</dimen>
<dimen name="conversation_update_vertical_padding">20dp</dimen>
<dimen name="conversation_update_vertical_padding_collapsed">4dp</dimen>
<dimen name="conversation_update_vertical_margin_action">12dp</dimen>
<dimen name="transfer_top_padding">64dp</dimen>
<dimen name="transfer_split_top_padding">32dp</dimen>