OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.Matrix; | 8 import android.graphics.Matrix; |
9 import android.graphics.Point; | 9 import android.graphics.Point; |
10 import android.graphics.PointF; | 10 import android.graphics.PointF; |
11 import android.graphics.Rect; | 11 import android.graphics.Rect; |
12 import android.view.GestureDetector; | 12 import android.view.GestureDetector; |
13 import android.view.MotionEvent; | 13 import android.view.MotionEvent; |
14 import android.view.ScaleGestureDetector; | 14 import android.view.ScaleGestureDetector; |
15 import android.view.ViewConfiguration; | 15 import android.view.ViewConfiguration; |
16 | 16 |
17 /** | 17 /** |
18 * This class is responsible for handling Touch input from the user. Touch even
ts which manipulate | 18 * This class is responsible for handling Touch input from the user. Touch even
ts which manipulate |
19 * the local canvas are handled in this class and any input which should be sent
to the remote host | 19 * the local canvas are handled in this class and any input which should be sent
to the remote host |
20 * are passed to the InputStrategyInterface implementation set by the DesktopVie
w. | 20 * are passed to the InputStrategyInterface implementation set by the DesktopVie
w. |
21 */ | 21 */ |
22 public class TouchInputHandler { | 22 public class TouchInputHandler { |
23 private final DesktopViewInterface mViewer; | 23 private final AbstractDesktopView mViewer; |
24 private final Context mContext; | 24 private final Context mContext; |
25 private final RenderData mRenderData; | 25 private final RenderData mRenderData; |
26 private final DesktopCanvas mDesktopCanvas; | 26 private final DesktopCanvas mDesktopCanvas; |
27 private InputStrategyInterface mInputStrategy; | 27 private InputStrategyInterface mInputStrategy; |
28 | 28 |
29 private GestureDetector mScroller; | 29 private GestureDetector mScroller; |
30 private ScaleGestureDetector mZoomer; | 30 private ScaleGestureDetector mZoomer; |
31 private TapGestureDetector mTapDetector; | 31 private TapGestureDetector mTapDetector; |
32 | 32 |
33 /** Used to disambiguate a 2-finger gesture as a swipe or a pinch. */ | 33 /** Used to disambiguate a 2-finger gesture as a swipe or a pinch. */ |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 public DesktopView.InputFeedbackType getLongPressFeedbackType() { | 172 public DesktopView.InputFeedbackType getLongPressFeedbackType() { |
173 return DesktopView.InputFeedbackType.NONE; | 173 return DesktopView.InputFeedbackType.NONE; |
174 } | 174 } |
175 | 175 |
176 @Override | 176 @Override |
177 public boolean isIndirectInputMode() { | 177 public boolean isIndirectInputMode() { |
178 return false; | 178 return false; |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 public TouchInputHandler(DesktopViewInterface viewer, Context context, Rende
rData renderData) { | 182 public TouchInputHandler(AbstractDesktopView viewer, Context context, Render
Data renderData) { |
183 mViewer = viewer; | 183 mViewer = viewer; |
184 mContext = context; | 184 mContext = context; |
185 mRenderData = renderData; | 185 mRenderData = renderData; |
186 mDesktopCanvas = new DesktopCanvas(mViewer, mRenderData); | 186 mDesktopCanvas = new DesktopCanvas(mViewer, mRenderData); |
187 | 187 |
188 GestureListener listener = new GestureListener(); | 188 GestureListener listener = new GestureListener(); |
189 mScroller = new GestureDetector(context, listener, null, false); | 189 mScroller = new GestureDetector(context, listener, null, false); |
190 | 190 |
191 // If long-press is enabled, the gesture-detector will not emit any furt
her onScroll | 191 // If long-press is enabled, the gesture-detector will not emit any furt
her onScroll |
192 // notifications after the onLongPress notification. Since onScroll is b
eing used for | 192 // notifications after the onLongPress notification. Since onScroll is b
eing used for |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 235 |
236 desktop.onSystemUiVisibilityChanged().add( | 236 desktop.onSystemUiVisibilityChanged().add( |
237 new Event.ParameterRunnable<SystemUiVisibilityChangedEventParame
ter>() { | 237 new Event.ParameterRunnable<SystemUiVisibilityChangedEventParame
ter>() { |
238 @Override | 238 @Override |
239 public void run(SystemUiVisibilityChangedEventParameter para
meter) { | 239 public void run(SystemUiVisibilityChangedEventParameter para
meter) { |
240 handleSystemUiVisibilityChanged(parameter); | 240 handleSystemUiVisibilityChanged(parameter); |
241 } | 241 } |
242 }); | 242 }); |
243 } | 243 } |
244 | 244 |
245 private void attachViewEvents(DesktopViewInterface viewer) { | 245 private void attachViewEvents(AbstractDesktopView viewer) { |
246 viewer.onTouch().add(new Event.ParameterRunnable<TouchEventParameter>()
{ | 246 viewer.onTouch().add(new Event.ParameterRunnable<TouchEventParameter>()
{ |
247 @Override | 247 @Override |
248 public void run(TouchEventParameter parameter) { | 248 public void run(TouchEventParameter parameter) { |
249 parameter.handled = handleTouchEvent(parameter.event); | 249 parameter.handled = handleTouchEvent(parameter.event); |
250 } | 250 } |
251 }); | 251 }); |
252 viewer.onClientSizeChanged().add(new Event.ParameterRunnable<SizeChanged
EventParameter>() { | 252 viewer.onClientSizeChanged().add(new Event.ParameterRunnable<SizeChanged
EventParameter>() { |
253 @Override | 253 @Override |
254 public void run(SizeChangedEventParameter parameter) { | 254 public void run(SizeChangedEventParameter parameter) { |
255 handleClientSizeChanged(parameter.width, parameter.height); | 255 handleClientSizeChanged(parameter.width, parameter.height); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 case 2: | 614 case 2: |
615 return InputStub.BUTTON_RIGHT; | 615 return InputStub.BUTTON_RIGHT; |
616 case 3: | 616 case 3: |
617 return InputStub.BUTTON_MIDDLE; | 617 return InputStub.BUTTON_MIDDLE; |
618 default: | 618 default: |
619 return InputStub.BUTTON_UNDEFINED; | 619 return InputStub.BUTTON_UNDEFINED; |
620 } | 620 } |
621 } | 621 } |
622 } | 622 } |
623 } | 623 } |
OLD | NEW |