[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.
TBR=jdduke@chromium.org
BUG=430543
Review URL: https://codereview.chromium.org/932493003
Cr-Commit-Position: refs/heads/master@{#316641}
(cherry picked from commit 2d616c68a8fd923e378b6473302c1406f19aa8cb)
Review URL: https://codereview.chromium.org/934153002
Cr-Commit-Position: refs/branch-heads/2272@{#321}
Cr-Branched-From: 827a380cfdb31aa54c8d56e63ce2c3fd8c3ba4d4-refs/heads/master@{#310958}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationPopupBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationPopupBridge.java
index 6e7559b6..0c1d29f 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationPopupBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/PasswordGenerationPopupBridge.java
@@ -66,6 +66,7 @@
mPopup = new DropdownPopupWindow(mContext, containerViewDelegate);
mPopup.setOnItemClickListener(this);
mPopup.setOnDismissListener(this);
+ mPopup.disableHideOnOutsideTap();
}
mAnchorWidth = 0;
}
diff --git a/ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java b/ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java
index c1056b0..25db9a2 100644
--- a/ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java
+++ b/ui/android/java/src/org/chromium/ui/DropdownPopupWindow.java
@@ -132,20 +132,6 @@
getListView().setDividerHeight(0);
ApiCompatibilityUtils.setLayoutDirection(getListView(),
mRtl ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
-
- // 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
- // API. This allows the C++ controller to completely control showing/hiding the popup.
- // See http://crbug.com/400601
- try {
- Method setForceIgnoreOutsideTouch = ListPopupWindow.class.getMethod(
- "setForceIgnoreOutsideTouch", new Class[] { boolean.class });
- setForceIgnoreOutsideTouch.invoke(this, new Object[] { true });
- } catch (Exception e) {
- Log.e("AutofillPopup",
- "ListPopupWindow.setForceIgnoreOutsideTouch not found",
- e);
- }
}
@Override
@@ -162,6 +148,26 @@
}
/**
+ * 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
+ // 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.
+ // See http://crbug.com/400601
+ try {
+ Method setForceIgnoreOutsideTouch = ListPopupWindow.class.getMethod(
+ "setForceIgnoreOutsideTouch", new Class[] { boolean.class });
+ setForceIgnoreOutsideTouch.invoke(this, new Object[] { true });
+ } catch (Exception e) {
+ Log.e("AutofillPopup",
+ "ListPopupWindow.setForceIgnoreOutsideTouch not found",
+ e);
+ }
+ }
+
+ /**
* Measures the width of the list content. The adapter should not be null.
* @return The popup window width in pixels.
*/
diff --git a/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java b/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java
index 5c50e63..4e45605 100644
--- a/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java
+++ b/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java
@@ -67,6 +67,7 @@
setOnItemClickListener(this);
setOnDismissListener(this);
+ disableHideOnOutsideTap();
}
/**