Fix margins on message clusters and 1:1 messages.

This commit is contained in:
Lucio Maciel
2021-07-21 17:04:57 -03:00
committed by Greyson Parrelli
parent 26c9b5166e
commit 833f90ce53
4 changed files with 15 additions and 4 deletions

View File

@@ -727,6 +727,14 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
bodyText.setText(StringUtil.trim(styledText)); bodyText.setText(StringUtil.trim(styledText));
bodyText.setVisibility(View.VISIBLE); bodyText.setVisibility(View.VISIBLE);
} }
if (!messageRecord.isOutgoing()) {
if (!messageRecord.isMms()) {
ViewUtil.setTopMargin(bodyText, readDimen(R.dimen.message_bubble_content_top_padding));
} else {
ViewUtil.setTopMargin(bodyText, readDimen(R.dimen.message_bubble_text_top_padding));
}
}
} }
private void setMediaAttributes(@NonNull MessageRecord messageRecord, private void setMediaAttributes(@NonNull MessageRecord messageRecord,
@@ -1123,6 +1131,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
} }
private void setQuote(@NonNull MessageRecord current, @NonNull Optional<MessageRecord> previous, @NonNull Optional<MessageRecord> next, boolean isGroupThread, @NonNull ChatColors chatColors) { private void setQuote(@NonNull MessageRecord current, @NonNull Optional<MessageRecord> previous, @NonNull Optional<MessageRecord> next, boolean isGroupThread, @NonNull ChatColors chatColors) {
boolean startOfCluster = isStartOfMessageCluster(current, previous, isGroupThread);
if (current.isMms() && !current.isMmsNotification() && ((MediaMmsMessageRecord)current).getQuote() != null) { if (current.isMms() && !current.isMmsNotification() && ((MediaMmsMessageRecord)current).getQuote() != null) {
if (quoteView == null) { if (quoteView == null) {
throw new AssertionError(); throw new AssertionError();
@@ -1144,7 +1153,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
quoteView.setOnLongClickListener(passthroughClickListener); quoteView.setOnLongClickListener(passthroughClickListener);
if (isStartOfMessageCluster(current, previous, isGroupThread)) { if (startOfCluster) {
if (current.isOutgoing()) { if (current.isOutgoing()) {
quoteView.setTopCornerSizes(true, true); quoteView.setTopCornerSizes(true, true);
} else if (isGroupThread) { } else if (isGroupThread) {
@@ -1172,7 +1181,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo
quoteView.dismiss(); quoteView.dismiss();
} }
int topMargin = current.isOutgoing() ? 0 : readDimen(R.dimen.message_bubble_content_top_padding); int topMargin = (current.isOutgoing() || !startOfCluster || !groupThread) ? 0 : readDimen(R.dimen.message_bubble_content_top_padding);
if (mediaThumbnailStub.resolved()) { if (mediaThumbnailStub.resolved()) {
ViewUtil.setTopMargin(mediaThumbnailStub.get(), topMargin); ViewUtil.setTopMargin(mediaThumbnailStub.get(), topMargin);
} }

View File

@@ -60,7 +60,6 @@
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="@dimen/message_bubble_edge_margin" android:layout_marginEnd="@dimen/message_bubble_edge_margin"
android:layout_toEndOf="@id/contact_photo_container" android:layout_toEndOf="@id/contact_photo_container"
android:paddingTop="@dimen/message_bubble_top_padding"
android:background="@color/white" android:background="@color/white"
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false" android:clipToPadding="false"
@@ -73,6 +72,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginTop="@dimen/message_bubble_top_padding"
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"> tools:visibility="visible">

View File

@@ -98,6 +98,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="1dp" android:layout_marginTop="1dp"
android:layout_marginBottom="@dimen/message_bubble_collapsed_footer_padding"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:ellipsize="end" android:ellipsize="end"
@@ -112,7 +113,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/message_bubble_horizontal_padding" android:layout_marginStart="@dimen/message_bubble_horizontal_padding"
android:layout_marginTop="2dp" android:layout_marginTop="-4dp"
android:layout_marginEnd="@dimen/message_bubble_horizontal_padding" android:layout_marginEnd="@dimen/message_bubble_horizontal_padding"
android:layout_marginBottom="@dimen/message_bubble_bottom_padding" android:layout_marginBottom="@dimen/message_bubble_bottom_padding"
android:alpha="0.7" android:alpha="0.7"

View File

@@ -36,6 +36,7 @@
<dimen name="message_bubble_shadow_distance">1.5dp</dimen> <dimen name="message_bubble_shadow_distance">1.5dp</dimen>
<dimen name="message_bubble_horizontal_padding">12dp</dimen> <dimen name="message_bubble_horizontal_padding">12dp</dimen>
<dimen name="message_bubble_top_padding">7dp</dimen> <dimen name="message_bubble_top_padding">7dp</dimen>
<dimen name="message_bubble_text_top_padding">1dp</dimen>
<dimen name="message_bubble_content_top_padding">4dp</dimen> <dimen name="message_bubble_content_top_padding">4dp</dimen>
<dimen name="message_bubble_top_padding_audio">12dp</dimen> <dimen name="message_bubble_top_padding_audio">12dp</dimen>
<dimen name="message_bubble_collapsed_footer_padding">6dp</dimen> <dimen name="message_bubble_collapsed_footer_padding">6dp</dimen>