From 23e282d297193655ce5a4b716312f0a985b27d50 Mon Sep 17 00:00:00 2001 From: Oren Blasberg Date: Wed, 20 Apr 2016 13:43:45 -0700 Subject: [PATCH] Accommodate NaN in new context menu methods. Bug: 28296401 Change-Id: I0ae6067e1ae01c342c1b39d6f64db5dcd02492d5 --- core/java/android/view/View.java | 4 ++-- core/java/android/view/ViewParent.java | 6 ++++-- core/java/com/android/internal/policy/DecorView.java | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 8a6b5dab2f0b6..ba9488d9359a9 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -5739,9 +5739,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * view-relative coordinate. * * @param x the X coordinate in pixels relative to the view to which the - * menu should be anchored + * menu should be anchored, or {@link Float#NaN} to disable anchoring * @param y the Y coordinate in pixels relative to the view to which the - * menu should be anchored + * menu should be anchored, or {@link Float#NaN} to disable anchoring * @return {@code true} if the context menu was shown, {@code false} * otherwise */ diff --git a/core/java/android/view/ViewParent.java b/core/java/android/view/ViewParent.java index 06afef27cee5a..849c8b93fd6b0 100644 --- a/core/java/android/view/ViewParent.java +++ b/core/java/android/view/ViewParent.java @@ -199,9 +199,11 @@ public interface ViewParent { * @param originalView the source view where the context menu was first * invoked * @param x the X coordinate in pixels relative to the original view to - * which the menu should be anchored + * which the menu should be anchored, or {@link Float#NaN} to + * disable anchoring * @param y the Y coordinate in pixels relative to the original view to - * which the menu should be anchored + * which the menu should be anchored, or {@link Float#NaN} to + * disable anchoring * @return {@code true} if the context menu was shown, {@code false} * otherwise */ diff --git a/core/java/com/android/internal/policy/DecorView.java b/core/java/com/android/internal/policy/DecorView.java index 3aa771971cf29..645ffda2cff59 100644 --- a/core/java/com/android/internal/policy/DecorView.java +++ b/core/java/com/android/internal/policy/DecorView.java @@ -733,16 +733,16 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind @Override public boolean showContextMenuForChild(View originalView) { - return showContextMenuForChildInternal(originalView, 0, 0, false); + return showContextMenuForChildInternal(originalView, Float.NaN, Float.NaN); } @Override public boolean showContextMenuForChild(View originalView, float x, float y) { - return showContextMenuForChildInternal(originalView, x, y, true); + return showContextMenuForChildInternal(originalView, x, y); } private boolean showContextMenuForChildInternal(View originalView, - float x, float y, boolean isPopup) { + float x, float y) { // Only allow one context menu at a time. if (mWindow.mContextMenuHelper != null) { mWindow.mContextMenuHelper.dismiss(); @@ -759,6 +759,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind } final MenuHelper helper; + final boolean isPopup = !Float.isNaN(x) && !Float.isNaN(y); if (isPopup) { helper = mWindow.mContextMenu.showPopup(getContext(), originalView, x, y); } else {