Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1907)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 231953003: Show Ash like <select> popup on Android tablets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@newpopupx
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index b5068b0eec0471e4408badf0edd6072d8d6e6ba9..2b158236b848c14f863d1712220c92ea7aebc453 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -67,6 +67,7 @@ import org.chromium.content.browser.input.InsertionHandleController;
import org.chromium.content.browser.input.SelectPopupDialog;
import org.chromium.content.browser.input.SelectPopupItem;
import org.chromium.content.browser.input.SelectionHandleController;
+import org.chromium.content.browser.input.SingleSelectPopup;
import org.chromium.content.common.ContentSwitches;
import org.chromium.content_public.browser.GestureStateListener;
import org.chromium.content_public.browser.WebContents;
@@ -320,6 +321,7 @@ public class ContentViewCore
private PopupZoomer mPopupZoomer;
private SelectPopupDialog mSelectPopupDialog;
+ private SingleSelectPopup mSingleSelectPopup;
private Runnable mFakeMouseMoveRunnable = null;
@@ -1551,7 +1553,6 @@ public class ContentViewCore
mInputMethodManagerWrapper.restartInput(mContainerView);
}
mContainerViewInternals.super_onConfigurationChanged(newConfig);
-
// To request layout has side effect, but it seems OK as it only happen in
// onConfigurationChange and layout has to be changed in most case.
mContainerView.requestLayout();
@@ -2388,20 +2389,34 @@ public class ContentViewCore
*/
@SuppressWarnings("unused")
@CalledByNative
- private void showSelectPopup(String[] items, int[] enabled, boolean multiple,
+ private void showSelectPopup(Rect bounds, String[] items, int[] enabled, boolean multiple,
int[] selectedIndices) {
if (mContainerView.getParent() == null || mContainerView.getVisibility() != View.VISIBLE) {
selectPopupMenuItems(null);
return;
}
-
- hideSelectPopup();
assert items.length == enabled.length;
List<SelectPopupItem> popupItems = new ArrayList<SelectPopupItem>();
for (int i = 0; i < items.length; i++) {
popupItems.add(new SelectPopupItem(items[i], enabled[i]));
}
- mSelectPopupDialog = SelectPopupDialog.show(this, popupItems, multiple, selectedIndices);
+
+ hidePopupDialog();
+ if (DeviceUtils.isTablet(mContext) && !multiple) {
+ mSingleSelectPopup = new SingleSelectPopup(this,
+ new SingleSelectPopup.SingleSelectPopupDelegate() {
+ @Override
+ public void optionSelected(int index) {
+ int[] indices = {index};
+ selectPopupMenuItems(indices);
+ hideSelectPopup();
+ }
+ });
+ mSingleSelectPopup.show(popupItems, bounds);
+ } else {
+ mSelectPopupDialog =
+ SelectPopupDialog.show(this, popupItems, multiple, selectedIndices);
+ }
}
/**
@@ -2413,6 +2428,10 @@ public class ContentViewCore
mSelectPopupDialog.hide();
mSelectPopupDialog = null;
}
+ if (mSingleSelectPopup != null) {
+ mSingleSelectPopup.hide();
+ mSingleSelectPopup = null;
+ }
}
/**

Powered by Google App Engine
This is Rietveld 408576698