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

Commit 30bea73d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Notification Content Cut Off] use max child height in ConversationLayout" into main

parents b94acf5e 6be7dbbb
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);