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.PointF; | 8 import android.graphics.PointF; |
9 import android.text.InputType; | 9 import android.text.InputType; |
10 import android.view.MotionEvent; | 10 import android.view.MotionEvent; |
11 import android.view.SurfaceView; | 11 import android.view.SurfaceView; |
12 import android.view.inputmethod.EditorInfo; | 12 import android.view.inputmethod.EditorInfo; |
13 import android.view.inputmethod.InputConnection; | 13 import android.view.inputmethod.InputConnection; |
14 import android.view.inputmethod.InputMethodManager; | 14 import android.view.inputmethod.InputMethodManager; |
15 | 15 |
16 import org.chromium.chromoting.jni.Client; | 16 import org.chromium.chromoting.jni.Client; |
17 | 17 |
18 /** | 18 /** |
19 * The abstract class for viewing and interacting with a specific remote host. H andles logic | 19 * The abstract class for viewing and interacting with a specific remote host. H andles logic |
20 * for touch input and render data. | 20 * for touch input and render data. |
21 */ | 21 */ |
22 public abstract class DesktopView extends SurfaceView { | 22 public abstract class DesktopView extends SurfaceView { |
23 /** Used to define the animation feedback shown when a user touches the scre en. */ | 23 /** Used to define the animation feedback shown when a user touches the scre en. */ |
24 public enum InputFeedbackType { NONE, SMALL_ANIMATION, LARGE_ANIMATION } | 24 public enum InputFeedbackType { NONE, SMALL_ANIMATION, LARGE_ANIMATION, TINY _SCALED_ANIMATION } |
joedow
2016/08/24 18:53:28
Now that we've broken the touch and trackpad feedb
Yuwei
2016/08/24 19:06:44
Done.
| |
25 | 25 |
26 protected final RenderData mRenderData; | 26 protected final RenderData mRenderData; |
27 protected final TouchInputHandler mInputHandler; | 27 protected final TouchInputHandler mInputHandler; |
28 | 28 |
29 /** | 29 /** |
30 * Subclass should trigger this event when the client view size is changed. | 30 * Subclass should trigger this event when the client view size is changed. |
31 */ | 31 */ |
32 protected final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChang ed = | 32 protected final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChang ed = |
33 new Event.Raisable<>(); | 33 new Event.Raisable<>(); |
34 | 34 |
35 /** | 35 /** |
36 * Subclass should trigger this event when the host (desktop frame) size is changed. | 36 * Subclass should trigger this event when the host (desktop frame) size is changed. |
37 */ | 37 */ |
38 protected final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged = | 38 protected final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged = |
39 new Event.Raisable<>(); | 39 new Event.Raisable<>(); |
40 | 40 |
41 private final int mTinyFeedbackPixelRadius; | |
41 private final int mSmallFeedbackPixelRadius; | 42 private final int mSmallFeedbackPixelRadius; |
42 private final int mLargeFeedbackPixelRadius; | 43 private final int mLargeFeedbackPixelRadius; |
43 | 44 |
44 /** The parent Desktop activity. */ | 45 /** The parent Desktop activity. */ |
45 private final Desktop mDesktop; | 46 private final Desktop mDesktop; |
46 | 47 |
47 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); | 48 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); |
48 | 49 |
49 public DesktopView(Desktop desktop, Client client) { | 50 public DesktopView(Desktop desktop, Client client) { |
50 super(desktop); | 51 super(desktop); |
51 Preconditions.notNull(desktop); | 52 Preconditions.notNull(desktop); |
52 Preconditions.notNull(client); | 53 Preconditions.notNull(client); |
53 mDesktop = desktop; | 54 mDesktop = desktop; |
54 mRenderData = new RenderData(); | 55 mRenderData = new RenderData(); |
55 mInputHandler = new TouchInputHandler(this, desktop, mRenderData); | 56 mInputHandler = new TouchInputHandler(this, desktop, mRenderData); |
56 mInputHandler.init(desktop, new InputEventSender(client)); | 57 mInputHandler.init(desktop, new InputEventSender(client)); |
57 | 58 |
58 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. | 59 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. |
59 setFocusableInTouchMode(true); | 60 setFocusableInTouchMode(true); |
60 | 61 |
62 mTinyFeedbackPixelRadius = getResources() | |
63 .getDimensionPixelSize(R.dimen.feedback_animation_radius_tiny); | |
64 | |
61 mSmallFeedbackPixelRadius = getResources() | 65 mSmallFeedbackPixelRadius = getResources() |
62 .getDimensionPixelSize(R.dimen.feedback_animation_radius_small); | 66 .getDimensionPixelSize(R.dimen.feedback_animation_radius_small); |
63 | 67 |
64 mLargeFeedbackPixelRadius = getResources() | 68 mLargeFeedbackPixelRadius = getResources() |
65 .getDimensionPixelSize(R.dimen.feedback_animation_radius_large); | 69 .getDimensionPixelSize(R.dimen.feedback_animation_radius_large); |
66 } | 70 } |
67 | 71 |
68 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass. | 72 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass. |
69 /** Shows the action bar. */ | 73 /** Shows the action bar. */ |
70 public final void showActionBar() { | 74 public final void showActionBar() { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 public final boolean onTouchEvent(MotionEvent event) { | 121 public final boolean onTouchEvent(MotionEvent event) { |
118 TouchEventParameter parameter = new TouchEventParameter(event); | 122 TouchEventParameter parameter = new TouchEventParameter(event); |
119 mOnTouch.raise(parameter); | 123 mOnTouch.raise(parameter); |
120 return parameter.handled; | 124 return parameter.handled; |
121 } | 125 } |
122 | 126 |
123 /** | 127 /** |
124 * Returns the radius of the given feedback type. | 128 * Returns the radius of the given feedback type. |
125 * 0.0f will be returned if no feedback should be shown. | 129 * 0.0f will be returned if no feedback should be shown. |
126 */ | 130 */ |
127 protected final float getFeedbackRadius(InputFeedbackType feedbackToShow) { | 131 protected final float getFeedbackRadius(InputFeedbackType feedbackToShow, fl oat scaleFactor) { |
128 switch (feedbackToShow) { | 132 switch (feedbackToShow) { |
129 case NONE: | 133 case NONE: |
130 return 0.0f; | 134 return 0.0f; |
131 case SMALL_ANIMATION: | 135 case SMALL_ANIMATION: |
132 return mSmallFeedbackPixelRadius; | 136 return mSmallFeedbackPixelRadius / scaleFactor; |
133 case LARGE_ANIMATION: | 137 case LARGE_ANIMATION: |
134 return mLargeFeedbackPixelRadius; | 138 return mLargeFeedbackPixelRadius / scaleFactor; |
139 case TINY_SCALED_ANIMATION: | |
140 return mTinyFeedbackPixelRadius; | |
135 default: | 141 default: |
136 // Unreachable, but required by Google Java style and findbugs. | 142 // Unreachable, but required by Google Java style and findbugs. |
137 assert false : "Unreached"; | 143 assert false : "Unreached"; |
138 return 0.0f; | 144 return 0.0f; |
139 } | 145 } |
140 } | 146 } |
141 | 147 |
142 /** Triggers a brief animation to indicate the existence and location of an input event. */ | 148 /** Triggers a brief animation to indicate the existence and location of an input event. */ |
143 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi ntF pos); | 149 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi ntF pos); |
144 | 150 |
(...skipping 14 matching lines...) Expand all Loading... | |
159 * the TouchInputHandler, which requires repainting. | 165 * the TouchInputHandler, which requires repainting. |
160 */ | 166 */ |
161 public abstract void cursorVisibilityChanged(); | 167 public abstract void cursorVisibilityChanged(); |
162 | 168 |
163 /** | 169 /** |
164 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will | 170 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will |
165 * periodically call TouchInputHandler.processAnimation() and repaint itself . | 171 * periodically call TouchInputHandler.processAnimation() and repaint itself . |
166 */ | 172 */ |
167 public abstract void setAnimationEnabled(boolean enabled); | 173 public abstract void setAnimationEnabled(boolean enabled); |
168 } | 174 } |
OLD | NEW |