Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23e282d2 authored by Oren Blasberg's avatar Oren Blasberg
Browse files

Accommodate NaN in new context menu methods.

Bug: 28296401
Change-Id: I0ae6067e1ae01c342c1b39d6f64db5dcd02492d5
parent 6ed4e35e
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -5739,9 +5739,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * view-relative coordinate.
     * view-relative coordinate.
     *
     *
     * @param x the X coordinate in pixels relative to the view to which the
     * @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
     * @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}
     * @return {@code true} if the context menu was shown, {@code false}
     *         otherwise
     *         otherwise
     */
     */
+4 −2
Original line number Original line Diff line number Diff line
@@ -199,9 +199,11 @@ public interface ViewParent {
     * @param originalView the source view where the context menu was first
     * @param originalView the source view where the context menu was first
     *                     invoked
     *                     invoked
     * @param x the X coordinate in pixels relative to the original view to
     * @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
     * @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}
     * @return {@code true} if the context menu was shown, {@code false}
     *         otherwise
     *         otherwise
     */
     */
+4 −3
Original line number Original line Diff line number Diff line
@@ -733,16 +733,16 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind


    @Override
    @Override
    public boolean showContextMenuForChild(View originalView) {
    public boolean showContextMenuForChild(View originalView) {
        return showContextMenuForChildInternal(originalView, 0, 0, false);
        return showContextMenuForChildInternal(originalView, Float.NaN, Float.NaN);
    }
    }


    @Override
    @Override
    public boolean showContextMenuForChild(View originalView, float x, float y) {
    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,
    private boolean showContextMenuForChildInternal(View originalView,
            float x, float y, boolean isPopup) {
            float x, float y) {
        // Only allow one context menu at a time.
        // Only allow one context menu at a time.
        if (mWindow.mContextMenuHelper != null) {
        if (mWindow.mContextMenuHelper != null) {
            mWindow.mContextMenuHelper.dismiss();
            mWindow.mContextMenuHelper.dismiss();
@@ -759,6 +759,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        }
        }


        final MenuHelper helper;
        final MenuHelper helper;
        final boolean isPopup = !Float.isNaN(x) && !Float.isNaN(y);
        if (isPopup) {
        if (isPopup) {
            helper = mWindow.mContextMenu.showPopup(getContext(), originalView, x, y);
            helper = mWindow.mContextMenu.showPopup(getContext(), originalView, x, y);
        } else {
        } else {