From 38adb0373d3b16c5ea2869b2a709fa048bcf9a6f Mon Sep 17 00:00:00 2001 From: Lucio Maciel Date: Fri, 23 Jul 2021 18:04:35 -0300 Subject: [PATCH] Fix mentions and thumbnail size. --- .../conversation/ConversationItem.java | 29 +++++++++++++------ .../conversation_item_received_multimedia.xml | 6 ++-- .../conversation_item_received_text_only.xml | 4 ++- .../conversation_item_sent_multimedia.xml | 4 ++- .../conversation_item_sent_text_only.xml | 4 ++- 5 files changed, 33 insertions(+), 14 deletions(-) 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 d38c2868b..b09799f26 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationItem.java @@ -176,6 +176,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo protected View replyIcon; @Nullable protected ViewGroup contactPhotoHolder; @Nullable private QuoteView quoteView; + private ViewGroup bodyFooterContainer; private EmojiTextView bodyText; private ConversationItemFooter footer; private ConversationItemFooter stickerFooter; @@ -244,6 +245,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo this.backgroundDrawable = new ClipProjectionDrawable(Objects.requireNonNull(ContextCompat.getDrawable(getContext(), R.drawable.conversation_item_background))); + this.bodyFooterContainer = findViewById(R.id.conversation_body_footer_container); this.bodyText = findViewById(R.id.conversation_item_body); this.footer = findViewById(R.id.conversation_item_footer); this.stickerFooter = findViewById(R.id.conversation_item_sticker_footer); @@ -781,7 +783,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo setSharedContactCorners(messageRecord, previousRecord, nextRecord, isGroupThread); - ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewUtil.updateLayoutParams(bodyFooterContainer, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); footer.setVisibility(GONE); } else if (hasLinkPreview(messageRecord) && messageRequestAccepted) { @@ -809,13 +811,13 @@ public final class ConversationItem extends RelativeLayout implements BindableCo setThumbnailCorners(messageRecord, previousRecord, nextRecord, isGroupThread); setLinkPreviewCorners(messageRecord, previousRecord, nextRecord, isGroupThread, true); - ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewUtil.updateLayoutParams(bodyFooterContainer, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } else { linkPreviewStub.get().setLinkPreview(glideRequests, linkPreview, true); linkPreviewStub.get().setDownloadClickedListener(downloadClickListener); setLinkPreviewCorners(messageRecord, previousRecord, nextRecord, isGroupThread, false); - ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewUtil.updateLayoutParams(bodyFooterContainer, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); } @@ -844,7 +846,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo Log.w(TAG, "setMediaAttributes: could not register listener for audio slide " + audioViewStub.get().getAudioSlideUri()); } - ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewUtil.updateLayoutParams(bodyFooterContainer, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); footer.setPlaybackSpeedListener(new AudioPlaybackSpeedToggleListener()); @@ -864,7 +866,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo documentViewStub.get().setDownloadClickListener(singleDownloadClickListener); documentViewStub.get().setOnLongClickListener(passthroughClickListener); - ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewUtil.updateLayoutParams(bodyFooterContainer, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); footer.setVisibility(VISIBLE); @@ -893,7 +895,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo stickerStub.get().setOnLongClickListener(passthroughClickListener); stickerStub.get().setOnClickListener(passthroughClickListener); - ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewUtil.updateLayoutParams(bodyFooterContainer, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); footer.setVisibility(VISIBLE); @@ -929,7 +931,7 @@ public final class ConversationItem extends RelativeLayout implements BindableCo setThumbnailCorners(messageRecord, previousRecord, nextRecord, isGroupThread); - ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewUtil.updateLayoutParams(bodyFooterContainer, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); footer.setVisibility(VISIBLE); @@ -958,9 +960,16 @@ public final class ConversationItem extends RelativeLayout implements BindableCo if (stickerStub.resolved()) stickerStub.get().setVisibility(View.GONE); if (revealableStub.resolved()) revealableStub.get().setVisibility(View.GONE); - ViewUtil.updateLayoutParams(bodyText, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ViewUtil.updateLayoutParams(bodyFooterContainer, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); ViewUtil.updateLayoutParamsIfNonNull(groupSenderHolder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + if (messageRecord.isMms() && !messageRecord.isOutgoing() && isGroupThread && !hasQuote(messageRecord)) { + boolean startOfCluster = isStartOfMessageCluster(messageRecord, previousRecord, isGroupThread); + int margin = startOfCluster ? readDimen(R.dimen.message_bubble_quote_negative_margin) : readDimen(R.dimen.message_bubble_top_padding); + + ViewUtil.setTopMargin(bodyText, margin); + } + footer.setVisibility(VISIBLE); } } @@ -1163,7 +1172,9 @@ public final class ConversationItem extends RelativeLayout implements BindableCo if (mediaThumbnailStub.resolved()) { ViewUtil.setTopMargin(mediaThumbnailStub.require(), readDimen(R.dimen.message_bubble_top_padding)); - } else if (startOfCluster && !current.isOutgoing() && groupThread) { + } + + if (startOfCluster && !current.isOutgoing() && groupThread) { ViewUtil.setTopMargin(quoteView, readDimen(R.dimen.message_bubble_quote_negative_margin)); } else { ViewUtil.setTopMargin(quoteView, readDimen(R.dimen.message_bubble_top_padding)); 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 49c3b639a..6c462c8f4 100644 --- a/app/src/main/res/layout/conversation_item_received_multimedia.xml +++ b/app/src/main/res/layout/conversation_item_received_multimedia.xml @@ -162,7 +162,9 @@ android:id="@+id/conversation_body_footer_container" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="vertical"> + android:orientation="vertical" + android:clipChildren="false" + android:clipToPadding="false"> + android:orientation="vertical" + android:clipChildren="false" + android:clipToPadding="false"> + android:orientation="vertical" + android:clipChildren="false" + android:clipToPadding="false"> + android:orientation="vertical" + android:clipChildren="false" + android:clipToPadding="false">