diff --git a/samples/ApiDemos/res/layout/pointer_shapes.xml b/samples/ApiDemos/res/layout/pointer_types.xml
similarity index 52%
rename from samples/ApiDemos/res/layout/pointer_shapes.xml
rename to samples/ApiDemos/res/layout/pointer_types.xml
index ff12ed0c6..d0533b28d 100644
--- a/samples/ApiDemos/res/layout/pointer_shapes.xml
+++ b/samples/ApiDemos/res/layout/pointer_types.xml
@@ -27,7 +27,7 @@
+ android:text="@string/pointer_type_description" />
+ android:text="@string/pointer_type_arrow"
+ android:pointerIcon="arrow" />
+ android:text="@string/pointer_type_context_menu"
+ android:pointerIcon="context_menu" />
+ android:text="@string/pointer_type_hand"
+ android:pointerIcon="hand" />
+ android:text="@string/pointer_type_help"
+ android:pointerIcon="help" />
+ android:text="@string/pointer_type_wait"
+ android:pointerIcon="wait" />
+ android:text="@string/pointer_type_cell"
+ android:pointerIcon="cell" />
+ android:text="@string/pointer_type_crosshair"
+ android:pointerIcon="crosshair" />
+ android:text="@string/pointer_type_text"
+ android:pointerIcon="text" />
+ android:text="@string/pointer_type_vertical_text"
+ android:pointerIcon="vertical_text" />
+ android:text="@string/pointer_type_alias"
+ android:pointerIcon="alias" />
+ android:text="@string/pointer_type_copy"
+ android:pointerIcon="copy" />
+ android:text="@string/pointer_type_no_drop"
+ android:pointerIcon="no_drop" />
+ android:text="@string/pointer_type_all_scroll"
+ android:pointerIcon="all_scroll" />
+ android:text="@string/pointer_type_horizontal_double_arrow"
+ android:pointerIcon="horizontal_double_arrow" />
+ android:text="@string/pointer_type_vertical_double_arrow"
+ android:pointerIcon="vertical_double_arrow" />
+ android:text="@string/pointer_type_top_right_diagonal_double_arrow"
+ android:pointerIcon="top_right_diagonal_double_arrow" />
+ android:text="@string/pointer_type_top_left_diagonal_double_arrow"
+ android:pointerIcon="top_left_diagonal_double_arrow" />
+ android:text="@string/pointer_type_zoom_in"
+ android:pointerIcon="zoom_in" />
+ android:text="@string/pointer_type_zoom_out"
+ android:pointerIcon="zoom_out" />
+ android:text="@string/pointer_type_grab"
+ android:pointerIcon="grab" />
+ android:text="@string/pointer_type_grabbing"
+ android:pointerIcon="grabbing" />
+ android:text="@string/pointer_type_none"
+ android:pointerIcon="none" />
+ android:text="@string/pointer_type_custom_resource"
+ android:pointerIcon="@drawable/custom_pointer_icon" />
+ android:text="@string/pointer_type_custom_resource_code" />
+ android:text="@string/pointer_type_custom_static" />
+ android:text="@string/pointer_type_custom_system" />
+ android:text="@string/pointer_type_custom_live" />
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 95db667f7..78de99f93 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -1093,34 +1093,34 @@
Try hovering over the button.
Intercepted hover event instead of sending it to the button. Om nom nom!
Hover Here
- The following demo is meaningful only with mouse. This does not have any effects on the touch screens.
- arrow
- context menu
- hand
- help
- wait
- cell
- crosshair
- text (I-beam)
- vertical text
- alias
- copy
- no drop
- all scroll
- horizontal double arrow
- vertical double arrow
- top right diagonal double arrow
- top left diagonal double arrow
- zoom in
- zoom out
- grab
- grabbing
- none (invisible)
- Custom (defined in resource file)
- Custom (resource loaded in code)
- Custom (static bitmap created in code)
- Custom (system icon picked in code)
- Custom (dynamic image created in code)
+ The following demo is meaningful only with mouse. This does not have any effects on the touch screens.
+ arrow
+ context menu
+ hand
+ help
+ wait
+ cell
+ crosshair
+ text (I-beam)
+ vertical text
+ alias
+ copy
+ no drop
+ all scroll
+ horizontal double arrow
+ vertical double arrow
+ top right diagonal double arrow
+ top left diagonal double arrow
+ zoom in
+ zoom out
+ grab
+ grabbing
+ none (invisible)
+ Custom (defined in resource file)
+ Custom (resource loaded in code)
+ Custom (static bitmap created in code)
+ Custom (system icon picked in code)
+ Custom (dynamic image created in code)
diff --git a/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.java b/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.java
index 7bbb4cae8..cea1d662c 100644
--- a/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.java
+++ b/samples/ApiDemos/src/com/example/android/apis/graphics/TouchRotateActivity.java
@@ -115,7 +115,7 @@ class TouchSurfaceView extends GLSurfaceView {
if (hasPointerCapture()) {
releasePointerCapture();
} else {
- setPointerCapture();
+ requestPointerCapture();
}
}
break;
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/LivePointerIconButton.java b/samples/ApiDemos/src/com/example/android/apis/view/LivePointerIconButton.java
index 6edf4de26..694db1be6 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/LivePointerIconButton.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/LivePointerIconButton.java
@@ -45,7 +45,7 @@ public class LivePointerIconButton extends Button {
}
@Override
- public PointerIcon getPointerIcon(MotionEvent event, float x, float y) {
+ public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
int cursorSize = getHeight();
Bitmap bitmap = Bitmap.createBitmap(cursorSize, cursorSize, Bitmap.Config.ARGB_8888);
@@ -65,8 +65,8 @@ public class LivePointerIconButton extends Button {
// Compute relative offset of the mouse pointer from the view center.
// It should be between -0.5 and 0.5.
- final float relativeX = (x / getWidth()) - 0.5f;
- final float relativeY = (y / getHeight()) - 0.5f;
+ final float relativeX = (event.getX(pointerIndex) / getWidth()) - 0.5f;
+ final float relativeY = (event.getY(pointerIndex) / getHeight()) - 0.5f;
// Draw a smaller circle inside the large circle, offset towards the center of the view.
final int innerCenterX = (int) (cursorSize * (1 - relativeX) / 2);
@@ -80,6 +80,6 @@ public class LivePointerIconButton extends Button {
final int hotSpotX = bitmap.getWidth() / 2;
final int hotSpotY = bitmap.getHeight() / 2;
- return PointerIcon.createCustomIcon(bitmap, hotSpotX, hotSpotY);
+ return PointerIcon.create(bitmap, hotSpotX, hotSpotY);
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/PointerShapes.java b/samples/ApiDemos/src/com/example/android/apis/view/PointerShapes.java
index 47e5fe65f..cddcd009c 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/PointerShapes.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/PointerShapes.java
@@ -29,6 +29,6 @@ public class PointerShapes extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.pointer_shapes);
+ setContentView(R.layout.pointer_types);
}
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/ResourcePointerIconButton.java b/samples/ApiDemos/src/com/example/android/apis/view/ResourcePointerIconButton.java
index d6739bcec..1ec4fb2f0 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/ResourcePointerIconButton.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/ResourcePointerIconButton.java
@@ -44,9 +44,9 @@ public class ResourcePointerIconButton extends Button {
}
@Override
- public PointerIcon getPointerIcon(MotionEvent event, float x, float y) {
+ public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
if (mCustomIcon == null) {
- mCustomIcon = PointerIcon.loadCustomIcon(getResources(), R.drawable.custom_pointer_icon);
+ mCustomIcon = PointerIcon.load(getResources(), R.drawable.custom_pointer_icon);
}
return mCustomIcon;
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/StaticPointerIconButton.java b/samples/ApiDemos/src/com/example/android/apis/view/StaticPointerIconButton.java
index 511dbb929..e246dfc7b 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/StaticPointerIconButton.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/StaticPointerIconButton.java
@@ -46,14 +46,13 @@ public class StaticPointerIconButton extends Button {
}
@Override
- public PointerIcon getPointerIcon(MotionEvent event, float x, float y) {
+ public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
if (mCustomIcon == null) {
Drawable d = getContext().getDrawable(R.drawable.smile);
final BitmapDrawable bitmapDrawable = (BitmapDrawable) d;
final int hotSpotX = d.getIntrinsicWidth() / 2;
final int hotSpotY = d.getIntrinsicHeight() / 2;
- mCustomIcon = PointerIcon.createCustomIcon(
- bitmapDrawable.getBitmap(), hotSpotX, hotSpotY);
+ mCustomIcon = PointerIcon.create(bitmapDrawable.getBitmap(), hotSpotX, hotSpotY);
}
return mCustomIcon;
}
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/SystemPointerIconButton.java b/samples/ApiDemos/src/com/example/android/apis/view/SystemPointerIconButton.java
index 53c859ef6..2ab037b85 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/SystemPointerIconButton.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/SystemPointerIconButton.java
@@ -42,28 +42,30 @@ public class SystemPointerIconButton extends Button {
}
@Override
- public PointerIcon getPointerIcon(MotionEvent event, float x, float y) {
+ public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
final int minX = getWidth() / 4;
final int maxX = getWidth() - minX;
final int minY = getHeight() / 4;
final int maxY = getHeight() - minY;
- int style;
+ final float x = event.getX(pointerIndex);
+ final float y = event.getY(pointerIndex);
+ int type;
if ((x < minX && y < minY) || (x > maxX && y > maxY)) {
// Top/left or bottom/right corner.
- style = PointerIcon.STYLE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
+ type = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
} else if ((x < minX && y > maxY) || (x > maxX && y < minY)) {
// Top/rightor bottom/left corner.
- style = PointerIcon.STYLE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
+ type = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
} else if (x < minX || x > maxX) {
// Left or right edge.
- style = PointerIcon.STYLE_HORIZONTAL_DOUBLE_ARROW;
+ type = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW;
} else if (y < minY || y > maxY) {
// Top or bottom edge edge.
- style = PointerIcon.STYLE_VERTICAL_DOUBLE_ARROW;
+ type = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
} else {
// Everything else (the middle).
- style = PointerIcon.STYLE_ALL_SCROLL;
+ type = PointerIcon.TYPE_ALL_SCROLL;
}
- return PointerIcon.getSystemIcon(getContext(), style);
+ return PointerIcon.getSystemIcon(getContext(), type);
}
}