From ff4311d114129c019fe14862846c2cc8609e5d13 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Mon, 16 May 2022 10:59:20 -0300 Subject: [PATCH] Add outline around sent gift reply thumb. --- .../securesms/components/QuoteView.java | 54 ++++++++++++++----- .../ConversationListItem.java | 8 ++- app/src/main/res/layout/quote_view.xml | 3 +- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java b/app/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java index ccfbc5a6bb..7b03a789be 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/QuoteView.java @@ -17,11 +17,14 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; -import androidx.appcompat.content.res.AppCompatResources; import androidx.core.content.ContextCompat; import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.google.android.material.imageview.ShapeableImageView; +import com.google.android.material.shape.CornerFamily; +import com.google.android.material.shape.ShapeAppearanceModel; +import org.signal.core.util.DimensionUnit; import org.signal.core.util.logging.Log; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.attachments.Attachment; @@ -76,18 +79,18 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver { } } - private ViewGroup mainView; - private ViewGroup footerView; - private TextView authorView; - private TextView bodyView; - private View quoteBarView; - private ImageView thumbnailView; - private View attachmentVideoOverlayView; - private ViewGroup attachmentContainerView; - private TextView attachmentNameView; - private ImageView dismissView; - private EmojiImageView missingStoryReaction; - private EmojiImageView storyReactionEmoji; + private ViewGroup mainView; + private ViewGroup footerView; + private TextView authorView; + private TextView bodyView; + private View quoteBarView; + private ShapeableImageView thumbnailView; + private View attachmentVideoOverlayView; + private ViewGroup attachmentContainerView; + private TextView attachmentNameView; + private ImageView dismissView; + private EmojiImageView missingStoryReaction; + private EmojiImageView storyReactionEmoji; private long id; private LiveRecipient author; @@ -380,7 +383,11 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver { } private void setQuoteAttachment(@NonNull GlideRequests glideRequests, @NonNull CharSequence body, @NonNull SlideDeck slideDeck, boolean originalMissing) { + boolean outgoing = messageType != MessageType.INCOMING && messageType != MessageType.STORY_REPLY_INCOMING; + boolean preview = messageType == MessageType.PREVIEW || messageType == MessageType.STORY_REPLY_PREVIEW; + mainView.setMinimumHeight(isStoryReply() && originalMissing ? 0 : thumbHeight); + thumbnailView.setPadding(0, 0, 0, 0); if (!attachments.containsMediaSlide() && isStoryReply()) { StoryTextPostModel model = getStoryTextPost(body); @@ -396,6 +403,12 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver { } if (quoteType == QuoteModel.Type.GIFT_BADGE) { + if (outgoing && !preview) { + int oneDp = (int) DimensionUnit.DP.toPixels(1); + thumbnailView.setPadding(oneDp, oneDp, oneDp, oneDp); + thumbnailView.setShapeAppearanceModel(buildShapeAppearanceForLayoutDirection()); + } + attachmentVideoOverlayView.setVisibility(GONE); attachmentContainerView.setVisibility(GONE); thumbnailView.setVisibility(VISIBLE); @@ -487,4 +500,19 @@ public class QuoteView extends FrameLayout implements RecipientForeverObserver { public @NonNull List getMentions() { return MentionAnnotation.getMentionsFromAnnotations(body); } + + private @NonNull ShapeAppearanceModel buildShapeAppearanceForLayoutDirection() { + int fourDp = (int) DimensionUnit.DP.toPixels(4); + if (getLayoutDirection() == LAYOUT_DIRECTION_LTR) { + return ShapeAppearanceModel.builder() + .setTopRightCorner(CornerFamily.ROUNDED, fourDp) + .setBottomRightCorner(CornerFamily.ROUNDED, fourDp) + .build(); + } else { + return ShapeAppearanceModel.builder() + .setTopLeftCorner(CornerFamily.ROUNDED, fourDp) + .setBottomLeftCorner(CornerFamily.ROUNDED, fourDp) + .build(); + } + } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListItem.java b/app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListItem.java index 9493cfbede..7348b38ccd 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListItem.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversationlist/ConversationListItem.java @@ -167,7 +167,13 @@ public final class ConversationListItem extends ConstraintLayout super.onLayout(changed, left, top, right, bottom); contactPhotoImage.getHitRect(newConversationAvatarTouchDelegateBounds); - newConversationAvatarTouchDelegateBounds.left = left; + + if (getLayoutDirection() == LAYOUT_DIRECTION_LTR) { + newConversationAvatarTouchDelegateBounds.left = left; + } else { + newConversationAvatarTouchDelegateBounds.right = right; + } + newConversationAvatarTouchDelegateBounds.top = top; newConversationAvatarTouchDelegateBounds.bottom = bottom; diff --git a/app/src/main/res/layout/quote_view.xml b/app/src/main/res/layout/quote_view.xml index bf6633f8e0..8b75db510c 100644 --- a/app/src/main/res/layout/quote_view.xml +++ b/app/src/main/res/layout/quote_view.xml @@ -119,10 +119,11 @@ tools:visibility="visible" /> -