Ensure consistent margins below sender name/label.

This commit is contained in:
jeffrey-signal
2026-02-17 16:02:49 -05:00
parent 6f9f89734d
commit 73c25f3476
4 changed files with 58 additions and 24 deletions

View File

@@ -428,6 +428,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
setHasBeenScheduled(conversationMessage);
setHasBeenPinned(conversationMessage);
setPoll(messageRecord, messageRecord.getToRecipient().getChatColors().asSingleColor());
adjustMarginsForSenderVisibility();
if (audioViewStub.resolved()) {
audioViewStub.get().setOnLongClickListener(passthroughClickListener);
@@ -1504,7 +1505,9 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
paymentViewStub.setVisibility(View.GONE);
ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int senderWidth = hasQuote(messageRecord) ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, senderWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
footer.setVisibility(VISIBLE);
@@ -1775,10 +1778,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
ViewUtil.setBottomMargin(quoteView, 0, false);
}
if (mediaThumbnailStub.resolved()) {
ViewUtil.setTopMargin(mediaThumbnailStub.require(), readDimen(R.dimen.message_bubble_top_padding), false);
}
if (linkPreviewStub.resolved() && !hasBigImageLinkPreview(current)) {
ViewUtil.setTopMargin(linkPreviewStub.get(), readDimen(R.dimen.message_bubble_top_padding), false);
}
@@ -1786,11 +1785,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
if (quoteView != null) {
quoteView.dismiss();
}
int topMargin = (current.isOutgoing() || !startOfCluster || !groupThread) ? 0 : readDimen(R.dimen.message_bubble_top_image_margin);
if (mediaThumbnailStub.resolved()) {
ViewUtil.setTopMargin(mediaThumbnailStub.require(), topMargin, false);
}
}
}
@@ -1987,7 +1981,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
!DateUtils.isSameDay(previous.get().getTimestamp(), current.getTimestamp()) || !isWithinClusteringTime(current, previous.get()) || forceGroupHeader(current))
{
groupSenderHolder.setVisibility(VISIBLE);
adjustMarginsForSenderVisibility(true);
if (hasWallpaper && hasNoBubble(current)) {
groupSenderHolder.setBackgroundResource(R.drawable.wallpaper_bubble_background_tintable_11);
@@ -1997,7 +1990,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
}
} else {
groupSenderHolder.setVisibility(GONE);
adjustMarginsForSenderVisibility(false);
}
if (!next.isPresent() || next.get().isUpdate() || !current.getFromRecipient().equals(next.get().getFromRecipient()) || !isWithinClusteringTime(current, next.get()) || forceGroupHeader(current)) {
@@ -2011,7 +2003,6 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
if (groupSenderHolder != null) {
groupSenderHolder.setVisibility(GONE);
}
adjustMarginsForSenderVisibility(false);
if (contactPhotoHolder != null) {
contactPhotoHolder.setVisibility(GONE);
@@ -2023,12 +2014,53 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
}
}
private void adjustMarginsForSenderVisibility(boolean senderNameVisible) {
ViewUtil.setTopMargin(bodyText, senderNameVisible ? 0 : readDimen(R.dimen.message_bubble_top_padding));
private void adjustMarginsForSenderVisibility() {
boolean senderNameVisible = groupSenderHolder != null && groupSenderHolder.getVisibility() == VISIBLE;
boolean hasContentAboveBody = (quoteView != null && quoteView.getVisibility() == VISIBLE)
|| (mediaThumbnailStub.resolved() && mediaThumbnailStub.require().getVisibility() == VISIBLE)
|| (linkPreviewStub.resolved() && linkPreviewStub.get().getVisibility() == VISIBLE)
|| (audioViewStub.resolved() && audioViewStub.get().getVisibility() == VISIBLE)
|| (documentViewStub.resolved() && documentViewStub.get().getVisibility() == VISIBLE)
|| (sharedContactStub.resolved() && sharedContactStub.get().getVisibility() == VISIBLE)
|| (stickerStub.resolved() && stickerStub.get().getVisibility() == VISIBLE)
|| (revealableStub.resolved() && revealableStub.get().getVisibility() == VISIBLE);
if (hasContentAboveBody) {
ViewUtil.setTopMargin(bodyText, readDimen(R.dimen.message_bubble_top_image_margin));
} else if (senderNameVisible) {
ViewUtil.setTopMargin(bodyText, 0);
} else {
ViewUtil.setTopMargin(bodyText, readDimen(R.dimen.message_bubble_top_padding));
}
if (quoteView != null) {
ViewUtil.setTopMargin(quoteView, senderNameVisible ? 0 : readDimen(R.dimen.message_bubble_top_padding));
}
if (audioViewStub.resolved()) {
ViewUtil.setTopMargin(audioViewStub.get(), senderNameVisible ? 0 : readDimen(R.dimen.message_bubble_top_padding_audio));
}
if (stickerStub.resolved()) {
ViewUtil.setTopMargin(stickerStub.get(), senderNameVisible ? 0 : readDimen(R.dimen.message_bubble_top_padding));
}
if (documentViewStub.resolved()) {
ViewUtil.setTopMargin(documentViewStub.get(), senderNameVisible ? 0 : readDimen(R.dimen.message_bubble_top_padding));
}
if (sharedContactStub.resolved()) {
ViewUtil.setTopMargin(sharedContactStub.get(), senderNameVisible ? 0 : readDimen(R.dimen.message_bubble_top_padding));
}
if (revealableStub.resolved()) {
ViewUtil.setTopMargin(revealableStub.get(), senderNameVisible ? 0 : readDimen(R.dimen.message_bubble_top_padding));
}
if (mediaThumbnailStub.resolved()) {
boolean hasQuoteAbove = quoteView != null && quoteView.getVisibility() == VISIBLE;
ViewUtil.setTopMargin(mediaThumbnailStub.require(), hasQuoteAbove ? readDimen(R.dimen.message_bubble_top_image_margin) : 0);
}
}
private void setOutlinerRadii(Outliner outliner, int topStart, int topEnd, int bottomEnd, int bottomStart) {

View File

@@ -83,7 +83,7 @@
android:id="@+id/group_sender_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_image_margin"
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginBottom="@dimen/message_bubble_top_image_margin"
android:orientation="horizontal"
android:visibility="gone"

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<org.thoughtcrime.securesms.conversation.ConversationItem xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:viewBindingIgnore="true"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/conversation_item"
android:layout_width="match_parent"
@@ -13,7 +12,8 @@
android:nextFocusRight="@+id/embedded_text_editor"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingEnd="@dimen/conversation_individual_right_gutter">
android:paddingEnd="@dimen/conversation_individual_right_gutter"
tools:viewBindingIgnore="true">
<FrameLayout
android:id="@+id/reply_icon_wrapper"
@@ -38,8 +38,8 @@
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@id/body_bubble"
android:layout_alignTop="@id/body_bubble"
android:layout_alignEnd="@id/body_bubble"
android:layout_alignBottom="@id/body_bubble"
android:layout_marginEnd="-42dp">
@@ -105,13 +105,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginBottom="1dp"
android:orientation="horizontal"
android:visibility="gone"
tools:visibility="visible">
<org.thoughtcrime.securesms.conversation.v2.items.SenderNameWithLabelView
android:id="@+id/group_sender_name_with_label"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/message_bubble_horizontal_padding"
android:paddingEnd="@dimen/message_bubble_horizontal_padding" />
@@ -156,9 +157,9 @@
android:id="@+id/conversation_item_sticker_footer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginTop="2dp"
android:layout_gravity="end"
android:clipChildren="false"
android:clipToPadding="false"
android:paddingStart="@dimen/message_bubble_horizontal_padding"

View File

@@ -77,6 +77,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:layout_marginBottom="1dp"
android:paddingStart="@dimen/message_bubble_horizontal_padding"
android:paddingEnd="@dimen/message_bubble_horizontal_padding"
android:visibility="gone"
@@ -125,11 +126,11 @@
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:layout_marginBottom="@dimen/message_bubble_footer_bottom_padding"
app:layout_constraintTop_toTopOf="@id/conversation_item_footer_date"
android:src="@drawable/symbol_pin_filled_12"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/conversation_item_footer_date"
app:layout_constraintEnd_toStartOf="@id/conversation_item_footer_date"
android:visibility="gone"
android:src="@drawable/symbol_pin_filled_12" />
app:layout_constraintTop_toTopOf="@id/conversation_item_footer_date" />
<TextView
android:id="@+id/conversation_item_footer_date"