diff options
| author | Alan Viverette <alanv@google.com> | 2015-11-25 14:22:00 -0500 |
|---|---|---|
| committer | Alan Viverette <alanv@google.com> | 2015-11-25 14:22:00 -0500 |
| commit | 021627eb5875372dea57ba91fa782fffbfbbc559 (patch) | |
| tree | eb34c1cf49177fa6312905e2c9a8cfb3fae43457 /core/java/android/view/ViewParent.java | |
| parent | e38bdf6bf79ff8d536d6909ef0b595d6dc3d56ee (diff) | |
Ensure only one context menu is shown at a time
Refactors the menu helper classes. Both classes now implement a common
MenuHelper interface, which eliminates the need to keep separate helpers
on PhoneWindow and unifies the DecorView showContextMenuForChild()
implementations.
We now explicitly dismiss any previously shown context menu before showing
a new context menu. Previously we relied on the modal nature of the dialog
context menu to prevent multiple menus from being opened at once, but this
is no longer reliable with popup context menus.
Bug: 25656520
Change-Id: Idab3daa6d6888f803f2e33660fe1dd488e4c28d1
Diffstat (limited to 'core/java/android/view/ViewParent.java')
| -rw-r--r-- | core/java/android/view/ViewParent.java | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/core/java/android/view/ViewParent.java b/core/java/android/view/ViewParent.java index 6ae448a7e888..f2ab35e90c17 100644 --- a/core/java/android/view/ViewParent.java +++ b/core/java/android/view/ViewParent.java @@ -174,26 +174,38 @@ public interface ViewParent { public void focusableViewAvailable(View v); /** - * Bring up a context menu for the specified view or its ancestors. - * - * <p>In most cases, a subclass does not need to override this. However, if + * Shows the context menu for the specified view or its ancestors. + * <p> + * In most cases, a subclass does not need to override this. However, if * the subclass is added directly to the window manager (for example, * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)}) - * then it should override this and show the context menu.</p> - * - * @param originalView The source view where the context menu was first invoked - * @return true if a context menu was displayed + * then it should override this and show the context menu. + * + * @param originalView the source view where the context menu was first + * invoked + * @return {@code true} if the context menu was shown, {@code false} + * otherwise + * @see #showContextMenuForChild(View, float, float) */ public boolean showContextMenuForChild(View originalView); /** - * Bring up a context menu for the specified view at the given x/y offset from - * the top left corner. - * - * @param originalView - * @param x The x offset at which to open the menu - * @param y The y offset at which to open the menu - * @return true if a context menu was displayed + * Shows the context menu for the specified view or its ancestors anchored + * to the specified view-relative coordinate. + * <p> + * In most cases, a subclass does not need to override this. However, if + * the subclass is added directly to the window manager (for example, + * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)}) + * then it should override this and show the context menu. + * + * @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 + * @param y the Y coordinate in pixels relative to the original view to + * which the menu should be anchored + * @return {@code true} if the context menu was shown, {@code false} + * otherwise */ public boolean showContextMenuForChild(View originalView, float x, float y); |
