Rename PointerIcon and Pointer Capture APIs
This is a response to API council feedback.
Bug: 26830970
Change-Id: I1be541a53e3943d06640169671824f7daea15462
diff --git a/api/current.txt b/api/current.txt
index 90d0b9a..7cf4283 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -42108,35 +42108,35 @@
}
public final class PointerIcon implements android.os.Parcelable {
- method public static android.view.PointerIcon createCustomIcon(android.graphics.Bitmap, float, float);
+ method public static android.view.PointerIcon create(android.graphics.Bitmap, float, float);
method public int describeContents();
method public static android.view.PointerIcon getSystemIcon(android.content.Context, int);
- method public static android.view.PointerIcon loadCustomIcon(android.content.res.Resources, int);
+ method public static android.view.PointerIcon load(android.content.res.Resources, int);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.view.PointerIcon> CREATOR;
- field public static final int STYLE_ALIAS = 1010; // 0x3f2
- field public static final int STYLE_ALL_SCROLL = 1013; // 0x3f5
- field public static final int STYLE_ARROW = 1000; // 0x3e8
- field public static final int STYLE_CELL = 1006; // 0x3ee
- field public static final int STYLE_CONTEXT_MENU = 1001; // 0x3e9
- field public static final int STYLE_COPY = 1011; // 0x3f3
- field public static final int STYLE_CROSSHAIR = 1007; // 0x3ef
- field public static final int STYLE_DEFAULT = 1000; // 0x3e8
- field public static final int STYLE_GRAB = 1020; // 0x3fc
- field public static final int STYLE_GRABBING = 1021; // 0x3fd
- field public static final int STYLE_HAND = 1002; // 0x3ea
- field public static final int STYLE_HELP = 1003; // 0x3eb
- field public static final int STYLE_HORIZONTAL_DOUBLE_ARROW = 1014; // 0x3f6
- field public static final int STYLE_NO_DROP = 1012; // 0x3f4
- field public static final int STYLE_NULL = 0; // 0x0
- field public static final int STYLE_TEXT = 1008; // 0x3f0
- field public static final int STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017; // 0x3f9
- field public static final int STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016; // 0x3f8
- field public static final int STYLE_VERTICAL_DOUBLE_ARROW = 1015; // 0x3f7
- field public static final int STYLE_VERTICAL_TEXT = 1009; // 0x3f1
- field public static final int STYLE_WAIT = 1004; // 0x3ec
- field public static final int STYLE_ZOOM_IN = 1018; // 0x3fa
- field public static final int STYLE_ZOOM_OUT = 1019; // 0x3fb
+ field public static final int TYPE_ALIAS = 1010; // 0x3f2
+ field public static final int TYPE_ALL_SCROLL = 1013; // 0x3f5
+ field public static final int TYPE_ARROW = 1000; // 0x3e8
+ field public static final int TYPE_CELL = 1006; // 0x3ee
+ field public static final int TYPE_CONTEXT_MENU = 1001; // 0x3e9
+ field public static final int TYPE_COPY = 1011; // 0x3f3
+ field public static final int TYPE_CROSSHAIR = 1007; // 0x3ef
+ field public static final int TYPE_DEFAULT = 1000; // 0x3e8
+ field public static final int TYPE_GRAB = 1020; // 0x3fc
+ field public static final int TYPE_GRABBING = 1021; // 0x3fd
+ field public static final int TYPE_HAND = 1002; // 0x3ea
+ field public static final int TYPE_HELP = 1003; // 0x3eb
+ field public static final int TYPE_HORIZONTAL_DOUBLE_ARROW = 1014; // 0x3f6
+ field public static final int TYPE_NO_DROP = 1012; // 0x3f4
+ field public static final int TYPE_NULL = 0; // 0x0
+ field public static final int TYPE_TEXT = 1008; // 0x3f0
+ field public static final int TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017; // 0x3f9
+ field public static final int TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016; // 0x3f8
+ field public static final int TYPE_VERTICAL_DOUBLE_ARROW = 1015; // 0x3f7
+ field public static final int TYPE_VERTICAL_TEXT = 1009; // 0x3f1
+ field public static final int TYPE_WAIT = 1004; // 0x3ec
+ field public static final int TYPE_ZOOM_IN = 1018; // 0x3fa
+ field public static final int TYPE_ZOOM_OUT = 1019; // 0x3fb
}
public class ScaleGestureDetector {
@@ -42502,7 +42502,7 @@
method public android.view.ViewParent getParentForAccessibility();
method public float getPivotX();
method public float getPivotY();
- method public android.view.PointerIcon getPointerIcon(android.view.MotionEvent, float, float);
+ method public android.view.PointerIcon getPointerIcon();
method public android.content.res.Resources getResources();
method public final int getRight();
method protected float getRightFadingEdgeStrength();
@@ -42653,6 +42653,7 @@
method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
method public void onProvideStructure(android.view.ViewStructure);
method public void onProvideVirtualStructure(android.view.ViewStructure);
+ method public android.view.PointerIcon onResolvePointerIcon(android.view.MotionEvent, int);
method protected void onRestoreInstanceState(android.os.Parcelable);
method public void onRtlPropertiesChanged(int);
method protected android.os.Parcelable onSaveInstanceState();
@@ -42700,6 +42701,7 @@
method public boolean requestFocus(int, android.graphics.Rect);
method public final boolean requestFocusFromTouch();
method public void requestLayout();
+ method public void requestPointerCapture();
method public boolean requestRectangleOnScreen(android.graphics.Rect);
method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean);
method public final void requestUnbufferedDispatch(android.view.MotionEvent);
@@ -42790,7 +42792,6 @@
method public void setPaddingRelative(int, int, int, int);
method public void setPivotX(float);
method public void setPivotY(float);
- method public void setPointerCapture();
method public void setPointerIcon(android.view.PointerIcon);
method public void setPressed(boolean);
method public final void setRight(int);
diff --git a/api/system-current.txt b/api/system-current.txt
index f877f331..2684f48 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -45106,35 +45106,35 @@
}
public final class PointerIcon implements android.os.Parcelable {
- method public static android.view.PointerIcon createCustomIcon(android.graphics.Bitmap, float, float);
+ method public static android.view.PointerIcon create(android.graphics.Bitmap, float, float);
method public int describeContents();
method public static android.view.PointerIcon getSystemIcon(android.content.Context, int);
- method public static android.view.PointerIcon loadCustomIcon(android.content.res.Resources, int);
+ method public static android.view.PointerIcon load(android.content.res.Resources, int);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.view.PointerIcon> CREATOR;
- field public static final int STYLE_ALIAS = 1010; // 0x3f2
- field public static final int STYLE_ALL_SCROLL = 1013; // 0x3f5
- field public static final int STYLE_ARROW = 1000; // 0x3e8
- field public static final int STYLE_CELL = 1006; // 0x3ee
- field public static final int STYLE_CONTEXT_MENU = 1001; // 0x3e9
- field public static final int STYLE_COPY = 1011; // 0x3f3
- field public static final int STYLE_CROSSHAIR = 1007; // 0x3ef
- field public static final int STYLE_DEFAULT = 1000; // 0x3e8
- field public static final int STYLE_GRAB = 1020; // 0x3fc
- field public static final int STYLE_GRABBING = 1021; // 0x3fd
- field public static final int STYLE_HAND = 1002; // 0x3ea
- field public static final int STYLE_HELP = 1003; // 0x3eb
- field public static final int STYLE_HORIZONTAL_DOUBLE_ARROW = 1014; // 0x3f6
- field public static final int STYLE_NO_DROP = 1012; // 0x3f4
- field public static final int STYLE_NULL = 0; // 0x0
- field public static final int STYLE_TEXT = 1008; // 0x3f0
- field public static final int STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017; // 0x3f9
- field public static final int STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016; // 0x3f8
- field public static final int STYLE_VERTICAL_DOUBLE_ARROW = 1015; // 0x3f7
- field public static final int STYLE_VERTICAL_TEXT = 1009; // 0x3f1
- field public static final int STYLE_WAIT = 1004; // 0x3ec
- field public static final int STYLE_ZOOM_IN = 1018; // 0x3fa
- field public static final int STYLE_ZOOM_OUT = 1019; // 0x3fb
+ field public static final int TYPE_ALIAS = 1010; // 0x3f2
+ field public static final int TYPE_ALL_SCROLL = 1013; // 0x3f5
+ field public static final int TYPE_ARROW = 1000; // 0x3e8
+ field public static final int TYPE_CELL = 1006; // 0x3ee
+ field public static final int TYPE_CONTEXT_MENU = 1001; // 0x3e9
+ field public static final int TYPE_COPY = 1011; // 0x3f3
+ field public static final int TYPE_CROSSHAIR = 1007; // 0x3ef
+ field public static final int TYPE_DEFAULT = 1000; // 0x3e8
+ field public static final int TYPE_GRAB = 1020; // 0x3fc
+ field public static final int TYPE_GRABBING = 1021; // 0x3fd
+ field public static final int TYPE_HAND = 1002; // 0x3ea
+ field public static final int TYPE_HELP = 1003; // 0x3eb
+ field public static final int TYPE_HORIZONTAL_DOUBLE_ARROW = 1014; // 0x3f6
+ field public static final int TYPE_NO_DROP = 1012; // 0x3f4
+ field public static final int TYPE_NULL = 0; // 0x0
+ field public static final int TYPE_TEXT = 1008; // 0x3f0
+ field public static final int TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017; // 0x3f9
+ field public static final int TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016; // 0x3f8
+ field public static final int TYPE_VERTICAL_DOUBLE_ARROW = 1015; // 0x3f7
+ field public static final int TYPE_VERTICAL_TEXT = 1009; // 0x3f1
+ field public static final int TYPE_WAIT = 1004; // 0x3ec
+ field public static final int TYPE_ZOOM_IN = 1018; // 0x3fa
+ field public static final int TYPE_ZOOM_OUT = 1019; // 0x3fb
}
public class ScaleGestureDetector {
@@ -45500,7 +45500,7 @@
method public android.view.ViewParent getParentForAccessibility();
method public float getPivotX();
method public float getPivotY();
- method public android.view.PointerIcon getPointerIcon(android.view.MotionEvent, float, float);
+ method public android.view.PointerIcon getPointerIcon();
method public android.content.res.Resources getResources();
method public final int getRight();
method protected float getRightFadingEdgeStrength();
@@ -45651,6 +45651,7 @@
method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
method public void onProvideStructure(android.view.ViewStructure);
method public void onProvideVirtualStructure(android.view.ViewStructure);
+ method public android.view.PointerIcon onResolvePointerIcon(android.view.MotionEvent, int);
method protected void onRestoreInstanceState(android.os.Parcelable);
method public void onRtlPropertiesChanged(int);
method protected android.os.Parcelable onSaveInstanceState();
@@ -45698,6 +45699,7 @@
method public boolean requestFocus(int, android.graphics.Rect);
method public final boolean requestFocusFromTouch();
method public void requestLayout();
+ method public void requestPointerCapture();
method public boolean requestRectangleOnScreen(android.graphics.Rect);
method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean);
method public final void requestUnbufferedDispatch(android.view.MotionEvent);
@@ -45788,7 +45790,6 @@
method public void setPaddingRelative(int, int, int, int);
method public void setPivotX(float);
method public void setPivotY(float);
- method public void setPointerCapture();
method public void setPointerIcon(android.view.PointerIcon);
method public void setPressed(boolean);
method public final void setRight(int);
diff --git a/api/test-current.txt b/api/test-current.txt
index 0bbca5a..9bed7f2 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -42188,35 +42188,35 @@
}
public final class PointerIcon implements android.os.Parcelable {
- method public static android.view.PointerIcon createCustomIcon(android.graphics.Bitmap, float, float);
+ method public static android.view.PointerIcon create(android.graphics.Bitmap, float, float);
method public int describeContents();
method public static android.view.PointerIcon getSystemIcon(android.content.Context, int);
- method public static android.view.PointerIcon loadCustomIcon(android.content.res.Resources, int);
+ method public static android.view.PointerIcon load(android.content.res.Resources, int);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.view.PointerIcon> CREATOR;
- field public static final int STYLE_ALIAS = 1010; // 0x3f2
- field public static final int STYLE_ALL_SCROLL = 1013; // 0x3f5
- field public static final int STYLE_ARROW = 1000; // 0x3e8
- field public static final int STYLE_CELL = 1006; // 0x3ee
- field public static final int STYLE_CONTEXT_MENU = 1001; // 0x3e9
- field public static final int STYLE_COPY = 1011; // 0x3f3
- field public static final int STYLE_CROSSHAIR = 1007; // 0x3ef
- field public static final int STYLE_DEFAULT = 1000; // 0x3e8
- field public static final int STYLE_GRAB = 1020; // 0x3fc
- field public static final int STYLE_GRABBING = 1021; // 0x3fd
- field public static final int STYLE_HAND = 1002; // 0x3ea
- field public static final int STYLE_HELP = 1003; // 0x3eb
- field public static final int STYLE_HORIZONTAL_DOUBLE_ARROW = 1014; // 0x3f6
- field public static final int STYLE_NO_DROP = 1012; // 0x3f4
- field public static final int STYLE_NULL = 0; // 0x0
- field public static final int STYLE_TEXT = 1008; // 0x3f0
- field public static final int STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017; // 0x3f9
- field public static final int STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016; // 0x3f8
- field public static final int STYLE_VERTICAL_DOUBLE_ARROW = 1015; // 0x3f7
- field public static final int STYLE_VERTICAL_TEXT = 1009; // 0x3f1
- field public static final int STYLE_WAIT = 1004; // 0x3ec
- field public static final int STYLE_ZOOM_IN = 1018; // 0x3fa
- field public static final int STYLE_ZOOM_OUT = 1019; // 0x3fb
+ field public static final int TYPE_ALIAS = 1010; // 0x3f2
+ field public static final int TYPE_ALL_SCROLL = 1013; // 0x3f5
+ field public static final int TYPE_ARROW = 1000; // 0x3e8
+ field public static final int TYPE_CELL = 1006; // 0x3ee
+ field public static final int TYPE_CONTEXT_MENU = 1001; // 0x3e9
+ field public static final int TYPE_COPY = 1011; // 0x3f3
+ field public static final int TYPE_CROSSHAIR = 1007; // 0x3ef
+ field public static final int TYPE_DEFAULT = 1000; // 0x3e8
+ field public static final int TYPE_GRAB = 1020; // 0x3fc
+ field public static final int TYPE_GRABBING = 1021; // 0x3fd
+ field public static final int TYPE_HAND = 1002; // 0x3ea
+ field public static final int TYPE_HELP = 1003; // 0x3eb
+ field public static final int TYPE_HORIZONTAL_DOUBLE_ARROW = 1014; // 0x3f6
+ field public static final int TYPE_NO_DROP = 1012; // 0x3f4
+ field public static final int TYPE_NULL = 0; // 0x0
+ field public static final int TYPE_TEXT = 1008; // 0x3f0
+ field public static final int TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017; // 0x3f9
+ field public static final int TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016; // 0x3f8
+ field public static final int TYPE_VERTICAL_DOUBLE_ARROW = 1015; // 0x3f7
+ field public static final int TYPE_VERTICAL_TEXT = 1009; // 0x3f1
+ field public static final int TYPE_WAIT = 1004; // 0x3ec
+ field public static final int TYPE_ZOOM_IN = 1018; // 0x3fa
+ field public static final int TYPE_ZOOM_OUT = 1019; // 0x3fb
}
public class ScaleGestureDetector {
@@ -42582,7 +42582,7 @@
method public android.view.ViewParent getParentForAccessibility();
method public float getPivotX();
method public float getPivotY();
- method public android.view.PointerIcon getPointerIcon(android.view.MotionEvent, float, float);
+ method public android.view.PointerIcon getPointerIcon();
method public android.content.res.Resources getResources();
method public final int getRight();
method protected float getRightFadingEdgeStrength();
@@ -42733,6 +42733,7 @@
method public void onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent);
method public void onProvideStructure(android.view.ViewStructure);
method public void onProvideVirtualStructure(android.view.ViewStructure);
+ method public android.view.PointerIcon onResolvePointerIcon(android.view.MotionEvent, int);
method protected void onRestoreInstanceState(android.os.Parcelable);
method public void onRtlPropertiesChanged(int);
method protected android.os.Parcelable onSaveInstanceState();
@@ -42780,6 +42781,7 @@
method public boolean requestFocus(int, android.graphics.Rect);
method public final boolean requestFocusFromTouch();
method public void requestLayout();
+ method public void requestPointerCapture();
method public boolean requestRectangleOnScreen(android.graphics.Rect);
method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean);
method public final void requestUnbufferedDispatch(android.view.MotionEvent);
@@ -42870,7 +42872,6 @@
method public void setPaddingRelative(int, int, int, int);
method public void setPivotX(float);
method public void setPivotY(float);
- method public void setPointerCapture();
method public void setPointerIcon(android.view.PointerIcon);
method public void setPressed(boolean);
method public final void setRight(int);
diff --git a/core/java/android/hardware/input/IInputManager.aidl b/core/java/android/hardware/input/IInputManager.aidl
index c4ee347..49c106e 100644
--- a/core/java/android/hardware/input/IInputManager.aidl
+++ b/core/java/android/hardware/input/IInputManager.aidl
@@ -79,7 +79,7 @@
void vibrate(int deviceId, in long[] pattern, int repeat, IBinder token);
void cancelVibrate(int deviceId, IBinder token);
- void setPointerIconShape(int shapeId);
+ void setPointerIconType(int typeId);
void setCustomPointerIcon(in PointerIcon icon);
void setPointerIconDetached(boolean detached);
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index 8a43acb..a5aeae33 100644
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -872,13 +872,13 @@
* Changes the mouse pointer's icon shape into the specified id.
*
* @param iconId The id of the pointer graphic, as a value between
- * {@link PointerIcon.STYLE_ARROW} and {@link PointerIcon.STYLE_GRABBING}.
+ * {@link PointerIcon.TYPE_ARROW} and {@link PointerIcon.TYPE_GRABBING}.
*
* @hide
*/
- public void setPointerIconShape(int iconId) {
+ public void setPointerIconType(int iconId) {
try {
- mIm.setPointerIconShape(iconId);
+ mIm.setPointerIconType(iconId);
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
}
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index 281ab12..f8796c3 100644
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -778,12 +778,12 @@
}
/**
- * Sets the current pointer shape.
- * @param pointerShape the id of the pointer icon.
+ * Sets the current pointer type.
+ * @param pointerType the type of the pointer icon.
* @hide
*/
- public void setPointerShape(int pointerShape) {
- InputManager.getInstance().setPointerIconShape(pointerShape);
+ public void setPointerType(int pointerType) {
+ InputManager.getInstance().setPointerIconType(pointerType);
}
/**
diff --git a/core/java/android/view/PointerIcon.java b/core/java/android/view/PointerIcon.java
index 81bb638..fc79f53 100644
--- a/core/java/android/view/PointerIcon.java
+++ b/core/java/android/view/PointerIcon.java
@@ -36,112 +36,112 @@
/**
* Represents an icon that can be used as a mouse pointer.
* <p>
- * Pointer icons can be provided either by the system using system styles,
+ * Pointer icons can be provided either by the system using system types,
* or by applications using bitmaps or application resources.
* </p>
*/
public final class PointerIcon implements Parcelable {
private static final String TAG = "PointerIcon";
- /** {@hide} Style constant: Custom icon with a user-supplied bitmap. */
- public static final int STYLE_CUSTOM = -1;
+ /** {@hide} Type constant: Custom icon with a user-supplied bitmap. */
+ public static final int TYPE_CUSTOM = -1;
- /** Style constant: Null icon. It has no bitmap. */
- public static final int STYLE_NULL = 0;
+ /** Type constant: Null icon. It has no bitmap. */
+ public static final int TYPE_NULL = 0;
- /** Style constant: no icons are specified. If all views uses this, then falls back
- * to the default style, but this is helpful to distinguish a view explicitly want
+ /** Type constant: no icons are specified. If all views uses this, then falls back
+ * to the default type, but this is helpful to distinguish a view explicitly want
* to have the default icon.
* @hide
*/
- public static final int STYLE_NOT_SPECIFIED = 1;
+ public static final int TYPE_NOT_SPECIFIED = 1;
- /** Style constant: Arrow icon. (Default mouse pointer) */
- public static final int STYLE_ARROW = 1000;
+ /** Type constant: Arrow icon. (Default mouse pointer) */
+ public static final int TYPE_ARROW = 1000;
- /** {@hide} Style constant: Spot hover icon for touchpads. */
- public static final int STYLE_SPOT_HOVER = 2000;
+ /** {@hide} Type constant: Spot hover icon for touchpads. */
+ public static final int TYPE_SPOT_HOVER = 2000;
- /** {@hide} Style constant: Spot touch icon for touchpads. */
- public static final int STYLE_SPOT_TOUCH = 2001;
+ /** {@hide} Type constant: Spot touch icon for touchpads. */
+ public static final int TYPE_SPOT_TOUCH = 2001;
- /** {@hide} Style constant: Spot anchor icon for touchpads. */
- public static final int STYLE_SPOT_ANCHOR = 2002;
+ /** {@hide} Type constant: Spot anchor icon for touchpads. */
+ public static final int TYPE_SPOT_ANCHOR = 2002;
- // Style constants for additional predefined icons for mice.
- /** Style constant: context-menu. */
- public static final int STYLE_CONTEXT_MENU = 1001;
+ // Type constants for additional predefined icons for mice.
+ /** Type constant: context-menu. */
+ public static final int TYPE_CONTEXT_MENU = 1001;
- /** Style constant: hand. */
- public static final int STYLE_HAND = 1002;
+ /** Type constant: hand. */
+ public static final int TYPE_HAND = 1002;
- /** Style constant: help. */
- public static final int STYLE_HELP = 1003;
+ /** Type constant: help. */
+ public static final int TYPE_HELP = 1003;
- /** Style constant: wait. */
- public static final int STYLE_WAIT = 1004;
+ /** Type constant: wait. */
+ public static final int TYPE_WAIT = 1004;
- /** Style constant: cell. */
- public static final int STYLE_CELL = 1006;
+ /** Type constant: cell. */
+ public static final int TYPE_CELL = 1006;
- /** Style constant: crosshair. */
- public static final int STYLE_CROSSHAIR = 1007;
+ /** Type constant: crosshair. */
+ public static final int TYPE_CROSSHAIR = 1007;
- /** Style constant: text. */
- public static final int STYLE_TEXT = 1008;
+ /** Type constant: text. */
+ public static final int TYPE_TEXT = 1008;
- /** Style constant: vertical-text. */
- public static final int STYLE_VERTICAL_TEXT = 1009;
+ /** Type constant: vertical-text. */
+ public static final int TYPE_VERTICAL_TEXT = 1009;
- /** Style constant: alias (indicating an alias of/shortcut to something is
+ /** Type constant: alias (indicating an alias of/shortcut to something is
* to be created. */
- public static final int STYLE_ALIAS = 1010;
+ public static final int TYPE_ALIAS = 1010;
- /** Style constant: copy. */
- public static final int STYLE_COPY = 1011;
+ /** Type constant: copy. */
+ public static final int TYPE_COPY = 1011;
- /** Style constant: no-drop. */
- public static final int STYLE_NO_DROP = 1012;
+ /** Type constant: no-drop. */
+ public static final int TYPE_NO_DROP = 1012;
- /** Style constant: all-scroll. */
- public static final int STYLE_ALL_SCROLL = 1013;
+ /** Type constant: all-scroll. */
+ public static final int TYPE_ALL_SCROLL = 1013;
- /** Style constant: horizontal double arrow mainly for resizing. */
- public static final int STYLE_HORIZONTAL_DOUBLE_ARROW = 1014;
+ /** Type constant: horizontal double arrow mainly for resizing. */
+ public static final int TYPE_HORIZONTAL_DOUBLE_ARROW = 1014;
- /** Style constant: vertical double arrow mainly for resizing. */
- public static final int STYLE_VERTICAL_DOUBLE_ARROW = 1015;
+ /** Type constant: vertical double arrow mainly for resizing. */
+ public static final int TYPE_VERTICAL_DOUBLE_ARROW = 1015;
- /** Style constant: diagonal double arrow -- top-right to bottom-left. */
- public static final int STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016;
+ /** Type constant: diagonal double arrow -- top-right to bottom-left. */
+ public static final int TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW = 1016;
- /** Style constant: diagonal double arrow -- top-left to bottom-right. */
- public static final int STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017;
+ /** Type constant: diagonal double arrow -- top-left to bottom-right. */
+ public static final int TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW = 1017;
- /** Style constant: zoom-in. */
- public static final int STYLE_ZOOM_IN = 1018;
+ /** Type constant: zoom-in. */
+ public static final int TYPE_ZOOM_IN = 1018;
- /** Style constant: zoom-out. */
- public static final int STYLE_ZOOM_OUT = 1019;
+ /** Type constant: zoom-out. */
+ public static final int TYPE_ZOOM_OUT = 1019;
- /** Style constant: grab. */
- public static final int STYLE_GRAB = 1020;
+ /** Type constant: grab. */
+ public static final int TYPE_GRAB = 1020;
- /** Style constant: grabbing. */
- public static final int STYLE_GRABBING = 1021;
+ /** Type constant: grabbing. */
+ public static final int TYPE_GRABBING = 1021;
- // OEM private styles should be defined starting at this range to avoid
- // conflicts with any system styles that may be defined in the future.
- private static final int STYLE_OEM_FIRST = 10000;
+ // OEM private types should be defined starting at this range to avoid
+ // conflicts with any system types that may be defined in the future.
+ private static final int TYPE_OEM_FIRST = 10000;
/** The default pointer icon. */
- public static final int STYLE_DEFAULT = STYLE_ARROW;
+ public static final int TYPE_DEFAULT = TYPE_ARROW;
- private static final PointerIcon gNullIcon = new PointerIcon(STYLE_NULL);
+ private static final PointerIcon gNullIcon = new PointerIcon(TYPE_NULL);
private static final SparseArray<PointerIcon> gSystemIcons = new SparseArray<PointerIcon>();
private static boolean sUseLargeIcons = false;
- private final int mStyle;
+ private final int mType;
private int mSystemIconResourceId;
private Bitmap mBitmap;
private float mHotSpotX;
@@ -151,8 +151,8 @@
private Bitmap mBitmapFrames[];
private int mDurationPerFrame;
- private PointerIcon(int style) {
- mStyle = style;
+ private PointerIcon(int type) {
+ mType = type;
}
/**
@@ -160,7 +160,7 @@
*
* @return The null pointer icon.
*
- * @see #STYLE_NULL
+ * @see #TYPE_NULL
* @hide
*/
public static PointerIcon getNullIcon() {
@@ -177,36 +177,36 @@
* @hide
*/
public static PointerIcon getDefaultIcon(@NonNull Context context) {
- return getSystemIcon(context, STYLE_DEFAULT);
+ return getSystemIcon(context, TYPE_DEFAULT);
}
/**
- * Gets a system pointer icon for the given style.
- * If style is not recognized, returns the default pointer icon.
+ * Gets a system pointer icon for the given type.
+ * If typeis not recognized, returns the default pointer icon.
*
* @param context The context.
- * @param style The pointer icon style.
+ * @param type The pointer icon type.
* @return The pointer icon.
*
* @throws IllegalArgumentException if context is null.
*/
- public static PointerIcon getSystemIcon(@NonNull Context context, int style) {
+ public static PointerIcon getSystemIcon(@NonNull Context context, int type) {
if (context == null) {
throw new IllegalArgumentException("context must not be null");
}
- if (style == STYLE_NULL) {
+ if (type == TYPE_NULL) {
return gNullIcon;
}
- PointerIcon icon = gSystemIcons.get(style);
+ PointerIcon icon = gSystemIcons.get(type);
if (icon != null) {
return icon;
}
- int styleIndex = getSystemIconStyleIndex(style);
- if (styleIndex == 0) {
- styleIndex = getSystemIconStyleIndex(STYLE_DEFAULT);
+ int typeIndex = getSystemIconTypeIndex(type);
+ if (typeIndex == 0) {
+ typeIndex = getSystemIconTypeIndex(TYPE_DEFAULT);
}
int defStyle = sUseLargeIcons ?
@@ -214,21 +214,21 @@
TypedArray a = context.obtainStyledAttributes(null,
com.android.internal.R.styleable.Pointer,
0, defStyle);
- int resourceId = a.getResourceId(styleIndex, -1);
+ int resourceId = a.getResourceId(typeIndex, -1);
a.recycle();
if (resourceId == -1) {
- Log.w(TAG, "Missing theme resources for pointer icon style " + style);
- return style == STYLE_DEFAULT ? gNullIcon : getSystemIcon(context, STYLE_DEFAULT);
+ Log.w(TAG, "Missing theme resources for pointer icon type " + type);
+ return type == TYPE_DEFAULT ? gNullIcon : getSystemIcon(context, TYPE_DEFAULT);
}
- icon = new PointerIcon(style);
+ icon = new PointerIcon(type);
if ((resourceId & 0xff000000) == 0x01000000) {
icon.mSystemIconResourceId = resourceId;
} else {
icon.loadResource(context, context.getResources(), resourceId);
}
- gSystemIcons.append(style, icon);
+ gSystemIcons.append(type, icon);
return icon;
}
@@ -242,7 +242,7 @@
}
/**
- * Creates a custom pointer from the given bitmap and hotspot information.
+ * Creates a custom pointer icon from the given bitmap and hotspot information.
*
* @param bitmap The bitmap for the icon.
* @param hotSpotX The X offset of the pointer icon hotspot in the bitmap.
@@ -254,14 +254,13 @@
* @throws IllegalArgumentException if bitmap is null, or if the x/y hotspot
* parameters are invalid.
*/
- public static PointerIcon createCustomIcon(
- @NonNull Bitmap bitmap, float hotSpotX, float hotSpotY) {
+ public static PointerIcon create(@NonNull Bitmap bitmap, float hotSpotX, float hotSpotY) {
if (bitmap == null) {
throw new IllegalArgumentException("bitmap must not be null");
}
validateHotSpot(bitmap, hotSpotX, hotSpotY);
- PointerIcon icon = new PointerIcon(STYLE_CUSTOM);
+ PointerIcon icon = new PointerIcon(TYPE_CUSTOM);
icon.mBitmap = bitmap;
icon.mHotSpotX = hotSpotX;
icon.mHotSpotY = hotSpotY;
@@ -289,12 +288,12 @@
* @throws Resources.NotFoundException if the resource was not found or the drawable
* linked in the resource was not found.
*/
- public static PointerIcon loadCustomIcon(@NonNull Resources resources, @XmlRes int resourceId) {
+ public static PointerIcon load(@NonNull Resources resources, @XmlRes int resourceId) {
if (resources == null) {
throw new IllegalArgumentException("resources must not be null");
}
- PointerIcon icon = new PointerIcon(STYLE_CUSTOM);
+ PointerIcon icon = new PointerIcon(TYPE_CUSTOM);
icon.loadResource(null, resources, resourceId);
return icon;
}
@@ -318,28 +317,28 @@
return this;
}
- PointerIcon result = new PointerIcon(mStyle);
+ PointerIcon result = new PointerIcon(mType);
result.mSystemIconResourceId = mSystemIconResourceId;
result.loadResource(context, context.getResources(), mSystemIconResourceId);
return result;
}
/** @hide */
- public int getStyle() {
- return mStyle;
+ public int getType() {
+ return mType;
}
public static final Parcelable.Creator<PointerIcon> CREATOR
= new Parcelable.Creator<PointerIcon>() {
public PointerIcon createFromParcel(Parcel in) {
- int style = in.readInt();
- if (style == STYLE_NULL) {
+ int type = in.readInt();
+ if (type == TYPE_NULL) {
return getNullIcon();
}
int systemIconResourceId = in.readInt();
if (systemIconResourceId != 0) {
- PointerIcon icon = new PointerIcon(style);
+ PointerIcon icon = new PointerIcon(type);
icon.mSystemIconResourceId = systemIconResourceId;
return icon;
}
@@ -347,7 +346,7 @@
Bitmap bitmap = Bitmap.CREATOR.createFromParcel(in);
float hotSpotX = in.readFloat();
float hotSpotY = in.readFloat();
- return PointerIcon.createCustomIcon(bitmap, hotSpotX, hotSpotY);
+ return PointerIcon.create(bitmap, hotSpotX, hotSpotY);
}
public PointerIcon[] newArray(int size) {
@@ -360,9 +359,9 @@
}
public void writeToParcel(Parcel out, int flags) {
- out.writeInt(mStyle);
+ out.writeInt(mType);
- if (mStyle != STYLE_NULL) {
+ if (mType != TYPE_NULL) {
out.writeInt(mSystemIconResourceId);
if (mSystemIconResourceId == 0) {
mBitmap.writeToParcel(out, flags);
@@ -383,7 +382,7 @@
}
PointerIcon otherIcon = (PointerIcon) other;
- if (mStyle != otherIcon.mStyle
+ if (mType != otherIcon.mType
|| mSystemIconResourceId != otherIcon.mSystemIconResourceId) {
return false;
}
@@ -477,57 +476,57 @@
}
}
- private static int getSystemIconStyleIndex(int style) {
- switch (style) {
- case STYLE_ARROW:
+ private static int getSystemIconTypeIndex(int type) {
+ switch (type) {
+ case TYPE_ARROW:
return com.android.internal.R.styleable.Pointer_pointerIconArrow;
- case STYLE_SPOT_HOVER:
+ case TYPE_SPOT_HOVER:
return com.android.internal.R.styleable.Pointer_pointerIconSpotHover;
- case STYLE_SPOT_TOUCH:
+ case TYPE_SPOT_TOUCH:
return com.android.internal.R.styleable.Pointer_pointerIconSpotTouch;
- case STYLE_SPOT_ANCHOR:
+ case TYPE_SPOT_ANCHOR:
return com.android.internal.R.styleable.Pointer_pointerIconSpotAnchor;
- case STYLE_HAND:
+ case TYPE_HAND:
return com.android.internal.R.styleable.Pointer_pointerIconHand;
- case STYLE_CONTEXT_MENU:
+ case TYPE_CONTEXT_MENU:
return com.android.internal.R.styleable.Pointer_pointerIconContextMenu;
- case STYLE_HELP:
+ case TYPE_HELP:
return com.android.internal.R.styleable.Pointer_pointerIconHelp;
- case STYLE_WAIT:
+ case TYPE_WAIT:
return com.android.internal.R.styleable.Pointer_pointerIconWait;
- case STYLE_CELL:
+ case TYPE_CELL:
return com.android.internal.R.styleable.Pointer_pointerIconCell;
- case STYLE_CROSSHAIR:
+ case TYPE_CROSSHAIR:
return com.android.internal.R.styleable.Pointer_pointerIconCrosshair;
- case STYLE_TEXT:
+ case TYPE_TEXT:
return com.android.internal.R.styleable.Pointer_pointerIconText;
- case STYLE_VERTICAL_TEXT:
+ case TYPE_VERTICAL_TEXT:
return com.android.internal.R.styleable.Pointer_pointerIconVerticalText;
- case STYLE_ALIAS:
+ case TYPE_ALIAS:
return com.android.internal.R.styleable.Pointer_pointerIconAlias;
- case STYLE_COPY:
+ case TYPE_COPY:
return com.android.internal.R.styleable.Pointer_pointerIconCopy;
- case STYLE_ALL_SCROLL:
+ case TYPE_ALL_SCROLL:
return com.android.internal.R.styleable.Pointer_pointerIconAllScroll;
- case STYLE_NO_DROP:
+ case TYPE_NO_DROP:
return com.android.internal.R.styleable.Pointer_pointerIconNodrop;
- case STYLE_HORIZONTAL_DOUBLE_ARROW:
+ case TYPE_HORIZONTAL_DOUBLE_ARROW:
return com.android.internal.R.styleable.Pointer_pointerIconHorizontalDoubleArrow;
- case STYLE_VERTICAL_DOUBLE_ARROW:
+ case TYPE_VERTICAL_DOUBLE_ARROW:
return com.android.internal.R.styleable.Pointer_pointerIconVerticalDoubleArrow;
- case STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW:
+ case TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW:
return com.android.internal.R.styleable.
Pointer_pointerIconTopRightDiagonalDoubleArrow;
- case STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW:
+ case TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW:
return com.android.internal.R.styleable.
Pointer_pointerIconTopLeftDiagonalDoubleArrow;
- case STYLE_ZOOM_IN:
+ case TYPE_ZOOM_IN:
return com.android.internal.R.styleable.Pointer_pointerIconZoomIn;
- case STYLE_ZOOM_OUT:
+ case TYPE_ZOOM_OUT:
return com.android.internal.R.styleable.Pointer_pointerIconZoomOut;
- case STYLE_GRAB:
+ case TYPE_GRAB:
return com.android.internal.R.styleable.Pointer_pointerIconGrab;
- case STYLE_GRABBING:
+ case TYPE_GRABBING:
return com.android.internal.R.styleable.Pointer_pointerIconGrabbing;
default:
return 0;
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 867937f..ade1733 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2644,7 +2644,7 @@
private static final int PFLAG3_POINTER_ICON_NOT_SPECIFIED = 0 << PFLAG3_POINTER_ICON_LSHIFT;
/**
- * Value indicating {@link PointerIcon.STYLE_NULL}.
+ * Value indicating {@link PointerIcon.TYPE_NULL}.
*/
private static final int PFLAG3_POINTER_ICON_NULL = 1 << PFLAG3_POINTER_ICON_LSHIFT;
@@ -4544,12 +4544,12 @@
case R.styleable.View_pointerIcon:
final int resourceId = a.getResourceId(attr, 0);
if (resourceId != 0) {
- setPointerIcon(PointerIcon.loadCustomIcon(
+ setPointerIcon(PointerIcon.load(
context.getResources(), resourceId));
} else {
- final int pointerShape = a.getInt(attr, PointerIcon.STYLE_NOT_SPECIFIED);
- if (pointerShape != PointerIcon.STYLE_NOT_SPECIFIED) {
- setPointerIcon(PointerIcon.getSystemIcon(context, pointerShape));
+ final int pointerType = a.getInt(attr, PointerIcon.TYPE_NOT_SPECIFIED);
+ if (pointerType != PointerIcon.TYPE_NOT_SPECIFIED) {
+ setPointerIcon(PointerIcon.getSystemIcon(context, pointerType));
}
}
break;
@@ -21805,19 +21805,22 @@
* The default implementation does not care the location or event types, but some subclasses
* may use it (such as WebViews).
* @param event The MotionEvent from a mouse
- * @param x The x position of the event, local to the view
- * @param y The y position of the event, local to the view
+ * @param pointerIndex The index of the pointer for which to retrieve the {@link PointerIcon}.
+ * This will be between 0 and {@link MotionEvent#getPointerCount()}.
* @see PointerIcon
*/
- public PointerIcon getPointerIcon(MotionEvent event, float x, float y) {
+ public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
+ final float x = event.getX(pointerIndex);
+ final float y = event.getY(pointerIndex);
if (isDraggingScrollBar() || isOnScrollbarThumb(x, y)) {
- return PointerIcon.getSystemIcon(mContext, PointerIcon.STYLE_ARROW);
+ return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_ARROW);
}
return mPointerIcon;
}
/**
* Set the pointer icon for the current view.
+ * Passing {@code null} will restore the pointer icon to its default value.
* @param pointerIcon A PointerIcon instance which will be shown when the mouse hovers.
*/
public void setPointerIcon(PointerIcon pointerIcon) {
@@ -21832,10 +21835,18 @@
}
/**
+ * Gets the pointer icon for the current view.
+ */
+ public PointerIcon getPointerIcon() {
+ return mPointerIcon;
+ }
+
+
+ /**
* Request capturing further mouse events.
*
- * When the view captures, the mouse pointer icon will disappear and will not change its
- * position. Further mouse events will come to the capturing view, and the mouse movements
+ * When the view captures, the pointer icon will disappear and will not change its
+ * position. Further pointer events will come to the capturing view, and the pointer movements
* will can be detected through {@link MotionEvent#AXIS_RELATIVE_X} and
* {@link MotionEvent#AXIS_RELATIVE_Y}. Non-mouse events (touchscreens, or stylus) will not
* be affected.
@@ -21847,10 +21858,10 @@
* @see #releasePointerCapture()
* @see #hasPointerCapture()
*/
- public void setPointerCapture() {
+ public void requestPointerCapture() {
final ViewRootImpl viewRootImpl = getViewRootImpl();
if (viewRootImpl != null) {
- viewRootImpl.setPointerCapture(this);
+ viewRootImpl.requestPointerCapture(this);
}
}
@@ -21859,7 +21870,7 @@
* Release the current capture of mouse events.
*
* If the view does not have the capture, it will do nothing.
- * @see #setPointerCapture()
+ * @see #requestPointerCapture()
* @see #hasPointerCapture()
*/
public void releasePointerCapture() {
@@ -21873,7 +21884,7 @@
* Checks the capture status of mouse events.
*
* @return true if the view has the capture.
- * @see #setPointerCapture()
+ * @see #requestPointerCapture()
* @see #hasPointerCapture()
*/
public boolean hasPointerCapture() {
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 37f9b71..c682d09 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -1715,9 +1715,11 @@
}
@Override
- public PointerIcon getPointerIcon(MotionEvent event, float x, float y) {
+ public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
+ final float x = event.getX(pointerIndex);
+ final float y = event.getY(pointerIndex);
if (isOnScrollbarThumb(x, y) || isDraggingScrollBar()) {
- return PointerIcon.getSystemIcon(mContext, PointerIcon.STYLE_ARROW);
+ return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_ARROW);
}
// Check what the child under the pointer says about the pointer.
final int childrenCount = mChildrenCount;
@@ -1731,7 +1733,8 @@
final View child = getAndVerifyPreorderedView(preorderedList, children, childIndex);
final PointF point = getLocalPoint();
if (isTransformedTouchPointInView(x, y, child, point)) {
- final PointerIcon pointerIcon = child.getPointerIcon(event, point.x, point.y);
+ final PointerIcon pointerIcon =
+ dispatchResolvePointerIcon(event, pointerIndex, child);
if (pointerIcon != null) {
if (preorderedList != null) preorderedList.clear();
return pointerIcon;
@@ -1744,7 +1747,24 @@
// The pointer is not a child or the child has no preferences, returning the default
// implementation.
- return super.getPointerIcon(event, x, y);
+ return super.onResolvePointerIcon(event, pointerIndex);
+ }
+
+ private PointerIcon dispatchResolvePointerIcon(MotionEvent event, int pointerIndex,
+ View child) {
+ final PointerIcon pointerIcon;
+ if (!child.hasIdentityMatrix()) {
+ MotionEvent transformedEvent = getTransformedMotionEvent(event, child);
+ pointerIcon = child.onResolvePointerIcon(transformedEvent, pointerIndex);
+ transformedEvent.recycle();
+ } else {
+ final float offsetX = mScrollX - child.mLeft;
+ final float offsetY = mScrollY - child.mTop;
+ event.offsetLocation(offsetX, offsetY);
+ pointerIcon = child.onResolvePointerIcon(event, pointerIndex);
+ event.offsetLocation(-offsetX, -offsetY);
+ }
+ return pointerIcon;
}
private int getAndVerifyPreorderedIndex(int childrenCount, int i, boolean customOrder) {
@@ -2125,17 +2145,14 @@
* @return {@code true} if the child handled the event.
*/
private boolean dispatchTransformedGenericPointerEvent(MotionEvent event, View child) {
- final float offsetX = mScrollX - child.mLeft;
- final float offsetY = mScrollY - child.mTop;
-
boolean handled;
if (!child.hasIdentityMatrix()) {
- MotionEvent transformedEvent = MotionEvent.obtain(event);
- transformedEvent.offsetLocation(offsetX, offsetY);
- transformedEvent.transform(child.getInverseMatrix());
+ MotionEvent transformedEvent = getTransformedMotionEvent(event, child);
handled = child.dispatchGenericMotionEvent(transformedEvent);
transformedEvent.recycle();
} else {
+ final float offsetX = mScrollX - child.mLeft;
+ final float offsetY = mScrollY - child.mTop;
event.offsetLocation(offsetX, offsetY);
handled = child.dispatchGenericMotionEvent(event);
event.offsetLocation(-offsetX, -offsetY);
@@ -2143,6 +2160,26 @@
return handled;
}
+ /**
+ * Returns a MotionEvent that's been transformed into the child's local coordinates.
+ *
+ * It's the responsibility of the caller to recycle it once they're finished with it.
+ * @param event The event to transform.
+ * @param child The view whose coordinate space is to be used.
+ * @return A copy of the the given MotionEvent, transformed into the given View's coordinate
+ * space.
+ */
+ private MotionEvent getTransformedMotionEvent(MotionEvent event, View child) {
+ final float offsetX = mScrollX - child.mLeft;
+ final float offsetY = mScrollY - child.mTop;
+ final MotionEvent transformedEvent = MotionEvent.obtain(event);
+ transformedEvent.offsetLocation(offsetX, offsetY);
+ if (!child.hasIdentityMatrix()) {
+ transformedEvent.transform(child.getInverseMatrix());
+ }
+ return transformedEvent;
+ }
+
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (mInputEventConsistencyVerifier != null) {
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index f83ab9a..7a8ee3a 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -359,7 +359,7 @@
private long mFpsPrevTime = -1;
private int mFpsNumFrames;
- private int mPointerIconShape = PointerIcon.STYLE_NOT_SPECIFIED;
+ private int mPointerIconType = PointerIcon.TYPE_NOT_SPECIFIED;
private PointerIcon mCustomPointerIcon = null;
/**
@@ -3189,7 +3189,7 @@
}
}
- void setPointerCapture(View view) {
+ void requestPointerCapture(View view) {
if (!mAttachInfo.mHasWindowFocus) {
Log.w(mTag, "Can't set capture if it's not focused.");
return;
@@ -3199,6 +3199,7 @@
}
mCapturingView = view;
InputManager.getInstance().setPointerIconDetached(true);
+ return;
}
void releasePointerCapture(View view) {
@@ -4466,19 +4467,18 @@
}
private void maybeUpdatePointerIcon(MotionEvent event) {
- if (event.getPointerCount() == 1
- && event.isFromSource(InputDevice.SOURCE_MOUSE)) {
+ if (event.getPointerCount() == 1 && event.isFromSource(InputDevice.SOURCE_MOUSE)) {
if (event.getActionMasked() == MotionEvent.ACTION_HOVER_ENTER
|| event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) {
- // Other apps or the window manager may change the icon shape outside of
- // this app, therefore the icon shape has to be reset on enter/exit event.
- mPointerIconShape = PointerIcon.STYLE_NOT_SPECIFIED;
+ // Other apps or the window manager may change the icon type outside of
+ // this app, therefore the icon type has to be reset on enter/exit event.
+ mPointerIconType = PointerIcon.TYPE_NOT_SPECIFIED;
}
if (event.getActionMasked() != MotionEvent.ACTION_HOVER_EXIT) {
if (!updatePointerIcon(event) &&
event.getActionMasked() == MotionEvent.ACTION_HOVER_MOVE) {
- mPointerIconShape = PointerIcon.STYLE_NOT_SPECIFIED;
+ mPointerIconType = PointerIcon.TYPE_NOT_SPECIFIED;
}
}
}
@@ -4505,13 +4505,14 @@
}
private void resetPointerIcon(MotionEvent event) {
- mPointerIconShape = PointerIcon.STYLE_NOT_SPECIFIED;
+ mPointerIconType = PointerIcon.TYPE_NOT_SPECIFIED;
updatePointerIcon(event);
}
private boolean updatePointerIcon(MotionEvent event) {
- final float x = event.getX();
- final float y = event.getY();
+ final int pointerIndex = 0;
+ final float x = event.getX(pointerIndex);
+ final float y = event.getY(pointerIndex);
if (mView == null) {
// E.g. click outside a popup to dismiss it
Slog.d(mTag, "updatePointerIcon called after view was removed");
@@ -4522,19 +4523,19 @@
Slog.d(mTag, "updatePointerIcon called with position out of bounds");
return false;
}
- final PointerIcon pointerIcon = mView.getPointerIcon(event, x, y);
- final int pointerShape = (pointerIcon != null) ?
- pointerIcon.getStyle() : PointerIcon.STYLE_DEFAULT;
+ final PointerIcon pointerIcon = mView.onResolvePointerIcon(event, pointerIndex);
+ final int pointerType = (pointerIcon != null) ?
+ pointerIcon.getType() : PointerIcon.TYPE_DEFAULT;
- if (mPointerIconShape != pointerShape) {
- mPointerIconShape = pointerShape;
- if (mPointerIconShape != PointerIcon.STYLE_CUSTOM) {
+ if (mPointerIconType != pointerType) {
+ mPointerIconType = pointerType;
+ if (mPointerIconType != PointerIcon.TYPE_CUSTOM) {
mCustomPointerIcon = null;
- InputManager.getInstance().setPointerIconShape(pointerShape);
+ InputManager.getInstance().setPointerIconType(pointerType);
return true;
}
}
- if (mPointerIconShape == PointerIcon.STYLE_CUSTOM &&
+ if (mPointerIconType == PointerIcon.TYPE_CUSTOM &&
!pointerIcon.equals(mCustomPointerIcon)) {
mCustomPointerIcon = pointerIcon;
InputManager.getInstance().setCustomPointerIcon(mCustomPointerIcon);
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 2012d7c..72bfc88 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -6009,19 +6009,21 @@
}
@Override
- public PointerIcon getPointerIcon(MotionEvent event, float x, float y) {
+ public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
if (mText instanceof Spannable && mLinksClickable) {
+ final float x = event.getX(pointerIndex);
+ final float y = event.getY(pointerIndex);
final int offset = getOffsetForPosition(x, y);
final ClickableSpan[] clickables = ((Spannable) mText).getSpans(offset, offset,
ClickableSpan.class);
if (clickables.length > 0) {
- return PointerIcon.getSystemIcon(mContext, PointerIcon.STYLE_HAND);
+ return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_HAND);
}
}
if (isTextSelectable() || isTextEditable()) {
- return PointerIcon.getSystemIcon(mContext, PointerIcon.STYLE_TEXT);
+ return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_TEXT);
}
- return super.getPointerIcon(event, x, y);
+ return super.onResolvePointerIcon(event, pointerIndex);
}
@Override
diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java
index 52d2e0a..c9c8292 100644
--- a/core/java/com/android/internal/view/BaseIWindow.java
+++ b/core/java/com/android/internal/view/BaseIWindow.java
@@ -95,7 +95,7 @@
@Override
public void updatePointerIcon(float x, float y) {
- InputManager.getInstance().setPointerIconShape(PointerIcon.STYLE_NOT_SPECIFIED);
+ InputManager.getInstance().setPointerIconType(PointerIcon.TYPE_NOT_SPECIFIED);
}
@Override
diff --git a/core/jni/android_view_PointerIcon.cpp b/core/jni/android_view_PointerIcon.cpp
index 71be52e..6b634df 100644
--- a/core/jni/android_view_PointerIcon.cpp
+++ b/core/jni/android_view_PointerIcon.cpp
@@ -32,7 +32,7 @@
static struct {
jclass clazz;
- jfieldID mStyle;
+ jfieldID mType;
jfieldID mBitmap;
jfieldID mHotSpotX;
jfieldID mHotSpotY;
@@ -78,7 +78,7 @@
status_t android_view_PointerIcon_getLoadedIcon(JNIEnv* env, jobject pointerIconObj,
PointerIcon* outPointerIcon) {
- outPointerIcon->style = env->GetIntField(pointerIconObj, gPointerIconClassInfo.mStyle);
+ outPointerIcon->style = env->GetIntField(pointerIconObj, gPointerIconClassInfo.mType);
outPointerIcon->hotSpotX = env->GetFloatField(pointerIconObj, gPointerIconClassInfo.mHotSpotX);
outPointerIcon->hotSpotY = env->GetFloatField(pointerIconObj, gPointerIconClassInfo.mHotSpotY);
@@ -128,8 +128,8 @@
gPointerIconClassInfo.mBitmap = GetFieldIDOrDie(env, gPointerIconClassInfo.clazz,
"mBitmap", "Landroid/graphics/Bitmap;");
- gPointerIconClassInfo.mStyle = GetFieldIDOrDie(env, gPointerIconClassInfo.clazz,
- "mStyle", "I");
+ gPointerIconClassInfo.mType = GetFieldIDOrDie(env, gPointerIconClassInfo.clazz,
+ "mType", "I");
gPointerIconClassInfo.mHotSpotX = GetFieldIDOrDie(env, gPointerIconClassInfo.clazz,
"mHotSpotX", "F");
diff --git a/libs/input/PointerController.cpp b/libs/input/PointerController.cpp
index 212c6a0..ad9e2d7 100644
--- a/libs/input/PointerController.cpp
+++ b/libs/input/PointerController.cpp
@@ -84,7 +84,7 @@
mLocked.pointerAlpha = 0.0f; // pointer is initially faded
mLocked.pointerSprite = mSpriteController->createSprite();
mLocked.pointerIconChanged = false;
- mLocked.requestedPointerShape = mPolicy->getDefaultPointerIconId();
+ mLocked.requestedPointerType = mPolicy->getDefaultPointerIconId();
mLocked.animationFrameIndex = 0;
mLocked.lastFrameUpdatedTime = 0;
@@ -459,10 +459,10 @@
updatePointerLocked();
}
-void PointerController::updatePointerShape(int32_t iconId) {
+void PointerController::updatePointerIcon(int32_t iconId) {
AutoMutex _l(mLock);
- if (mLocked.requestedPointerShape != iconId) {
- mLocked.requestedPointerShape = iconId;
+ if (mLocked.requestedPointerType != iconId) {
+ mLocked.requestedPointerType = iconId;
mLocked.presentationChanged = true;
updatePointerLocked();
}
@@ -473,7 +473,7 @@
const int32_t iconId = mPolicy->getCustomPointerIconId();
mLocked.additionalMouseResources[iconId] = icon;
- mLocked.requestedPointerShape = iconId;
+ mLocked.requestedPointerType = iconId;
mLocked.presentationChanged = true;
updatePointerLocked();
@@ -574,7 +574,7 @@
bool PointerController::doBitmapAnimationLocked(nsecs_t timestamp) {
std::map<int32_t, PointerAnimation>::const_iterator iter = mLocked.animationResources.find(
- mLocked.requestedPointerShape);
+ mLocked.requestedPointerType);
if (iter == mLocked.animationResources.end()) {
return false;
}
@@ -636,14 +636,14 @@
if (mLocked.pointerIconChanged || mLocked.presentationChanged) {
if (mLocked.presentation == PRESENTATION_POINTER) {
- if (mLocked.requestedPointerShape == mPolicy->getDefaultPointerIconId()) {
+ if (mLocked.requestedPointerType == mPolicy->getDefaultPointerIconId()) {
mLocked.pointerSprite->setIcon(mLocked.pointerIcon);
} else {
std::map<int32_t, SpriteIcon>::const_iterator iter =
- mLocked.additionalMouseResources.find(mLocked.requestedPointerShape);
+ mLocked.additionalMouseResources.find(mLocked.requestedPointerType);
if (iter != mLocked.additionalMouseResources.end()) {
std::map<int32_t, PointerAnimation>::const_iterator anim_iter =
- mLocked.animationResources.find(mLocked.requestedPointerShape);
+ mLocked.animationResources.find(mLocked.requestedPointerType);
if (anim_iter != mLocked.animationResources.end()) {
mLocked.animationFrameIndex = 0;
mLocked.lastFrameUpdatedTime = systemTime(SYSTEM_TIME_MONOTONIC);
@@ -651,7 +651,7 @@
}
mLocked.pointerSprite->setIcon(iter->second);
} else {
- ALOGW("Can't find the resource for icon id %d", mLocked.requestedPointerShape);
+ ALOGW("Can't find the resource for icon id %d", mLocked.requestedPointerType);
mLocked.pointerSprite->setIcon(mLocked.pointerIcon);
}
}
diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h
index c1381f3..b47139a 100644
--- a/libs/input/PointerController.h
+++ b/libs/input/PointerController.h
@@ -105,7 +105,7 @@
const uint32_t* spotIdToIndex, BitSet32 spotIdBits);
virtual void clearSpots();
- void updatePointerShape(int32_t iconId);
+ void updatePointerIcon(int32_t iconId);
void setCustomPointerIcon(const SpriteIcon& icon);
void setDisplayViewport(int32_t width, int32_t height, int32_t orientation);
void setInactivityTimeout(InactivityTimeout inactivityTimeout);
@@ -180,7 +180,7 @@
std::map<int32_t, SpriteIcon> additionalMouseResources;
std::map<int32_t, PointerAnimation> animationResources;
- int32_t requestedPointerShape;
+ int32_t requestedPointerType;
int32_t buttonState;
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index ea0ee18..998f50f 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -16,8 +16,8 @@
package com.android.systemui.stackdivider;
-import static android.view.PointerIcon.STYLE_HORIZONTAL_DOUBLE_ARROW;
-import static android.view.PointerIcon.STYLE_VERTICAL_DOUBLE_ARROW;
+import static android.view.PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW;
+import static android.view.PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -266,7 +266,7 @@
boolean landscape = getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE;
mHandle.setPointerIcon(PointerIcon.getSystemIcon(getContext(),
- landscape ? STYLE_HORIZONTAL_DOUBLE_ARROW : STYLE_VERTICAL_DOUBLE_ARROW));
+ landscape ? TYPE_HORIZONTAL_DOUBLE_ARROW : TYPE_VERTICAL_DOUBLE_ARROW));
getViewTreeObserver().addOnComputeInternalInsetsListener(this);
mHandle.setAccessibilityDelegate(mHandleDelegate);
mGestureDetector = new GestureDetector(mContext, new SimpleOnGestureListener() {
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index b5d5486..0daa8ba 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -219,7 +219,7 @@
private static native void nativeReloadDeviceAliases(long ptr);
private static native String nativeDump(long ptr);
private static native void nativeMonitor(long ptr);
- private static native void nativeSetPointerIconShape(long ptr, int iconId);
+ private static native void nativeSetPointerIconType(long ptr, int iconId);
private static native void nativeReloadPointerIcons(long ptr);
private static native void nativeSetCustomPointerIcon(long ptr, PointerIcon icon);
private static native void nativeSetPointerIconDetached(long ptr, boolean detached);
@@ -1691,8 +1691,8 @@
// Binder call
@Override
- public void setPointerIconShape(int iconId) {
- nativeSetPointerIconShape(mPtr, iconId);
+ public void setPointerIconType(int iconId) {
+ nativeSetPointerIconType(mPtr, iconId);
}
// Binder call
diff --git a/services/core/java/com/android/server/wm/DragState.java b/services/core/java/com/android/server/wm/DragState.java
index 0539b05..c4eca08 100644
--- a/services/core/java/com/android/server/wm/DragState.java
+++ b/services/core/java/com/android/server/wm/DragState.java
@@ -584,7 +584,7 @@
void overridePointerIconLw(int touchSource) {
mTouchSource = touchSource;
if (isFromSource(InputDevice.SOURCE_MOUSE)) {
- InputManager.getInstance().setPointerIconShape(PointerIcon.STYLE_GRABBING);
+ InputManager.getInstance().setPointerIconType(PointerIcon.TYPE_GRABBING);
}
}
}
diff --git a/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java b/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java
index 83cc1ee..73ce0f2 100644
--- a/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java
+++ b/services/core/java/com/android/server/wm/TaskTapPointerEventListener.java
@@ -25,11 +25,11 @@
import com.android.server.wm.WindowManagerService.H;
-import static android.view.PointerIcon.STYLE_NOT_SPECIFIED;
-import static android.view.PointerIcon.STYLE_HORIZONTAL_DOUBLE_ARROW;
-import static android.view.PointerIcon.STYLE_VERTICAL_DOUBLE_ARROW;
-import static android.view.PointerIcon.STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
-import static android.view.PointerIcon.STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
+import static android.view.PointerIcon.TYPE_NOT_SPECIFIED;
+import static android.view.PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW;
+import static android.view.PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
+import static android.view.PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
+import static android.view.PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
public class TaskTapPointerEventListener implements PointerEventListener {
@@ -41,7 +41,7 @@
private boolean mTwoFingerScrolling;
private boolean mInGestureDetection;
private GestureDetector mGestureDetector;
- private int mPointerIconShape = STYLE_NOT_SPECIFIED;
+ private int mPointerIconType = TYPE_NOT_SPECIFIED;
public TaskTapPointerEventListener(WindowManagerService service,
DisplayContent displayContent) {
@@ -87,33 +87,33 @@
final int x = (int) motionEvent.getX();
final int y = (int) motionEvent.getY();
final Task task = mDisplayContent.findTaskForControlPoint(x, y);
- int iconShape = STYLE_NOT_SPECIFIED;
+ int iconType = TYPE_NOT_SPECIFIED;
if (task != null) {
task.getDimBounds(mTmpRect);
if (!mTmpRect.isEmpty() && !mTmpRect.contains(x, y)) {
if (x < mTmpRect.left) {
- iconShape =
- (y < mTmpRect.top) ? STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW :
- (y > mTmpRect.bottom) ? STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW :
- STYLE_HORIZONTAL_DOUBLE_ARROW;
+ iconType =
+ (y < mTmpRect.top) ? TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW :
+ (y > mTmpRect.bottom) ? TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW :
+ TYPE_HORIZONTAL_DOUBLE_ARROW;
} else if (x > mTmpRect.right) {
- iconShape =
- (y < mTmpRect.top) ? STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW :
- (y > mTmpRect.bottom) ? STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW :
- STYLE_HORIZONTAL_DOUBLE_ARROW;
+ iconType =
+ (y < mTmpRect.top) ? TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW :
+ (y > mTmpRect.bottom) ? TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW :
+ TYPE_HORIZONTAL_DOUBLE_ARROW;
} else if (y < mTmpRect.top || y > mTmpRect.bottom) {
- iconShape = STYLE_VERTICAL_DOUBLE_ARROW;
+ iconType = TYPE_VERTICAL_DOUBLE_ARROW;
}
}
}
- if (mPointerIconShape != iconShape) {
- mPointerIconShape = iconShape;
- if (mPointerIconShape == STYLE_NOT_SPECIFIED) {
+ if (mPointerIconType != iconType) {
+ mPointerIconType = iconType;
+ if (mPointerIconType == TYPE_NOT_SPECIFIED) {
// Find the underlying window and ask it restore the pointer icon.
mService.mH.obtainMessage(H.RESTORE_POINTER_ICON,
x, y, mDisplayContent).sendToTarget();
} else {
- InputManager.getInstance().setPointerIconShape(mPointerIconShape);
+ InputManager.getInstance().setPointerIconType(mPointerIconType);
}
}
} break;
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 8c010bb..47b184e 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -11135,7 +11135,7 @@
Slog.w(TAG_WM, "unable to restore pointer icon");
}
} else {
- InputManager.getInstance().setPointerIconShape(PointerIcon.STYLE_DEFAULT);
+ InputManager.getInstance().setPointerIconType(PointerIcon.TYPE_DEFAULT);
}
}
diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp
index 197c043..e8237ef 100644
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -204,7 +204,7 @@
void setShowTouches(bool enabled);
void setInteractive(bool interactive);
void reloadCalibration();
- void setPointerIconShape(int32_t iconId);
+ void setPointerIconType(int32_t iconId);
void reloadPointerIcons();
void setCustomPointerIcon(const SpriteIcon& icon);
void setPointerIconDetached(bool detached);
@@ -785,11 +785,11 @@
InputReaderConfiguration::CHANGE_TOUCH_AFFINE_TRANSFORMATION);
}
-void NativeInputManager::setPointerIconShape(int32_t iconId) {
+void NativeInputManager::setPointerIconType(int32_t iconId) {
AutoMutex _l(mLock);
sp<PointerController> controller = mLocked.pointerController.promote();
if (controller != NULL) {
- controller->updatePointerShape(iconId);
+ controller->updatePointerIcon(iconId);
}
}
@@ -1462,9 +1462,9 @@
im->getInputManager()->getDispatcher()->monitor();
}
-static void nativeSetPointerIconShape(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jint iconId) {
+static void nativeSetPointerIconType(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jint iconId) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
- im->setPointerIconShape(iconId);
+ im->setPointerIconType(iconId);
}
static void nativeReloadPointerIcons(JNIEnv* /* env */, jclass /* clazz */, jlong ptr) {
@@ -1548,8 +1548,8 @@
(void*) nativeDump },
{ "nativeMonitor", "(J)V",
(void*) nativeMonitor },
- { "nativeSetPointerIconShape", "(JI)V",
- (void*) nativeSetPointerIconShape },
+ { "nativeSetPointerIconType", "(JI)V",
+ (void*) nativeSetPointerIconType },
{ "nativeReloadPointerIcons", "(J)V",
(void*) nativeReloadPointerIcons },
{ "nativeSetCustomPointerIcon", "(JLandroid/view/PointerIcon;)V",