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

Commit ed391269 authored by Oren Blasberg's avatar Oren Blasberg
Browse files

Make context menus show as popup menus.

This means that right-clicking/long pressing on a view that is registered for
context menu will show the context menu as a popup menu instead.

Bug: 20016398
Change-Id: I96fea60435fff2f981d288521f490f8ff24ada15
parent bf028210
Loading
Loading
Loading
Loading
+5 −8
Original line number Original line Diff line number Diff line
@@ -414,6 +414,7 @@ package android {
    field public static final int contentInsetRight = 16843862; // 0x1010456
    field public static final int contentInsetRight = 16843862; // 0x1010456
    field public static final int contentInsetStart = 16843859; // 0x1010453
    field public static final int contentInsetStart = 16843859; // 0x1010453
    field public static final int contextClickable = 16844007; // 0x10104e7
    field public static final int contextClickable = 16844007; // 0x10104e7
    field public static final int contextPopupMenuStyle = 16844032; // 0x1010500
    field public static final int controlX1 = 16843772; // 0x10103fc
    field public static final int controlX1 = 16843772; // 0x10103fc
    field public static final int controlX2 = 16843774; // 0x10103fe
    field public static final int controlX2 = 16843774; // 0x10103fe
    field public static final int controlY1 = 16843773; // 0x10103fd
    field public static final int controlY1 = 16843773; // 0x10103fd
@@ -1220,6 +1221,7 @@ package android {
    field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
    field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
    field public static final int textAppearanceMedium = 16842817; // 0x1010041
    field public static final int textAppearanceMedium = 16842817; // 0x1010041
    field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
    field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
    field public static final int textAppearancePopupMenuHeader = 16844033; // 0x1010501
    field public static final int textAppearanceSearchResultSubtitle = 16843424; // 0x10102a0
    field public static final int textAppearanceSearchResultSubtitle = 16843424; // 0x10102a0
    field public static final int textAppearanceSearchResultTitle = 16843425; // 0x10102a1
    field public static final int textAppearanceSearchResultTitle = 16843425; // 0x10102a1
    field public static final int textAppearanceSmall = 16842818; // 0x1010042
    field public static final int textAppearanceSmall = 16842818; // 0x1010042
@@ -36541,6 +36543,7 @@ package android.view {
    method public void setY(float);
    method public void setY(float);
    method public void setZ(float);
    method public void setZ(float);
    method public boolean showContextMenu();
    method public boolean showContextMenu();
    method public boolean showContextMenu(float, float);
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback);
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback);
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback, int);
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback, int);
    method public void startAnimation(android.view.animation.Animation);
    method public void startAnimation(android.view.animation.Animation);
@@ -37007,6 +37010,7 @@ package android.view {
    method public void setTransitionGroup(boolean);
    method public void setTransitionGroup(boolean);
    method public boolean shouldDelayChildPressedState();
    method public boolean shouldDelayChildPressedState();
    method public boolean showContextMenuForChild(android.view.View);
    method public boolean showContextMenuForChild(android.view.View);
    method public boolean showContextMenuForChild(android.view.View, float, float);
    method public android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback);
    method public android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback);
    method public android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback, int);
    method public android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback, int);
    method public void startLayoutAnimation();
    method public void startLayoutAnimation();
@@ -37128,6 +37132,7 @@ package android.view {
    method public abstract boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
    method public abstract boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
    method public abstract void requestTransparentRegion(android.view.View);
    method public abstract void requestTransparentRegion(android.view.View);
    method public abstract boolean showContextMenuForChild(android.view.View);
    method public abstract boolean showContextMenuForChild(android.view.View);
    method public abstract boolean showContextMenuForChild(android.view.View, float, float);
    method public abstract android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback);
    method public abstract android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback);
    method public abstract android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback, int);
    method public abstract android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback, int);
  }
  }
