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

Commit 6be7dbbb authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

[Notification Content Cut Off] use max child height in ConversationLayout

FrameLayout measures its match_parent children twice when any of FLs dimension is unspecified.
It also sets its dimension before the match parent childrens second measurement.
Since View#measure is not immutable, children can have a different dimensions.
When the biggest children has bigger height than its first measurement, its content is going to be cut off.
We calculate the maxHeight in this CL and set it to fix cut off issue.

Bug: 324537506
Flag: android.widget.flags.conversation_layout_use_maximum_child_height
Test: Manual. Disable child invalidation and optimize linearlayout. Post a group notification with short choices and trigger onMeasure twice by orientation change. There shouldn't be any cut off.
Change-Id: I02be31dea83a217247c2e0dff05ceaa88efb2dee
parent 102f1f0c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -57,3 +57,13 @@ flag {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "conversation_layout_use_maximum_child_height"
  namespace: "systemui"
  description: "MessagingChild always needs to be measured during MessagingLinearLayout onMeasure."
  bug: "324537506"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}
 No newline at end of file
+34 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.widget;

import static android.widget.flags.Flags.conversationLayoutUseMaximumChildHeight;

import static com.android.internal.widget.MessagingGroup.IMAGE_DISPLAY_LOCATION_EXTERNAL;
import static com.android.internal.widget.MessagingGroup.IMAGE_DISPLAY_LOCATION_INLINE;

@@ -1407,6 +1409,38 @@ public class ConversationLayout extends FrameLayout
        }
    }


    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        // ConversationLayout needs to set its height to its biggest child to show the content
        // properly.
        // FrameLayout measures its match_parent children twice when any of FLs dimension is not
        // specified. However, its sets its own dimensions before the second measurement pass.
        // Content CutOff happens when children have bigger height on its second measurement.
        if (conversationLayoutUseMaximumChildHeight()) {
            int maxHeight = getMeasuredHeight();
            final int count = getChildCount();

            for (int i = 0; i < count; i++) {
                final View child = getChildAt(i);
                if (child == null || child.getVisibility() == GONE) {
                    continue;
                }

                final LayoutParams lp = (LayoutParams) child.getLayoutParams();
                maxHeight = Math.max(maxHeight,
                        child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin);
            }

            maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
            if (maxHeight != getMeasuredHeight()) {
                setMeasuredDimension(getMeasuredWidth(), maxHeight);
            }
        }
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);