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

Commit 446b4e72 authored by Rob Carr's avatar Rob Carr Committed by Android (Google) Code Review
Browse files

Merge "PopupWindow. Don't use -1 width/height for calculations." into nyc-dev

parents 0d723a2a f6e801da
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -1512,6 +1512,24 @@ public class PopupWindow {
        outParams.x = drawingLocation[0] + xOffset;
        outParams.y = drawingLocation[1] + anchorHeight + yOffset;

        // Let the window manager know to align the top to y.
        outParams.gravity = Gravity.LEFT | Gravity.TOP;
        outParams.width = width;
        outParams.height = height;

        // If width or height is unspecified. We can leave it to the window manager to match
        // to the parent size, but for our local purposes of calculating positioning, we need
        // to fill in real width and height values.
        final Rect displayFrame = new Rect();
        anchor.getWindowVisibleDisplayFrame(displayFrame);
        if (width < 0) {
            width = displayFrame.right - displayFrame.left;
        }
        if (height < 0) {
            height = displayFrame.bottom - displayFrame.top;
        }


        // If we need to adjust for gravity RIGHT, align to the bottom-right
        // corner of the anchor (still accounting for offsets).
        final int hgrav = Gravity.getAbsoluteGravity(gravity, anchor.getLayoutDirection())
@@ -1520,17 +1538,9 @@ public class PopupWindow {
            outParams.x -= width - anchorWidth;
        }

        // Let the window manager know to align the top to y.
        outParams.gravity = Gravity.LEFT | Gravity.TOP;
        outParams.width = width;
        outParams.height = height;

        final int[] screenLocation = mTmpScreenLocation;
        anchor.getLocationOnScreen(screenLocation);

        final Rect displayFrame = new Rect();
        anchor.getWindowVisibleDisplayFrame(displayFrame);

        // First, attempt to fit the popup vertically without resizing.
        final boolean fitsVertical = tryFitVertical(outParams, yOffset, height,
                anchorHeight, drawingLocation[1], screenLocation[1], displayFrame.top,
@@ -2114,10 +2124,10 @@ public class PopupWindow {

        // If an explicit width/height has not specified, use the most recent
        // explicitly specified value (either from setWidth/Height or update).
        if (width == -1) {
        if (width < 0) {
            width = mWidth;
        }
        if (height == -1) {
        if (height < 0) {
            height = mHeight;
        }