@@ -45349,10 +45354,7 @@ package java.lang.reflect {
  }
  }
  public final class Constructor extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
  public final class Constructor extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
    method public boolean equals(java.lang.Object);
    method public A getAnnotation(java.lang.Class<A>);
    method public A getAnnotation(java.lang.Class<A>);
    method public java.lang.annotation.Annotation[] getAnnotations();
    method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
    method public java.lang.Class<T> getDeclaringClass();
    method public java.lang.Class<T> getDeclaringClass();
    method public java.lang.Class<?>[] getExceptionTypes();
    method public java.lang.Class<?>[] getExceptionTypes();
    method public java.lang.reflect.Type[] getGenericExceptionTypes();
    method public java.lang.reflect.Type[] getGenericExceptionTypes();
@@ -45362,7 +45364,6 @@ package java.lang.reflect {
    method public java.lang.annotation.Annotation[][] getParameterAnnotations();
    method public java.lang.annotation.Annotation[][] getParameterAnnotations();
    method public java.lang.Class<?>[] getParameterTypes();
    method public java.lang.Class<?>[] getParameterTypes();
    method public java.lang.reflect.TypeVariable<java.lang.reflect.Constructor<T>>[] getTypeParameters();
    method public java.lang.reflect.TypeVariable<java.lang.reflect.Constructor<T>>[] getTypeParameters();
    method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
    method public boolean isSynthetic();
    method public boolean isSynthetic();
    method public boolean isVarArgs();
    method public boolean isVarArgs();
    method public T newInstance(java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException;
    method public T newInstance(java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException;
@@ -45436,10 +45437,7 @@ package java.lang.reflect {
  }
  }
  public final class Method extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
  public final class Method extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
    method public boolean equals(java.lang.Object);
    method public A getAnnotation(java.lang.Class<A>);
    method public A getAnnotation(java.lang.Class<A>);
    method public java.lang.annotation.Annotation[] getAnnotations();
    method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
    method public java.lang.Class<?> getDeclaringClass();
    method public java.lang.Class<?> getDeclaringClass();
    method public java.lang.Object getDefaultValue();
    method public java.lang.Object getDefaultValue();
    method public java.lang.Class<?>[] getExceptionTypes();
    method public java.lang.Class<?>[] getExceptionTypes();
@@ -45453,7 +45451,6 @@ package java.lang.reflect {
    method public java.lang.Class<?> getReturnType();
    method public java.lang.Class<?> getReturnType();
    method public java.lang.reflect.TypeVariable<java.lang.reflect.Method>[] getTypeParameters();
    method public java.lang.reflect.TypeVariable<java.lang.reflect.Method>[] getTypeParameters();
    method public java.lang.Object invoke(java.lang.Object, java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException;
    method public java.lang.Object invoke(java.lang.Object, java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException;
    method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
    method public boolean isBridge();
    method public boolean isBridge();
    method public boolean isSynthetic();
    method public boolean isSynthetic();
    method public boolean isVarArgs();
    method public boolean isVarArgs();
+5 −8
Original line number Original line Diff line number Diff line
@@ -506,6 +506,7 @@ package android {
    field public static final int contentInsetRight = 16843862; // 0x1010456
    field public static final int contentInsetRight = 16843862; // 0x1010456
    field public static final int contentInsetStart = 16843859; // 0x1010453
    field public static final int contentInsetStart = 16843859; // 0x1010453
    field public static final int contextClickable = 16844007; // 0x10104e7
    field public static final int contextClickable = 16844007; // 0x10104e7
    field public static final int contextPopupMenuStyle = 16844032; // 0x1010500
    field public static final int controlX1 = 16843772; // 0x10103fc
    field public static final int controlX1 = 16843772; // 0x10103fc
    field public static final int controlX2 = 16843774; // 0x10103fe
    field public static final int controlX2 = 16843774; // 0x10103fe
    field public static final int controlY1 = 16843773; // 0x10103fd
    field public static final int controlY1 = 16843773; // 0x10103fd
@@ -1316,6 +1317,7 @@ package android {
    field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
    field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
    field public static final int textAppearanceMedium = 16842817; // 0x1010041
    field public static final int textAppearanceMedium = 16842817; // 0x1010041
    field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
    field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
    field public static final int textAppearancePopupMenuHeader = 16844033; // 0x1010501
    field public static final int textAppearanceSearchResultSubtitle = 16843424; // 0x10102a0
    field public static final int textAppearanceSearchResultSubtitle = 16843424; // 0x10102a0
    field public static final int textAppearanceSearchResultTitle = 16843425; // 0x10102a1
    field public static final int textAppearanceSearchResultTitle = 16843425; // 0x10102a1
    field public static final int textAppearanceSmall = 16842818; // 0x1010042
    field public static final int textAppearanceSmall = 16842818; // 0x1010042
@@ -38835,6 +38837,7 @@ package android.view {
    method public void setY(float);
    method public void setY(float);
    method public void setZ(float);
    method public void setZ(float);
    method public boolean showContextMenu();
    method public boolean showContextMenu();
    method public boolean showContextMenu(float, float);
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback);
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback);
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback, int);
    method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback, int);
    method public void startAnimation(android.view.animation.Animation);
    method public void startAnimation(android.view.animation.Animation);
@@ -39301,6 +39304,7 @@ package android.view {
    method public void setTransitionGroup(boolean);
    method public void setTransitionGroup(boolean);
    method public boolean shouldDelayChildPressedState();
    method public boolean shouldDelayChildPressedState();
    method public boolean showContextMenuForChild(android.view.View);
    method public boolean showContextMenuForChild(android.view.View);
    method public boolean showContextMenuForChild(android.view.View, float, float);
    method public android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback);
    method public android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback);
    method public android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback, int);
    method public android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback, int);
    method public void startLayoutAnimation();
    method public void startLayoutAnimation();
@@ -39422,6 +39426,7 @@ package android.view {
    method public abstract boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
    method public abstract boolean requestSendAccessibilityEvent(android.view.View, android.view.accessibility.AccessibilityEvent);
    method public abstract void requestTransparentRegion(android.view.View);
    method public abstract void requestTransparentRegion(android.view.View);
    method public abstract boolean showContextMenuForChild(android.view.View);
    method public abstract boolean showContextMenuForChild(android.view.View);
    method public abstract boolean showContextMenuForChild(android.view.View, float, float);
    method public abstract android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback);
    method public abstract android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback);
    method public abstract android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback, int);
    method public abstract android.view.ActionMode startActionModeForChild(android.view.View, android.view.ActionMode.Callback, int);
  }
  }
