From d4a20510ec21bb6374b2b84c7648d65efae135e9 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Thu, 17 Jun 2021 23:39:13 -0400 Subject: [PATCH] close #1339 --- .../directmessages/DirectItemViewHolder.java | 24 +++++++++++-------- .../customviews/ChatMessageLayout.java | 19 +++++++++++---- .../main/res/layout/layout_dm_reel_share.xml | 11 +++++---- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java index 610acc7c..f61c45ef 100644 --- a/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java +++ b/app/src/main/java/awais/instagrabber/adapters/viewholder/directmessages/DirectItemViewHolder.java @@ -133,16 +133,20 @@ public abstract class DirectItemViewHolder extends RecyclerView.ViewHolder imple setGroupUserDetails(item, messageDirection); setBackground(messageDirection); setMessageInfo(item, messageDirection); - if (itemType == DirectItemType.REEL_SHARE) { - containerLayoutParams.setMarginStart(0); - containerLayoutParams.setMarginEnd(0); - } - if (itemType == DirectItemType.TEXT || itemType == DirectItemType.LINK || itemType == DirectItemType.UNKNOWN) { - binding.messageInfo.setPadding(0, 0, dmRadius, dmRadiusSmall); - } else { - if (showMessageInfo()) { - binding.messageInfo.setPadding(0, 0, messageInfoPaddingSmall, dmRadiusSmall); - } + switch (itemType) { + case REEL_SHARE: + case STORY_SHARE: // i think they could have texts? +// containerLayoutParams.setMarginStart(0); +// containerLayoutParams.setMarginEnd(0); + case TEXT: + case LINK: + case UNKNOWN: + binding.messageInfo.setPadding(0, 0, dmRadius, dmRadiusSmall); + break; + default: + if (showMessageInfo()) { + binding.messageInfo.setPadding(0, 0, messageInfoPaddingSmall, dmRadiusSmall); + } } setupReply(item, messageDirection); setReactions(item, position); diff --git a/app/src/main/java/awais/instagrabber/customviews/ChatMessageLayout.java b/app/src/main/java/awais/instagrabber/customviews/ChatMessageLayout.java index c0568a70..50d8a54d 100644 --- a/app/src/main/java/awais/instagrabber/customviews/ChatMessageLayout.java +++ b/app/src/main/java/awais/instagrabber/customviews/ChatMessageLayout.java @@ -9,6 +9,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.ConstraintLayout; import awais.instagrabber.R; @@ -74,7 +75,6 @@ public class ChatMessageLayout extends FrameLayout { if (firstChild == null) return; final int firstChildId = firstChild.getId(); - if (firstChildId == R.id.reel_share_container) return; int availableWidth = widthSize - getPaddingLeft() - getPaddingRight(); // int availableHeight = heightSize - getPaddingTop() - getPaddingBottom(); @@ -100,13 +100,24 @@ public class ChatMessageLayout extends FrameLayout { } else { int viewPartMainLineCount = 1; float viewPartMainLastLineWidth = 0; + final TextView textMessage; if (firstChild instanceof TextView) { - viewPartMainLineCount = ((TextView) firstChild).getLineCount(); + textMessage = (TextView) firstChild; + } + else if (firstChildId == R.id.reel_share_container) { + textMessage = (TextView) ((ConstraintLayout) firstChild).getChildAt(5); + } + else if (firstChildId == R.id.story_container) { + textMessage = (TextView) ((ConstraintLayout) firstChild).getChildAt(2); + } + else textMessage = null; + if (textMessage != null) { + viewPartMainLineCount = textMessage.getLineCount(); viewPartMainLastLineWidth = viewPartMainLineCount > 0 - ? ((TextView) firstChild).getLayout().getLineWidth(viewPartMainLineCount - 1) + ? textMessage.getLayout().getLineWidth(viewPartMainLineCount - 1) : 0; // also include start left padding - viewPartMainLastLineWidth += firstChild.getPaddingLeft(); + viewPartMainLastLineWidth += textMessage.getPaddingLeft(); } final float lastLineWithInfoWidth = viewPartMainLastLineWidth + viewPartInfoWidth; diff --git a/app/src/main/res/layout/layout_dm_reel_share.xml b/app/src/main/res/layout/layout_dm_reel_share.xml index 2d4f9db7..2895cd2a 100644 --- a/app/src/main/res/layout/layout_dm_reel_share.xml +++ b/app/src/main/res/layout/layout_dm_reel_share.xml @@ -72,12 +72,13 @@