Chromium Code Reviews| Index: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java |
| diff --git a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java |
| index d6fe710aeb0fa8fa0f8a3b9daf2f8f11886de67b..65b104e50037f7f13dbbe452df7d8ad6178fac66 100644 |
| --- a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java |
| +++ b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java |
| @@ -32,6 +32,7 @@ public class ViewerActivity |
| private native void onSurfaceChanged(long handle, Surface surface); |
| private native void onSurfaceDestroyed(long handle); |
| private native void onKeyPressed(long handle, int keycode); |
| + private native void onTouched(long handle, int owner, int state, float x, float y); |
| @Override |
| public boolean onCreateOptionsMenu(Menu menu) { |
| @@ -96,6 +97,24 @@ public class ViewerActivity |
| @Override |
| public boolean onTouch(View v, MotionEvent event) { |
| - return false; // TODO pass the touch event to native code |
| + int count = event.getPointerCount(); |
| + for (int i = 0; i < count; i++) { |
| + final float x = event.getX(i); |
| + final float y = event.getY(i); |
| + final int owner = event.getPointerId(i); |
| + int action = event.getAction() & MotionEvent.ACTION_MASK; |
| + switch (action) { |
|
djsollen
2016/05/16 18:16:00
why can't you do this in the native code where you
liyuqian
2016/05/16 18:32:37
Done. You're right. I just copied this piece of co
|
| + case MotionEvent.ACTION_POINTER_UP: |
| + action = MotionEvent.ACTION_UP; |
| + break; |
| + case MotionEvent.ACTION_POINTER_DOWN: |
| + action = MotionEvent.ACTION_DOWN; |
| + break; |
| + default: |
| + break; |
| + } |
| + onTouched(mApplication.getNativeHandle(), owner, action, x, y); |
| + } |
| + return true; |
| } |
| } |