Merge "DO NOT MERGE Rename PointerIcon and Pointer Capture APIs" into nyc-dev

This commit is contained in:
TreeHugger Robot
2016-05-19 15:03:33 +00:00
committed by Android (Google) Code Review
8 changed files with 122 additions and 121 deletions

View File

@@ -27,7 +27,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_description" />
android:text="@string/pointer_type_description" />
<GridLayout
android:columnCount="2"
@@ -36,185 +36,185 @@
android:orientation="horizontal">
<Button
android:id="@+id/pointer_shape_view_arrow"
android:id="@+id/pointer_type_view_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_arrow"
android:pointerShape="arrow" />
android:text="@string/pointer_type_arrow"
android:pointerIcon="arrow" />
<Button
android:id="@+id/pointer_shape_view_context_menu"
android:id="@+id/pointer_type_view_context_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_context_menu"
android:pointerShape="context_menu" />
android:text="@string/pointer_type_context_menu"
android:pointerIcon="context_menu" />
<Button
android:id="@+id/pointer_shape_view_hand"
android:id="@+id/pointer_type_view_hand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_hand"
android:pointerShape="hand" />
android:text="@string/pointer_type_hand"
android:pointerIcon="hand" />
<Button
android:id="@+id/pointer_shape_view_help"
android:id="@+id/pointer_type_view_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_help"
android:pointerShape="help" />
android:text="@string/pointer_type_help"
android:pointerIcon="help" />
<Button
android:id="@+id/pointer_shape_view_wait"
android:id="@+id/pointer_type_view_wait"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_wait"
android:pointerShape="wait" />
android:text="@string/pointer_type_wait"
android:pointerIcon="wait" />
<Button
android:id="@+id/pointer_shape_view_cell"
android:id="@+id/pointer_type_view_cell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_cell"
android:pointerShape="cell" />
android:text="@string/pointer_type_cell"
android:pointerIcon="cell" />
<Button
android:id="@+id/pointer_shape_view_crosshair"
android:id="@+id/pointer_type_view_crosshair"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_crosshair"
android:pointerShape="crosshair" />
android:text="@string/pointer_type_crosshair"
android:pointerIcon="crosshair" />
<Button
android:id="@+id/pointer_shape_view_text"
android:id="@+id/pointer_type_view_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_text"
android:pointerShape="text" />
android:text="@string/pointer_type_text"
android:pointerIcon="text" />
<Button
android:id="@+id/pointer_shape_view_vertical_text"
android:id="@+id/pointer_type_view_vertical_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_vertical_text"
android:pointerShape="vertical_text" />
android:text="@string/pointer_type_vertical_text"
android:pointerIcon="vertical_text" />
<Button
android:id="@+id/pointer_shape_view_alias"
android:id="@+id/pointer_type_view_alias"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_alias"
android:pointerShape="alias" />
android:text="@string/pointer_type_alias"
android:pointerIcon="alias" />
<Button
android:id="@+id/pointer_shape_view_copy"
android:id="@+id/pointer_type_view_copy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_copy"
android:pointerShape="copy" />
android:text="@string/pointer_type_copy"
android:pointerIcon="copy" />
<Button
android:id="@+id/pointer_shape_view_no_drop"
android:id="@+id/pointer_type_view_no_drop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_no_drop"
android:pointerShape="no_drop" />
android:text="@string/pointer_type_no_drop"
android:pointerIcon="no_drop" />
<Button
android:id="@+id/pointer_shape_view_all_scroll"
android:id="@+id/pointer_type_view_all_scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_all_scroll"
android:pointerShape="all_scroll" />
android:text="@string/pointer_type_all_scroll"
android:pointerIcon="all_scroll" />
<Button
android:id="@+id/pointer_shape_view_horizontal_double_arrow"
android:id="@+id/pointer_type_view_horizontal_double_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_horizontal_double_arrow"
android:pointerShape="horizontal_double_arrow" />
android:text="@string/pointer_type_horizontal_double_arrow"
android:pointerIcon="horizontal_double_arrow" />
<Button
android:id="@+id/pointer_shape_view_vertical_double_arrow"
android:id="@+id/pointer_type_view_vertical_double_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_vertical_double_arrow"
android:pointerShape="vertical_double_arrow" />
android:text="@string/pointer_type_vertical_double_arrow"
android:pointerIcon="vertical_double_arrow" />
<Button
android:id="@+id/pointer_shape_view_top_right_diagonal_double_arrow"
android:id="@+id/pointer_type_view_top_right_diagonal_double_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_top_right_diagonal_double_arrow"
android:pointerShape="top_right_diagonal_double_arrow" />
android:text="@string/pointer_type_top_right_diagonal_double_arrow"
android:pointerIcon="top_right_diagonal_double_arrow" />
<Button
android:id="@+id/pointer_shape_view_top_left_diagonal_double_arrow"
android:id="@+id/pointer_type_view_top_left_diagonal_double_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_top_left_diagonal_double_arrow"
android:pointerShape="top_left_diagonal_double_arrow" />
android:text="@string/pointer_type_top_left_diagonal_double_arrow"
android:pointerIcon="top_left_diagonal_double_arrow" />
<Button
android:id="@+id/pointer_shape_view_zoom_in"
android:id="@+id/pointer_type_view_zoom_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_zoom_in"
android:pointerShape="zoom_in" />
android:text="@string/pointer_type_zoom_in"
android:pointerIcon="zoom_in" />
<Button
android:id="@+id/pointer_shape_view_zoom_out"
android:id="@+id/pointer_type_view_zoom_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_zoom_out"
android:pointerShape="zoom_out" />
android:text="@string/pointer_type_zoom_out"
android:pointerIcon="zoom_out" />
<Button
android:id="@+id/pointer_shape_view_grab"
android:id="@+id/pointer_type_view_grab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_grab"
android:pointerShape="grab" />
android:text="@string/pointer_type_grab"
android:pointerIcon="grab" />
<Button
android:id="@+id/pointer_shape_view_grabbing"
android:id="@+id/pointer_type_view_grabbing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_grabbing"
android:pointerShape="grabbing" />
android:text="@string/pointer_type_grabbing"
android:pointerIcon="grabbing" />
<Button
android:id="@+id/pointer_shape_view_none"
android:id="@+id/pointer_type_view_none"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_none"
android:pointerShape="none" />
android:text="@string/pointer_type_none"
android:pointerIcon="none" />
<Button
android:id="@+id/pointer_shape_view_custom"
android:id="@+id/pointer_type_view_custom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_custom_resource"
android:pointerShape="@drawable/custom_pointer_icon" />
android:text="@string/pointer_type_custom_resource"
android:pointerIcon="@drawable/custom_pointer_icon" />
<com.example.android.apis.view.ResourcePointerIconButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_custom_resource_code" />
android:text="@string/pointer_type_custom_resource_code" />
<com.example.android.apis.view.StaticPointerIconButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_custom_static" />
android:text="@string/pointer_type_custom_static" />
<com.example.android.apis.view.SystemPointerIconButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_custom_system" />
android:text="@string/pointer_type_custom_system" />
<com.example.android.apis.view.LivePointerIconButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pointer_shape_custom_live" />
android:text="@string/pointer_type_custom_live" />
</GridLayout>

