1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 05:16:58 +00:00

Include textview left padding while calculating last line width in text messages. For austinhuang0131/barinsta#1222

This commit is contained in:
Ammar Githam 2021-05-10 23:03:37 +09:00
parent 3b41cd78bd
commit 79fe697167
3 changed files with 30 additions and 4 deletions

View File

@ -105,12 +105,15 @@ public class ChatMessageLayout extends FrameLayout {
viewPartMainLastLineWidth = viewPartMainLineCount > 0
? ((TextView) firstChild).getLayout().getLineWidth(viewPartMainLineCount - 1)
: 0;
// also include start left padding
viewPartMainLastLineWidth += firstChild.getPaddingLeft();
}
if (viewPartMainLineCount > 1 && !(viewPartMainLastLineWidth + viewPartInfoWidth > viewPartMain.getMeasuredWidth())) {
final float lastLineWithInfoWidth = viewPartMainLastLineWidth + viewPartInfoWidth;
if (viewPartMainLineCount > 1 && lastLineWithInfoWidth <= viewPartMain.getMeasuredWidth()) {
widthSize += viewPartMainWidth;
heightSize += viewPartMainHeight;
} else if (viewPartMainLineCount > 1 && (viewPartMainLastLineWidth + viewPartInfoWidth > availableWidth)) {
} else if (viewPartMainLineCount > 1 && (lastLineWithInfoWidth > availableWidth)) {
widthSize += viewPartMainWidth;
heightSize += viewPartMainHeight + viewPartInfoHeight;
} else if (viewPartMainLineCount == 1 && (viewPartMainWidth + viewPartInfoWidth > availableWidth)) {
@ -120,6 +123,16 @@ public class ChatMessageLayout extends FrameLayout {
heightSize += viewPartMainHeight;
widthSize += viewPartMainWidth + viewPartInfoWidth;
}
// if (isInEditMode()) {
// TextView wDebugView = (TextView) ((ViewGroup) this.getParent()).findViewWithTag("debug");
// wDebugView.setText(lastLineWithInfoWidth
// + "\n" + availableWidth
// + "\n" + viewPartMain.getMeasuredWidth()
// + "\n" + (lastLineWithInfoWidth <= viewPartMain.getMeasuredWidth())
// + "\n" + (lastLineWithInfoWidth > availableWidth)
// + "\n" + (viewPartMainWidth + viewPartInfoWidth > availableWidth));
// }
}
setMeasuredDimension(widthSize, heightSize);
super.onMeasure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY));

View File

@ -139,7 +139,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_height="200dp"
tools:layout_width="100dp" />
tools:layout_width="100dp">
<!--<include layout="@layout/layout_dm_text" />-->
</FrameLayout>
<LinearLayout
android:id="@+id/message_info"
@ -176,6 +178,17 @@
</awais.instagrabber.customviews.ChatMessageLayout>
<!--<TextView-->
<!-- android:tag="debug"-->
<!-- android:textColor="@color/white"-->
<!-- android:layout_width="0dp"-->
<!-- android:visibility="visible"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:background="@color/black"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"/>-->
<FrameLayout
android:id="@+id/reactions_wrapper"
android:layout_width="0dp"

View File

@ -10,4 +10,4 @@
android:paddingBottom="@dimen/dm_message_card_radius_small"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
android:textColor="@color/white"
tools:text="Text message" />
tools:text="So here you can see the timestamp overlaps lol tt tt tt tt tt tt tt tt tt tt t" />