Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c2fd6a1 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an issue where the message could be empty

We're now making sure that the last message can never be too short
and we will therefore always see at least one message

Bug: 111576198
Test: Send message with "Text\r\n"
Change-Id: I4db0708511c45710540653501c845df5dd813545
parent b76b6c5a
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -111,14 +111,16 @@ public class MessagingLinearLayout extends ViewGroup {
            final int childHeight = child.getMeasuredHeight();
            int newHeight = Math.max(totalHeight, totalHeight + childHeight + lp.topMargin +
                    lp.bottomMargin + spacing);
            first = false;
            int measureType = MessagingChild.MEASURED_NORMAL;
            if (messagingChild != null) {
                measureType = messagingChild.getMeasuredType();
                linesRemaining -= messagingChild.getConsumedLines();
            }
            boolean isShortened = measureType == MessagingChild.MEASURED_SHORTENED;
            boolean isTooSmall = measureType == MessagingChild.MEASURED_TOO_SMALL;

            // We never measure the first item as too small, we want to at least show something.
            boolean isTooSmall = measureType == MessagingChild.MEASURED_TOO_SMALL && !first;
            boolean isShortened = measureType == MessagingChild.MEASURED_SHORTENED
                    || measureType == MessagingChild.MEASURED_TOO_SMALL && first;
            if (newHeight <= targetHeight && !isTooSmall) {
                totalHeight = newHeight;
                measuredWidth = Math.max(measuredWidth,
@@ -131,6 +133,7 @@ public class MessagingLinearLayout extends ViewGroup {
            } else {
                break;
            }
            first = false;
        }

        setMeasuredDimension(