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

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

Issue 2272793003: [Remoting Android] New touch feedback texture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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.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 {
25 NONE,
26 SHORT_TOUCH_ANIMATION,
27 LONG_TOUCH_ANIMATION,
28 LONG_TRACKPAD_ANIMATION
29 }
25 30
26 protected final RenderData mRenderData; 31 protected final RenderData mRenderData;
27 protected final TouchInputHandler mInputHandler; 32 protected final TouchInputHandler mInputHandler;
28 33
29 /** 34 /**
30 * Subclass should trigger this event when the client view size is changed. 35 * Subclass should trigger this event when the client view size is changed.
31 */ 36 */
32 protected final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChang ed = 37 protected final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChang ed =
33 new Event.Raisable<>(); 38 new Event.Raisable<>();
34 39
35 /** 40 /**
36 * 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.
37 */ 42 */
38 protected final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged = 43 protected final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged =
39 new Event.Raisable<>(); 44 new Event.Raisable<>();
40 45
41 private final int mSmallFeedbackPixelRadius; 46 private final int mLongTrackpadAnimationRadius;
42 private final int mLargeFeedbackPixelRadius; 47 private final int mShortTouchAnimationRadius;
48 private final int mLongTouchAnimationRadius;
43 49
44 /** The parent Desktop activity. */ 50 /** The parent Desktop activity. */
45 private final Desktop mDesktop; 51 private final Desktop mDesktop;
46 52
47 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); 53 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>();
48 54
49 public DesktopView(Desktop desktop, Client client) { 55 public DesktopView(Desktop desktop, Client client) {
50 super(desktop); 56 super(desktop);
51 Preconditions.notNull(desktop); 57 Preconditions.notNull(desktop);
52 Preconditions.notNull(client); 58 Preconditions.notNull(client);
53 mDesktop = desktop; 59 mDesktop = desktop;
54 mRenderData = new RenderData(); 60 mRenderData = new RenderData();
55 mInputHandler = new TouchInputHandler(this, desktop, mRenderData); 61 mInputHandler = new TouchInputHandler(this, desktop, mRenderData);
56 mInputHandler.init(desktop, new InputEventSender(client)); 62 mInputHandler.init(desktop, new InputEventSender(client));
57 63
58 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. 64 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings.
59 setFocusableInTouchMode(true); 65 setFocusableInTouchMode(true);
60 66
61 mSmallFeedbackPixelRadius = getResources() 67 mLongTrackpadAnimationRadius =
62 .getDimensionPixelSize(R.dimen.feedback_animation_radius_small); 68 getResources().getDimensionPixelSize(R.dimen.long_trackpad_anima tion_radius);
63 69
64 mLargeFeedbackPixelRadius = getResources() 70 mShortTouchAnimationRadius =
65 .getDimensionPixelSize(R.dimen.feedback_animation_radius_large); 71 getResources().getDimensionPixelSize(R.dimen.short_touch_animati on_radius);
72
73 mLongTouchAnimationRadius =
74 getResources().getDimensionPixelSize(R.dimen.long_touch_animatio n_radius);
66 } 75 }
67 76
68 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass. 77 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass.
69 /** Shows the action bar. */ 78 /** Shows the action bar. */
70 public final void showActionBar() { 79 public final void showActionBar() {
71 mDesktop.showSystemUi(); 80 mDesktop.showSystemUi();
72 } 81 }
73 82
74 /** Shows the software keyboard. */ 83 /** Shows the software keyboard. */
75 public final void showKeyboard() { 84 public final void showKeyboard() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 public final boolean onTouchEvent(MotionEvent event) { 126 public final boolean onTouchEvent(MotionEvent event) {
118 TouchEventParameter parameter = new TouchEventParameter(event); 127 TouchEventParameter parameter = new TouchEventParameter(event);
119 mOnTouch.raise(parameter); 128 mOnTouch.raise(parameter);
120 return parameter.handled; 129 return parameter.handled;
121 } 130 }
122 131
123 /** 132 /**
124 * Returns the radius of the given feedback type. 133 * Returns the radius of the given feedback type.
125 * 0.0f will be returned if no feedback should be shown. 134 * 0.0f will be returned if no feedback should be shown.
126 */ 135 */
127 protected final float getFeedbackRadius(InputFeedbackType feedbackToShow) { 136 protected final float getFeedbackRadius(InputFeedbackType feedbackToShow, fl oat scaleFactor) {
128 switch (feedbackToShow) { 137 switch (feedbackToShow) {
129 case NONE: 138 case NONE:
130 return 0.0f; 139 return 0.0f;
131 case SMALL_ANIMATION: 140 case SHORT_TOUCH_ANIMATION:
132 return mSmallFeedbackPixelRadius; 141 return mShortTouchAnimationRadius / scaleFactor;
133 case LARGE_ANIMATION: 142 case LONG_TOUCH_ANIMATION:
134 return mLargeFeedbackPixelRadius; 143 return mLongTouchAnimationRadius / scaleFactor;
144 case LONG_TRACKPAD_ANIMATION:
145 return mLongTrackpadAnimationRadius;
joedow 2016/08/24 19:11:06 A comment here on why this value isn't being norma
Yuwei 2016/08/24 20:05:43 Done.
135 default: 146 default:
136 // Unreachable, but required by Google Java style and findbugs. 147 // Unreachable, but required by Google Java style and findbugs.
137 assert false : "Unreached"; 148 assert false : "Unreached";
138 return 0.0f; 149 return 0.0f;
139 } 150 }
140 } 151 }
141 152
142 /** Triggers a brief animation to indicate the existence and location of an input event. */ 153 /** Triggers a brief animation to indicate the existence and location of an input event. */
143 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi ntF pos); 154 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi ntF pos);
144 155
(...skipping 14 matching lines...) Expand all
159 * the TouchInputHandler, which requires repainting. 170 * the TouchInputHandler, which requires repainting.
160 */ 171 */
161 public abstract void cursorVisibilityChanged(); 172 public abstract void cursorVisibilityChanged();
162 173
163 /** 174 /**
164 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will 175 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will
165 * periodically call TouchInputHandler.processAnimation() and repaint itself . 176 * periodically call TouchInputHandler.processAnimation() and repaint itself .
166 */ 177 */
167 public abstract void setAnimationEnabled(boolean enabled); 178 public abstract void setAnimationEnabled(boolean enabled);
168 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698