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

Commit 0a27c486 authored by Adam Powell's avatar Adam Powell
Browse files

Fix measurement bug in keyguard/MultiPaneChallengeLayout

Change-Id: Ifbcd32281f06e6c53e573998e7085d7d0542acac
parent b0ed8bdb
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -221,30 +221,35 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
            if (lp.centerWithinArea > 0) {
                if (mOrientation == HORIZONTAL) {
                    adjustedWidthSpec = MeasureSpec.makeMeasureSpec(
                            (int) (width * lp.centerWithinArea + 0.5f), MeasureSpec.EXACTLY);
                    adjustedHeightSpec = heightSpec;
                            (int) ((width - widthUsed) * lp.centerWithinArea + 0.5f),
                            MeasureSpec.EXACTLY);
                    adjustedHeightSpec = MeasureSpec.makeMeasureSpec(
                            MeasureSpec.getSize(heightSpec) - heightUsed, MeasureSpec.EXACTLY);
                } else {
                    adjustedWidthSpec = widthSpec;
                    adjustedWidthSpec = MeasureSpec.makeMeasureSpec(
                            MeasureSpec.getSize(widthSpec) - widthUsed, MeasureSpec.EXACTLY);
                    adjustedHeightSpec = MeasureSpec.makeMeasureSpec(
                            (int) (height * lp.centerWithinArea + 0.5f), MeasureSpec.EXACTLY);
                            (int) ((height - heightUsed) * lp.centerWithinArea + 0.5f),
                            MeasureSpec.EXACTLY);
                }
            } else {
                adjustedWidthSpec = widthSpec;
                adjustedHeightSpec = heightSpec;
                adjustedWidthSpec = MeasureSpec.makeMeasureSpec(
                        MeasureSpec.getSize(widthSpec) - widthUsed, MeasureSpec.EXACTLY);
                adjustedHeightSpec = MeasureSpec.makeMeasureSpec(
                        MeasureSpec.getSize(heightSpec) - heightUsed, MeasureSpec.EXACTLY);
            }
            if (lp.maxWidth >= 0) {
                adjustedWidthSpec = MeasureSpec.makeMeasureSpec(
                        Math.min(lp.maxWidth, MeasureSpec.getSize(widthSpec)),
                        Math.min(lp.maxWidth, MeasureSpec.getSize(adjustedWidthSpec)),
                        MeasureSpec.EXACTLY);
            }
            if (lp.maxHeight >= 0) {
                adjustedHeightSpec = MeasureSpec.makeMeasureSpec(
                        Math.min(lp.maxHeight, MeasureSpec.getSize(heightSpec)),
                        Math.min(lp.maxHeight, MeasureSpec.getSize(adjustedHeightSpec)),
                        MeasureSpec.EXACTLY);
            }

            measureChildWithMargins(child, adjustedWidthSpec, widthUsed,
                    adjustedHeightSpec, heightUsed);
            measureChildWithMargins(child, adjustedWidthSpec, 0, adjustedHeightSpec, 0);
        }
    }