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

Commit e8439367 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Don't overwrite vertical and horizontal offsets unless explicit" into nyc-dev

parents 22d91b0e d7b25992
Loading
Loading
Loading
Loading
+21 −15
Original line number Diff line number Diff line
@@ -181,8 +181,10 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
    private View mAnchorView;
    private View mShownAnchorView;
    private int mLastPosition;
    private int mInitXOffset;
    private int mInitYOffset;
    private boolean mHasXOffset;
    private boolean mHasYOffset;
    private int mXOffset;
    private int mYOffset;
    private boolean mForceShowIcon;
    private boolean mShowTitle;
    private Callback mPresenterCallback;
@@ -379,9 +381,6 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
            parentView = null;
        }

        final int x;
        final int y;
        final Rect epicenterBounds;
        if (parentView != null) {
            // This menu is a cascading submenu anchored to a parent view.
            popupWindow.setTouchModal(false);
@@ -401,6 +400,7 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey

            // By now, mDropDownGravity is the resolved absolute gravity, so
            // this should work in both LTR and RTL.
            final int x;
            if ((mDropDownGravity & Gravity.RIGHT) == Gravity.RIGHT) {
                if (showOnRight) {
                    x = parentOffsetLeft + menuWidth;
@@ -415,17 +415,21 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
                }
            }

            y = parentOffsetTop;
            epicenterBounds = null;
        } else {
            x = mInitXOffset;
            y = mInitYOffset;
            epicenterBounds = getEpicenterBounds();
        }

            popupWindow.setHorizontalOffset(x);

            final int y = parentOffsetTop;
            popupWindow.setVerticalOffset(y);
        } else {
            if (mHasXOffset) {
                popupWindow.setHorizontalOffset(mXOffset);
            }
            if (mHasYOffset) {
                popupWindow.setVerticalOffset(mYOffset);
            }
            final Rect epicenterBounds = getEpicenterBounds();
            popupWindow.setEpicenterBounds(epicenterBounds);
        }


        final CascadingMenuInfo menuInfo = new CascadingMenuInfo(popupWindow, menu, mLastPosition);
        mShowingMenus.add(menuInfo);
@@ -712,12 +716,14 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey

    @Override
    public void setHorizontalOffset(int x) {
        mInitXOffset = x;
        mHasXOffset = true;
        mXOffset = x;
    }

    @Override
    public void setVerticalOffset(int y) {
        mInitYOffset = y;
        mHasYOffset = true;
        mYOffset = y;
    }

    @Override
+5 −7
Original line number Diff line number Diff line
@@ -108,8 +108,6 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On

    private int mDropDownGravity = Gravity.NO_GRAVITY;

    private int mXOffset;
    private int mYOffset;
    private boolean mShowTitle;

    public StandardMenuPopup(Context context, MenuBuilder menu, View anchorView, int popupStyleAttr,
@@ -177,8 +175,6 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On

        mPopup.setContentWidth(mContentWidth);
        mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
        mPopup.setHorizontalOffset(mXOffset);
        mPopup.setVerticalOffset(mYOffset);
        mPopup.setEpicenterBounds(getEpicenterBounds());
        mPopup.show();

@@ -276,7 +272,9 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On
            mMenu.close(false /* closeAllMenus */);

            // Show the new sub-menu popup at the same location as this popup.
            if (subPopup.tryShow(mXOffset, mYOffset)) {
            final int horizontalOffset = mPopup.getHorizontalOffset();
            final int verticalOffset = mPopup.getVerticalOffset();
            if (subPopup.tryShow(horizontalOffset, verticalOffset)) {
                if (mPresenterCallback != null) {
                    mPresenterCallback.onOpenSubMenu(subMenu);
                }
@@ -338,12 +336,12 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On

    @Override
    public void setHorizontalOffset(int x) {
        mXOffset = x;
        mPopup.setHorizontalOffset(x);
    }

    @Override
    public void setVerticalOffset(int y) {
        mYOffset = y;
        mPopup.setVerticalOffset(y);
    }

    @Override