Merge "Don't overwrite vertical and horizontal offsets unless explicit" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e84393674d
@@ -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;
|
||||
popupWindow.setHorizontalOffset(x);
|
||||
|
||||
final int y = parentOffsetTop;
|
||||
popupWindow.setVerticalOffset(y);
|
||||
} else {
|
||||
x = mInitXOffset;
|
||||
y = mInitYOffset;
|
||||
epicenterBounds = getEpicenterBounds();
|
||||
if (mHasXOffset) {
|
||||
popupWindow.setHorizontalOffset(mXOffset);
|
||||
}
|
||||
if (mHasYOffset) {
|
||||
popupWindow.setVerticalOffset(mYOffset);
|
||||
}
|
||||
final Rect epicenterBounds = getEpicenterBounds();
|
||||
popupWindow.setEpicenterBounds(epicenterBounds);
|
||||
}
|
||||
|
||||
popupWindow.setHorizontalOffset(x);
|
||||
popupWindow.setVerticalOffset(y);
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user