| Index: ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java
|
| diff --git a/ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java b/ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java
|
| index 45b799e33ece7d4e5a067421924f246b75afcbf4..febea40147149612074f2a82c06037d65d9ab115 100644
|
| --- a/ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java
|
| +++ b/ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java
|
| @@ -30,10 +30,6 @@ public class DropdownPopupWindow extends ListPopupWindow {
|
| private final Context mContext;
|
| private final ViewAndroidDelegate mViewAndroidDelegate;
|
| private final View mAnchorView;
|
| - private float mAnchorWidth;
|
| - private float mAnchorHeight;
|
| - private float mAnchorX;
|
| - private float mAnchorY;
|
| private boolean mRtl;
|
| private int mInitialSelection = -1;
|
| private OnLayoutChangeListener mLayoutChangeListener;
|
| @@ -44,14 +40,16 @@ public class DropdownPopupWindow extends ListPopupWindow {
|
| /**
|
| * Creates an DropdownPopupWindow with specified parameters.
|
| * @param context Application context.
|
| + * @param anchorView
|
| * @param viewAndroidDelegate View delegate used to add and remove views.
|
| */
|
| - public DropdownPopupWindow(Context context, ViewAndroidDelegate viewAndroidDelegate) {
|
| + public DropdownPopupWindow(Context context, View anchorView, float anchorWidth,
|
| + ViewAndroidDelegate viewAndroidDelegate) {
|
| super(context, null, 0, R.style.DropdownPopupWindow);
|
| mContext = context;
|
| + mAnchorView = anchorView;
|
| mViewAndroidDelegate = viewAndroidDelegate;
|
|
|
| - mAnchorView = mViewAndroidDelegate.acquireAnchorView();
|
| mAnchorView.setId(R.id.dropdown_popup_window);
|
| mAnchorView.setTag(this);
|
|
|
| @@ -63,7 +61,6 @@ public class DropdownPopupWindow extends ListPopupWindow {
|
| }
|
| };
|
| mAnchorView.addOnLayoutChangeListener(mLayoutChangeListener);
|
| -
|
| super.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
| @Override
|
| public void onDismiss() {
|
| @@ -80,25 +77,22 @@ public class DropdownPopupWindow extends ListPopupWindow {
|
| Rect originalPadding = new Rect();
|
| getBackground().getPadding(originalPadding);
|
| setVerticalOffset(-originalPadding.top);
|
| - }
|
|
|
| - /**
|
| - * Sets the location and the size of the anchor view that the DropdownPopupWindow will use to
|
| - * attach itself. Calling this method can cause a layout change, so the adapter should not be
|
| - * null.
|
| - * @param x X coordinate of the top left corner of the anchor view.
|
| - * @param y Y coordinate of the top left corner of the anchor view.
|
| - * @param width The width of the anchor view.
|
| - * @param height The height of the anchor view.
|
| - */
|
| - public void setAnchorRect(float x, float y, float width, float height) {
|
| - mAnchorWidth = width;
|
| - mAnchorHeight = height;
|
| - mAnchorX = x;
|
| - mAnchorY = y;
|
| - if (mAnchorView != null) {
|
| - mViewAndroidDelegate.setAnchorViewPosition(mAnchorView, mAnchorX, mAnchorY,
|
| - mAnchorWidth, mAnchorHeight);
|
| + // An ugly hack to keep the popup from expanding on top of the keyboard.
|
| + setInputMethodMode(INPUT_METHOD_NEEDED);
|
| +
|
| + int contentWidth = measureContentWidth();
|
| + float contentWidthInDip = contentWidth
|
| + / mContext.getResources().getDisplayMetrics().density;
|
| + if (contentWidthInDip + originalPadding.left + originalPadding.right > anchorWidth) {
|
| + setContentWidth(contentWidth);
|
| + final Rect displayFrame = new Rect();
|
| + mAnchorView.getWindowVisibleDisplayFrame(displayFrame);
|
| + if (getWidth() > displayFrame.width()) {
|
| + setWidth(displayFrame.width());
|
| + }
|
| + } else {
|
| + setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
|
| }
|
| }
|
|
|
| @@ -118,26 +112,6 @@ public class DropdownPopupWindow extends ListPopupWindow {
|
| */
|
| @Override
|
| public void show() {
|
| - // An ugly hack to keep the popup from expanding on top of the keyboard.
|
| - setInputMethodMode(INPUT_METHOD_NEEDED);
|
| -
|
| - int contentWidth = measureContentWidth();
|
| - float contentWidthInDip = contentWidth
|
| - / mContext.getResources().getDisplayMetrics().density;
|
| - Rect padding = new Rect();
|
| - getBackground().getPadding(padding);
|
| - if (contentWidthInDip + padding.left + padding.right > mAnchorWidth) {
|
| - setContentWidth(contentWidth);
|
| - final Rect displayFrame = new Rect();
|
| - mAnchorView.getWindowVisibleDisplayFrame(displayFrame);
|
| - if (getWidth() > displayFrame.width()) {
|
| - setWidth(displayFrame.width());
|
| - }
|
| - } else {
|
| - setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
|
| - }
|
| - mViewAndroidDelegate.setAnchorViewPosition(mAnchorView, mAnchorX, mAnchorY, mAnchorWidth,
|
| - mAnchorHeight);
|
| boolean wasShowing = isShowing();
|
| super.show();
|
| getListView().setDividerHeight(0);
|
|
|