diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java index dd1330e09c..9adc9a618f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java @@ -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) { diff --git a/app/src/main/res/layout/conversation_item_received_multimedia.xml b/app/src/main/res/layout/conversation_item_received_multimedia.xml index c798604ac6..e2549a68b2 100644 --- a/app/src/main/res/layout/conversation_item_received_multimedia.xml +++ b/app/src/main/res/layout/conversation_item_received_multimedia.xml @@ -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" diff --git a/app/src/main/res/layout/conversation_item_received_text_only.xml b/app/src/main/res/layout/conversation_item_received_text_only.xml index 67125b88a5..28de759eb9 100644 --- a/app/src/main/res/layout/conversation_item_received_text_only.xml +++ b/app/src/main/res/layout/conversation_item_received_text_only.xml @@ -1,7 +1,6 @@ + android:paddingEnd="@dimen/conversation_individual_right_gutter" + tools:viewBindingIgnore="true"> @@ -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"> @@ -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" diff --git a/app/src/main/res/layout/v2_conversation_item_text_only_incoming.xml b/app/src/main/res/layout/v2_conversation_item_text_only_incoming.xml index dd8f545bde..e134af3561 100644 --- a/app/src/main/res/layout/v2_conversation_item_text_only_incoming.xml +++ b/app/src/main/res/layout/v2_conversation_item_text_only_incoming.xml @@ -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" />