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

Commit be570ce9 authored by Selim Cinek's avatar Selim Cinek
Browse files

Measuring the content views always at their specified size

Before we were limiting the height of the contentViews with
the height of the size that was given to us. When the
shade is collapsed, this actually made them measure
with size 0 in cases where we had a notch.
In rare cases, the measuring caching could lead to oddities
where content would be invisible.
We're now measuring them uniformly.
As a side effect, this measuring might also fix another bug,
where the notification is the full height of the view.

Test: add all sorts of notifications with notch, observe normal layout
Change-Id: I714f34f1564549952423ca51751cfe37ed45d991
Fixes: 73952748
Fixes: 78144261
parent 150bafd2
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ public class NotificationContentView extends FrameLayout {
        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
        boolean hasFixedHeight = heightMode == MeasureSpec.EXACTLY;
        boolean isHeightLimited = heightMode == MeasureSpec.AT_MOST;
        int maxSize = Integer.MAX_VALUE;
        int maxSize = Integer.MAX_VALUE / 2;
        int width = MeasureSpec.getSize(widthMeasureSpec);
        if (hasFixedHeight || isHeightLimited) {
            maxSize = MeasureSpec.getSize(heightMeasureSpec);
@@ -189,17 +189,15 @@ public class NotificationContentView extends FrameLayout {
            if (mExpandedSmartReplyView != null) {
                notificationMaxHeight += mExpandedSmartReplyView.getHeightUpperLimit();
            }
            int size = Math.min(maxSize, notificationMaxHeight);
            int size = notificationMaxHeight;
            ViewGroup.LayoutParams layoutParams = mExpandedChild.getLayoutParams();
            boolean useExactly = false;
            if (layoutParams.height >= 0) {
                // An actual height is set
                size = Math.min(maxSize, layoutParams.height);
                size = Math.min(size, layoutParams.height);
                useExactly = true;
            }
            int spec = size == Integer.MAX_VALUE
                    ? MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
                    : MeasureSpec.makeMeasureSpec(size, useExactly
            int spec = MeasureSpec.makeMeasureSpec(size, useExactly
                            ? MeasureSpec.EXACTLY
                            : MeasureSpec.AT_MOST);
            measureChildWithMargins(mExpandedChild, widthMeasureSpec, 0, spec, 0);
@@ -207,7 +205,7 @@ public class NotificationContentView extends FrameLayout {
        }
        if (mContractedChild != null) {
            int heightSpec;
            int size = Math.min(maxSize, mSmallHeight);
            int size = mSmallHeight;
            ViewGroup.LayoutParams layoutParams = mContractedChild.getLayoutParams();
            boolean useExactly = false;
            if (layoutParams.height >= 0) {
@@ -241,7 +239,7 @@ public class NotificationContentView extends FrameLayout {
        if (mHeadsUpChild != null) {
            int maxHeight = mHeadsUpHeight;
            maxHeight += mHeadsUpWrapper.getExtraMeasureHeight();
            int size = Math.min(maxSize, maxHeight);
            int size = maxHeight;
            ViewGroup.LayoutParams layoutParams = mHeadsUpChild.getLayoutParams();
            boolean useExactly = false;
            if (layoutParams.height >= 0) {
@@ -263,11 +261,11 @@ public class NotificationContentView extends FrameLayout {
                        MeasureSpec.EXACTLY);
            }
            mSingleLineView.measure(singleLineWidthSpec,
                    MeasureSpec.makeMeasureSpec(maxSize, MeasureSpec.AT_MOST));
                    MeasureSpec.makeMeasureSpec(mNotificationMaxHeight, MeasureSpec.AT_MOST));
            maxChildHeight = Math.max(maxChildHeight, mSingleLineView.getMeasuredHeight());
        }
        if (mAmbientChild != null) {
            int size = Math.min(maxSize, mNotificationAmbientHeight);
            int size = mNotificationAmbientHeight;
            ViewGroup.LayoutParams layoutParams = mAmbientChild.getLayoutParams();
            boolean useExactly = false;
            if (layoutParams.height >= 0) {
@@ -281,7 +279,7 @@ public class NotificationContentView extends FrameLayout {
            maxChildHeight = Math.max(maxChildHeight, mAmbientChild.getMeasuredHeight());
        }
        if (mAmbientSingleLineChild != null) {
            int size = Math.min(maxSize, mNotificationAmbientHeight);
            int size = mNotificationAmbientHeight;
            ViewGroup.LayoutParams layoutParams = mAmbientSingleLineChild.getLayoutParams();
            boolean useExactly = false;
            if (layoutParams.height >= 0) {