@@ -47957,10 +47962,7 @@ package java.lang.reflect {
  }
  }
  public final class Constructor extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
  public final class Constructor extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
    method public boolean equals(java.lang.Object);
    method public A getAnnotation(java.lang.Class<A>);
    method public A getAnnotation(java.lang.Class<A>);
    method public java.lang.annotation.Annotation[] getAnnotations();
    method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
    method public java.lang.Class<T> getDeclaringClass();
    method public java.lang.Class<T> getDeclaringClass();
    method public java.lang.Class<?>[] getExceptionTypes();
    method public java.lang.Class<?>[] getExceptionTypes();
    method public java.lang.reflect.Type[] getGenericExceptionTypes();
    method public java.lang.reflect.Type[] getGenericExceptionTypes();
@@ -47970,7 +47972,6 @@ package java.lang.reflect {
    method public java.lang.annotation.Annotation[][] getParameterAnnotations();
    method public java.lang.annotation.Annotation[][] getParameterAnnotations();
    method public java.lang.Class<?>[] getParameterTypes();
    method public java.lang.Class<?>[] getParameterTypes();
    method public java.lang.reflect.TypeVariable<java.lang.reflect.Constructor<T>>[] getTypeParameters();
    method public java.lang.reflect.TypeVariable<java.lang.reflect.Constructor<T>>[] getTypeParameters();
    method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
    method public boolean isSynthetic();
    method public boolean isSynthetic();
    method public boolean isVarArgs();
    method public boolean isVarArgs();
    method public T newInstance(java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException;
    method public T newInstance(java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException;
@@ -48044,10 +48045,7 @@ package java.lang.reflect {
  }
  }
  public final class Method extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
  public final class Method extends java.lang.reflect.AccessibleObject implements java.lang.reflect.GenericDeclaration java.lang.reflect.Member {
    method public boolean equals(java.lang.Object);
    method public A getAnnotation(java.lang.Class<A>);
    method public A getAnnotation(java.lang.Class<A>);
    method public java.lang.annotation.Annotation[] getAnnotations();
    method public java.lang.annotation.Annotation[] getDeclaredAnnotations();
    method public java.lang.Class<?> getDeclaringClass();
    method public java.lang.Class<?> getDeclaringClass();
    method public java.lang.Object getDefaultValue();
    method public java.lang.Object getDefaultValue();
    method public java.lang.Class<?>[] getExceptionTypes();
    method public java.lang.Class<?>[] getExceptionTypes();
@@ -48061,7 +48059,6 @@ package java.lang.reflect {
    method public java.lang.Class<?> getReturnType();
    method public java.lang.Class<?> getReturnType();
    method public java.lang.reflect.TypeVariable<java.lang.reflect.Method>[] getTypeParameters();
    method public java.lang.reflect.TypeVariable<java.lang.reflect.Method>[] getTypeParameters();
    method public java.lang.Object invoke(java.lang.Object, java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException;
    method public java.lang.Object invoke(java.lang.Object, java.lang.Object...) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException;
    method public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation>);
    method public boolean isBridge();
    method public boolean isBridge();
    method public boolean isSynthetic();
    method public boolean isSynthetic();
    method public boolean isVarArgs();
    method public boolean isVarArgs();
+3 −6
Original line number Original line Diff line number Diff line
@@ -5388,7 +5388,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    protected boolean performButtonActionOnTouchDown(MotionEvent event) {
    protected boolean performButtonActionOnTouchDown(MotionEvent event) {
        if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE &&
        if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE &&
            (event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0) {
            (event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0) {
            showContextMenu(event.getX(), event.getY(), event.getMetaState());
            showContextMenu(event.getX(), event.getY());
            mPrivateFlags |= PFLAG_CANCEL_NEXT_UP_EVENT;
            mPrivateFlags |= PFLAG_CANCEL_NEXT_UP_EVENT;
            return true;
            return true;
        }
        }
@@ -5409,13 +5409,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     *
     *
     * @param x The referenced x coordinate.
     * @param x The referenced x coordinate.
     * @param y The referenced y coordinate.
     * @param y The referenced y coordinate.
     * @param metaState The keyboard modifiers that were pressed.
     * @return Whether a context menu was displayed.
     * @return Whether a context menu was displayed.
     *
     * @hide
     */
     */
    public boolean showContextMenu(float x, float y, int metaState) {
    public boolean showContextMenu(float x, float y) {
        return showContextMenu();
        return getParent().showContextMenuForChild(this, x, y);
    }
    }
    /**
    /**
+5 −0
Original line number Original line Diff line number Diff line
@@ -767,6 +767,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        return mParent != null && mParent.showContextMenuForChild(originalView);
        return mParent != null && mParent.showContextMenuForChild(originalView);
    }
    }


    @Override
    public boolean showContextMenuForChild(View originalView, float x, float y) {
        return mParent != null && mParent.showContextMenuForChild(originalView, x, y);
    }

    /**
    /**
     * {@inheritDoc}
     * {@inheritDoc}
     */
     */
+11 −0
Original line number Original line Diff line number Diff line
@@ -181,6 +181,17 @@ public interface ViewParent {
     */
     */
    public boolean showContextMenuForChild(View originalView);
    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
     */
    public boolean showContextMenuForChild(View originalView, float x, float y);

    /**
    /**
     * Have the parent populate the specified context menu if it has anything to
     * Have the parent populate the specified context menu if it has anything to
     * add (and then recurse on its parent).
     * add (and then recurse on its parent).
Loading