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 mAnchorView;
|
||||||
private View mShownAnchorView;
|
private View mShownAnchorView;
|
||||||
private int mLastPosition;
|
private int mLastPosition;
|
||||||
private int mInitXOffset;
|
private boolean mHasXOffset;
|
||||||
private int mInitYOffset;
|
private boolean mHasYOffset;
|
||||||
|
private int mXOffset;
|
||||||
|
private int mYOffset;
|
||||||
private boolean mForceShowIcon;
|
private boolean mForceShowIcon;
|
||||||
private boolean mShowTitle;
|
private boolean mShowTitle;
|
||||||
private Callback mPresenterCallback;
|
private Callback mPresenterCallback;
|
||||||
@@ -379,9 +381,6 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
|
|||||||
parentView = null;
|
parentView = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int x;
|
|
||||||
final int y;
|
|
||||||
final Rect epicenterBounds;
|
|
||||||
if (parentView != null) {
|
if (parentView != null) {
|
||||||
// This menu is a cascading submenu anchored to a parent view.
|
// This menu is a cascading submenu anchored to a parent view.
|
||||||
popupWindow.setTouchModal(false);
|
popupWindow.setTouchModal(false);
|
||||||
@@ -401,6 +400,7 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
|
|||||||
|
|
||||||
// By now, mDropDownGravity is the resolved absolute gravity, so
|
// By now, mDropDownGravity is the resolved absolute gravity, so
|
||||||
// this should work in both LTR and RTL.
|
// this should work in both LTR and RTL.
|
||||||
|
final int x;
|
||||||
if ((mDropDownGravity & Gravity.RIGHT) == Gravity.RIGHT) {
|
if ((mDropDownGravity & Gravity.RIGHT) == Gravity.RIGHT) {
|
||||||
if (showOnRight) {
|
if (showOnRight) {
|
||||||
x = parentOffsetLeft + menuWidth;
|
x = parentOffsetLeft + menuWidth;
|
||||||
@@ -415,17 +415,21 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y = parentOffsetTop;
|
popupWindow.setHorizontalOffset(x);
|
||||||
epicenterBounds = null;
|
|
||||||
|
final int y = parentOffsetTop;
|
||||||
|
popupWindow.setVerticalOffset(y);
|
||||||
} else {
|
} else {
|
||||||
x = mInitXOffset;
|
if (mHasXOffset) {
|
||||||
y = mInitYOffset;
|
popupWindow.setHorizontalOffset(mXOffset);
|
||||||
epicenterBounds = getEpicenterBounds();
|
}
|
||||||
|
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);
|
final CascadingMenuInfo menuInfo = new CascadingMenuInfo(popupWindow, menu, mLastPosition);
|
||||||
mShowingMenus.add(menuInfo);
|
mShowingMenus.add(menuInfo);
|
||||||
@@ -712,12 +716,14 @@ final class CascadingMenuPopup extends MenuPopup implements MenuPresenter, OnKey
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHorizontalOffset(int x) {
|
public void setHorizontalOffset(int x) {
|
||||||
mInitXOffset = x;
|
mHasXOffset = true;
|
||||||
|
mXOffset = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVerticalOffset(int y) {
|
public void setVerticalOffset(int y) {
|
||||||
mInitYOffset = y;
|
mHasYOffset = true;
|
||||||
|
mYOffset = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -108,8 +108,6 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On
|
|||||||
|
|
||||||
private int mDropDownGravity = Gravity.NO_GRAVITY;
|
private int mDropDownGravity = Gravity.NO_GRAVITY;
|
||||||
|
|
||||||
private int mXOffset;
|
|
||||||
private int mYOffset;
|
|
||||||
private boolean mShowTitle;
|
private boolean mShowTitle;
|
||||||
|
|
||||||
public StandardMenuPopup(Context context, MenuBuilder menu, View anchorView, int popupStyleAttr,
|
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.setContentWidth(mContentWidth);
|
||||||
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
|
mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||||
mPopup.setHorizontalOffset(mXOffset);
|
|
||||||
mPopup.setVerticalOffset(mYOffset);
|
|
||||||
mPopup.setEpicenterBounds(getEpicenterBounds());
|
mPopup.setEpicenterBounds(getEpicenterBounds());
|
||||||
mPopup.show();
|
mPopup.show();
|
||||||
|
|
||||||
@@ -276,7 +272,9 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On
|
|||||||
mMenu.close(false /* closeAllMenus */);
|
mMenu.close(false /* closeAllMenus */);
|
||||||
|
|
||||||
// Show the new sub-menu popup at the same location as this popup.
|
// 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) {
|
if (mPresenterCallback != null) {
|
||||||
mPresenterCallback.onOpenSubMenu(subMenu);
|
mPresenterCallback.onOpenSubMenu(subMenu);
|
||||||
}
|
}
|
||||||
@@ -338,12 +336,12 @@ final class StandardMenuPopup extends MenuPopup implements OnDismissListener, On
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHorizontalOffset(int x) {
|
public void setHorizontalOffset(int x) {
|
||||||
mXOffset = x;
|
mPopup.setHorizontalOffset(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVerticalOffset(int y) {
|
public void setVerticalOffset(int y) {
|
||||||
mYOffset = y;
|
mPopup.setVerticalOffset(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user