| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromoting; | 5 package org.chromium.chromoting; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.Rect; | 8 import android.graphics.Rect; |
| 9 import android.view.GestureDetector; | 9 import android.view.GestureDetector; |
| 10 import android.view.MotionEvent; | 10 import android.view.MotionEvent; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 private final InputState.Settable mInputState; | 52 private final InputState.Settable mInputState; |
| 53 private final int mEdgeSlopInPx; | 53 private final int mEdgeSlopInPx; |
| 54 private final float mSwipeThreshold; | 54 private final float mSwipeThreshold; |
| 55 private final GestureDetector mScroller; | 55 private final GestureDetector mScroller; |
| 56 private final ScaleGestureDetector mZoomer; | 56 private final ScaleGestureDetector mZoomer; |
| 57 private final TapGestureDetector mTapDetector; | 57 private final TapGestureDetector mTapDetector; |
| 58 private final SwipePinchDetector mSwipePinchDetector; | 58 private final SwipePinchDetector mSwipePinchDetector; |
| 59 | 59 |
| 60 private Rect mPanGestureBounds; | 60 private Rect mPanGestureBounds; |
| 61 | 61 |
| 62 InputMonitor(DesktopView view, Context context) { | 62 InputMonitor(DesktopView view, RenderStub renderStub, Context context) { |
| 63 mOnTap = new Event.Raisable<>(); | 63 mOnTap = new Event.Raisable<>(); |
| 64 mOnPressAndHold = new Event.Raisable<>(); | 64 mOnPressAndHold = new Event.Raisable<>(); |
| 65 mOnTouchEvent = new Event.Raisable<>(); | 65 mOnTouchEvent = new Event.Raisable<>(); |
| 66 mOnScroll = new Event.Raisable<>(); | 66 mOnScroll = new Event.Raisable<>(); |
| 67 mOnScrollFling = new Event.Raisable<>(); | 67 mOnScrollFling = new Event.Raisable<>(); |
| 68 mOnFling = new Event.Raisable<>(); | 68 mOnFling = new Event.Raisable<>(); |
| 69 mOnScale = new Event.Raisable<>(); | 69 mOnScale = new Event.Raisable<>(); |
| 70 mOnSwipe = new Event.Raisable<>(); | 70 mOnSwipe = new Event.Raisable<>(); |
| 71 mOnMove = new Event.Raisable<>(); | 71 mOnMove = new Event.Raisable<>(); |
| 72 mInputState = new InputState.Settable(); | 72 mInputState = new InputState.Settable(); |
| 73 mEdgeSlopInPx = ViewConfiguration.get(context).getScaledEdgeSlop(); | 73 mEdgeSlopInPx = ViewConfiguration.get(context).getScaledEdgeSlop(); |
| 74 mSwipeThreshold = 40 * context.getResources().getDisplayMetrics().densit
y; | 74 mSwipeThreshold = 40 * context.getResources().getDisplayMetrics().densit
y; |
| 75 mScroller = new GestureDetector(context, this, null, false); | 75 mScroller = new GestureDetector(context, this, null, false); |
| 76 mScroller.setIsLongpressEnabled(false); | 76 mScroller.setIsLongpressEnabled(false); |
| 77 mZoomer = new ScaleGestureDetector(context, this); | 77 mZoomer = new ScaleGestureDetector(context, this); |
| 78 mTapDetector = new TapGestureDetector(context, this); | 78 mTapDetector = new TapGestureDetector(context, this); |
| 79 mSwipePinchDetector = new SwipePinchDetector(context); | 79 mSwipePinchDetector = new SwipePinchDetector(context); |
| 80 view.onClientSizeChanged().add( | 80 renderStub.onClientSizeChanged().add( |
| 81 new Event.ParameterRunnable<SizeChangedEventParameter>() { | 81 new Event.ParameterRunnable<SizeChangedEventParameter>() { |
| 82 @Override | 82 @Override |
| 83 public void run(SizeChangedEventParameter param) { | 83 public void run(SizeChangedEventParameter param) { |
| 84 handleClientSizeChanged(param); | 84 handleClientSizeChanged(param); |
| 85 } | 85 } |
| 86 }); | 86 }); |
| 87 // Currently we support only touch events. | 87 // Currently we support only touch events. |
| 88 view.onTouch().add( | 88 view.onTouch().add( |
| 89 new Event.ParameterRunnable<TouchEventParameter>() { | 89 new Event.ParameterRunnable<TouchEventParameter>() { |
| 90 @Override | 90 @Override |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 mOnTouchEvent.raise(parameter.event); | 283 mOnTouchEvent.raise(parameter.event); |
| 284 | 284 |
| 285 boolean handled = mScroller.onTouchEvent(parameter.event); | 285 boolean handled = mScroller.onTouchEvent(parameter.event); |
| 286 handled |= mZoomer.onTouchEvent(parameter.event); | 286 handled |= mZoomer.onTouchEvent(parameter.event); |
| 287 handled |= mTapDetector.onTouchEvent(parameter.event); | 287 handled |= mTapDetector.onTouchEvent(parameter.event); |
| 288 mSwipePinchDetector.onTouchEvent(parameter.event); | 288 mSwipePinchDetector.onTouchEvent(parameter.event); |
| 289 | 289 |
| 290 parameter.handled = handled; | 290 parameter.handled = handled; |
| 291 } | 291 } |
| 292 } | 292 } |
| OLD | NEW |