View File

@@ -1093,34 +1093,34 @@
<string name="hover_intercept_message_initial">Try hovering over the button.</string>
<string name="hover_intercept_message_intercepted">Intercepted hover event instead of sending it to the button. Om nom nom!</string>
<string name="hover_button">Hover Here</string>
<string name="pointer_shape_description">The following demo is meaningful only with mouse. This does not have any effects on the touch screens.</string>
<string name="pointer_shape_arrow">arrow</string>
<string name="pointer_shape_context_menu">context menu</string>
<string name="pointer_shape_hand">hand</string>
<string name="pointer_shape_help">help</string>
<string name="pointer_shape_wait">wait</string>
<string name="pointer_shape_cell">cell</string>
<string name="pointer_shape_crosshair">crosshair</string>
<string name="pointer_shape_text">text (I-beam)</string>
<string name="pointer_shape_vertical_text">vertical text</string>
<string name="pointer_shape_alias">alias</string>
<string name="pointer_shape_copy">copy</string>
<string name="pointer_shape_no_drop">no drop</string>
<string name="pointer_shape_all_scroll">all scroll</string>
<string name="pointer_shape_horizontal_double_arrow">horizontal double arrow</string>
<string name="pointer_shape_vertical_double_arrow">vertical double arrow</string>
<string name="pointer_shape_top_right_diagonal_double_arrow">top right diagonal double arrow</string>
<string name="pointer_shape_top_left_diagonal_double_arrow">top left diagonal double arrow</string>
<string name="pointer_shape_zoom_in">zoom in</string>
<string name="pointer_shape_zoom_out">zoom out</string>
<string name="pointer_shape_grab">grab</string>
<string name="pointer_shape_grabbing">grabbing</string>
<string name="pointer_shape_none">none (invisible)</string>
<string name="pointer_shape_custom_resource">Custom (defined in resource file)</string>
<string name="pointer_shape_custom_resource_code">Custom (resource loaded in code)</string>
<string name="pointer_shape_custom_static">Custom (static bitmap created in code)</string>
<string name="pointer_shape_custom_system">Custom (system icon picked in code)</string>
<string name="pointer_shape_custom_live">Custom (dynamic image created in code)</string>
<string name="pointer_type_description">The following demo is meaningful only with mouse. This does not have any effects on the touch screens.</string>
<string name="pointer_type_arrow">arrow</string>
<string name="pointer_type_context_menu">context menu</string>
<string name="pointer_type_hand">hand</string>
<string name="pointer_type_help">help</string>
<string name="pointer_type_wait">wait</string>
<string name="pointer_type_cell">cell</string>
<string name="pointer_type_crosshair">crosshair</string>
<string name="pointer_type_text">text (I-beam)</string>
<string name="pointer_type_vertical_text">vertical text</string>
<string name="pointer_type_alias">alias</string>
<string name="pointer_type_copy">copy</string>
<string name="pointer_type_no_drop">no drop</string>
<string name="pointer_type_all_scroll">all scroll</string>
<string name="pointer_type_horizontal_double_arrow">horizontal double arrow</string>
<string name="pointer_type_vertical_double_arrow">vertical double arrow</string>
<string name="pointer_type_top_right_diagonal_double_arrow">top right diagonal double arrow</string>
<string name="pointer_type_top_left_diagonal_double_arrow">top left diagonal double arrow</string>
<string name="pointer_type_zoom_in">zoom in</string>
<string name="pointer_type_zoom_out">zoom out</string>
<string name="pointer_type_grab">grab</string>
<string name="pointer_type_grabbing">grabbing</string>
<string name="pointer_type_none">none (invisible)</string>
<string name="pointer_type_custom_resource">Custom (defined in resource file)</string>
<string name="pointer_type_custom_resource_code">Custom (resource loaded in code)</string>
<string name="pointer_type_custom_static">Custom (static bitmap created in code)</string>
<string name="pointer_type_custom_system">Custom (system icon picked in code)</string>
<string name="pointer_type_custom_live">Custom (dynamic image created in code)</string>
<!-- ============================== -->
<!-- GoogleLogin examples strings -->

View File

@@ -115,7 +115,7 @@ class TouchSurfaceView extends GLSurfaceView {
if (hasPointerCapture()) {
releasePointerCapture();
} else {
setPointerCapture();
requestPointerCapture();
}
}
break;

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}
}