Commit 2d616c68 authored by rouslan's avatar rouslan Committed by Commit bot

[android] Hide <select> dropdown on outside tap.

Outside tap should hide <select> dropdowns, but not dropdowns associated
with input fields. Tapping on an input field should not hide the
associated autofill or password generation popup.

BUG=430543

Review URL: https://codereview.chromium.org/932493003

Cr-Commit-Position: refs/heads/master@{#316641}
parent 12fcf61b
...@@ -66,6 +66,7 @@ public class PasswordGenerationPopupBridge implements AdapterView.OnItemClickLis ...@@ -66,6 +66,7 @@ public class PasswordGenerationPopupBridge implements AdapterView.OnItemClickLis
mPopup = new DropdownPopupWindow(mContext, containerViewDelegate); mPopup = new DropdownPopupWindow(mContext, containerViewDelegate);
mPopup.setOnItemClickListener(this); mPopup.setOnItemClickListener(this);
mPopup.setOnDismissListener(this); mPopup.setOnDismissListener(this);
mPopup.disableHideOnOutsideTap();
} }
mAnchorWidth = 0; mAnchorWidth = 0;
} }
......
...@@ -134,7 +134,26 @@ public class DropdownPopupWindow extends ListPopupWindow { ...@@ -134,7 +134,26 @@ public class DropdownPopupWindow extends ListPopupWindow {
getListView().setDividerHeight(0); getListView().setDividerHeight(0);
ApiCompatibilityUtils.setLayoutDirection(getListView(), ApiCompatibilityUtils.setLayoutDirection(getListView(),
mRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR); mRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
}
@Override
public void setOnDismissListener(PopupWindow.OnDismissListener listener) {
mOnDismissListener = listener;
}
/**
* Sets the text direction in the dropdown. Should be called before show().
* @param isRtl If true, then dropdown text direciton is right to left.
*/
public void setRtl(boolean isRtl) {
mRtl = isRtl;
}
/**
* Disable hiding on outside tap so that tapping on a text input field associated with the popup
* will not hide the popup.
*/
public void disableHideOnOutsideTap() {
// HACK: The ListPopupWindow's mPopup automatically dismisses on an outside tap. There's // HACK: The ListPopupWindow's mPopup automatically dismisses on an outside tap. There's
// no way to override it or prevent it, except reaching into ListPopupWindow's hidden // no way to override it or prevent it, except reaching into ListPopupWindow's hidden
// API. This allows the C++ controller to completely control showing/hiding the popup. // API. This allows the C++ controller to completely control showing/hiding the popup.
...@@ -150,19 +169,6 @@ public class DropdownPopupWindow extends ListPopupWindow { ...@@ -150,19 +169,6 @@ public class DropdownPopupWindow extends ListPopupWindow {
} }
} }
@Override
public void setOnDismissListener(PopupWindow.OnDismissListener listener) {
mOnDismissListener = listener;
}
/**
* Sets the text direction in the dropdown. Should be called before show().
* @param isRtl If true, then dropdown text direciton is right to left.
*/
public void setRtl(boolean isRtl) {
mRtl = isRtl;
}
/** /**
* Measures the width of the list content. The adapter should not be null. * Measures the width of the list content. The adapter should not be null.
* @return The popup window width in pixels. * @return The popup window width in pixels.
......
...@@ -67,6 +67,7 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On ...@@ -67,6 +67,7 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
setOnItemClickListener(this); setOnItemClickListener(this);
setOnDismissListener(this); setOnDismissListener(this);
disableHideOnOutsideTap();
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment