Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/DesktopView.java

Issue 2297073002: [Remoting Android] Move feedback type to radius logic out of DesktopView (Closed)
Patch Set: Reviewer's Feedback Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.PointF; 9 import android.graphics.PointF;
10 import android.text.InputType; 10 import android.text.InputType;
(...skipping 25 matching lines...) Expand all
36 */ 36 */
37 protected final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChang ed = 37 protected final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChang ed =
38 new Event.Raisable<>(); 38 new Event.Raisable<>();
39 39
40 /** 40 /**
41 * Subclass should trigger this event when the host (desktop frame) size is changed. 41 * Subclass should trigger this event when the host (desktop frame) size is changed.
42 */ 42 */
43 protected final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged = 43 protected final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged =
44 new Event.Raisable<>(); 44 new Event.Raisable<>();
45 45
46 private final int mTinyFeedbackPixelRadius;
47 private final int mSmallFeedbackPixelRadius;
48 private final int mLargeFeedbackPixelRadius;
49
50 /** The parent Desktop activity. */ 46 /** The parent Desktop activity. */
51 private final Desktop mDesktop; 47 private final Desktop mDesktop;
52 48
53 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); 49 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>();
54 50
55 public DesktopView(Desktop desktop, Client client) { 51 public DesktopView(Desktop desktop, Client client) {
56 super(desktop); 52 super(desktop);
57 Preconditions.notNull(desktop); 53 Preconditions.notNull(desktop);
58 Preconditions.notNull(client); 54 Preconditions.notNull(client);
59 mDesktop = desktop; 55 mDesktop = desktop;
60 mInputHandler = new TouchInputHandler(this, desktop); 56 mInputHandler = new TouchInputHandler(this, desktop);
61 mInputHandler.init(desktop, new InputEventSender(client)); 57 mInputHandler.init(desktop, new InputEventSender(client));
62
63 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings.
64 setFocusableInTouchMode(true);
65
66 mTinyFeedbackPixelRadius =
67 getResources().getDimensionPixelSize(R.dimen.feedback_animation_ radius_tiny);
68
69 mSmallFeedbackPixelRadius =
70 getResources().getDimensionPixelSize(R.dimen.feedback_animation_ radius_small);
71
72 mLargeFeedbackPixelRadius =
73 getResources().getDimensionPixelSize(R.dimen.feedback_animation_ radius_large);
74 } 58 }
75 59
76 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass. 60 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass.
77 /** Shows the action bar. */ 61 /** Shows the action bar. */
78 public final void showActionBar() { 62 public final void showActionBar() {
79 mDesktop.showSystemUi(); 63 mDesktop.showSystemUi();
80 } 64 }
81 65
82 /** Shows the software keyboard. */ 66 /** Shows the software keyboard. */
83 public final void showKeyboard() { 67 public final void showKeyboard() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 105 }
122 106
123 /** Called whenever the user attempts to touch the canvas. */ 107 /** Called whenever the user attempts to touch the canvas. */
124 @Override 108 @Override
125 public final boolean onTouchEvent(MotionEvent event) { 109 public final boolean onTouchEvent(MotionEvent event) {
126 TouchEventParameter parameter = new TouchEventParameter(event); 110 TouchEventParameter parameter = new TouchEventParameter(event);
127 mOnTouch.raise(parameter); 111 mOnTouch.raise(parameter);
128 return parameter.handled; 112 return parameter.handled;
129 } 113 }
130 114
131 /**
132 * Returns the radius of the given feedback type.
133 * 0.0f will be returned if no feedback should be shown.
134 */
135 protected final float getFeedbackRadius(InputFeedbackType feedbackToShow, fl oat scaleFactor) {
136 switch (feedbackToShow) {
137 case NONE:
138 return 0.0f;
139 case SHORT_TOUCH_ANIMATION:
140 return mSmallFeedbackPixelRadius / scaleFactor;
141 case LONG_TOUCH_ANIMATION:
142 return mLargeFeedbackPixelRadius / scaleFactor;
143 case LONG_TRACKPAD_ANIMATION:
144 // The size of the longpress trackpad animation is supposed to b e close to the size
145 // of the cursor so it doesn't need to be normalized and should be scaled with the
146 // canvas.
147 return mTinyFeedbackPixelRadius;
148 default:
149 // Unreachable, but required by Google Java style and findbugs.
150 assert false : "Unreached";
151 return 0.0f;
152 }
153 }
154
155 /** Triggers a brief animation to indicate the existence and location of an input event. */ 115 /** Triggers a brief animation to indicate the existence and location of an input event. */
156 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi ntF pos); 116 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi ntF pos);
157 117
158 /** 118 /**
159 * Informs the view that its transformation matrix (for rendering the remote desktop bitmap) 119 * Informs the view that its transformation matrix (for rendering the remote desktop bitmap)
160 * has been changed by the TouchInputHandler, which requires repainting. 120 * has been changed by the TouchInputHandler, which requires repainting.
161 */ 121 */
162 public abstract void transformationChanged(Matrix matrix); 122 public abstract void transformationChanged(Matrix matrix);
163 123
164 /** 124 /**
165 * Informs the view that the cursor has been moved by the TouchInputHandler, which requires 125 * Informs the view that the cursor has been moved by the TouchInputHandler, which requires
166 * repainting. 126 * repainting.
167 */ 127 */
168 public abstract void cursorMoved(PointF position); 128 public abstract void cursorMoved(PointF position);
169 129
170 /** 130 /**
171 * Informs the view that the cursor visibility has been changed (for differe nt input mode) by 131 * Informs the view that the cursor visibility has been changed (for differe nt input mode) by
172 * the TouchInputHandler, which requires repainting. 132 * the TouchInputHandler, which requires repainting.
173 */ 133 */
174 public abstract void cursorVisibilityChanged(boolean visible); 134 public abstract void cursorVisibilityChanged(boolean visible);
175 135
176 /** 136 /**
177 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will 137 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will
178 * periodically call TouchInputHandler.processAnimation() and repaint itself . 138 * periodically call TouchInputHandler.processAnimation() and repaint itself .
179 */ 139 */
180 public abstract void setAnimationEnabled(boolean enabled); 140 public abstract void setAnimationEnabled(boolean enabled);
181 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698