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

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

Issue 2175353003: [Remoting Android] Define feedback animation size in dp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback Created 4 years, 4 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.Point; 8 import android.graphics.Point;
9 import android.text.InputType; 9 import android.text.InputType;
10 import android.view.MotionEvent; 10 import android.view.MotionEvent;
(...skipping 20 matching lines...) Expand all
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 protected final int mSmallFeedbackPixelRadius;
42 protected final int mLargeFeedbackPixelRadius;
43
41 /** The parent Desktop activity. */ 44 /** The parent Desktop activity. */
42 private final Desktop mDesktop; 45 private final Desktop mDesktop;
43 46
44 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>(); 47 private final Event.Raisable<TouchEventParameter> mOnTouch = new Event.Raisa ble<>();
45 48
46 public AbstractDesktopView(Desktop desktop, Client client) { 49 public AbstractDesktopView(Desktop desktop, Client client) {
47 super(desktop); 50 super(desktop);
48 Preconditions.notNull(desktop); 51 Preconditions.notNull(desktop);
49 Preconditions.notNull(client); 52 Preconditions.notNull(client);
50 mDesktop = desktop; 53 mDesktop = desktop;
51 mRenderData = new RenderData(); 54 mRenderData = new RenderData();
52 mInputHandler = new TouchInputHandler(this, desktop, mRenderData); 55 mInputHandler = new TouchInputHandler(this, desktop, mRenderData);
53 mInputHandler.init(desktop, new InputEventSender(client)); 56 mInputHandler.init(desktop, new InputEventSender(client));
54 57
55 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings. 58 // Give this view keyboard focus, allowing us to customize the soft keyb oard's settings.
56 setFocusableInTouchMode(true); 59 setFocusableInTouchMode(true);
60
61 mSmallFeedbackPixelRadius = getResources()
62 .getDimensionPixelSize(R.dimen.feedback_animation_radius_small);
63
64 mLargeFeedbackPixelRadius = getResources()
65 .getDimensionPixelSize(R.dimen.feedback_animation_radius_large);
57 } 66 }
58 67
59 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass. 68 // TODO(yuweih): move showActionBar and showKeyboard out of this abstract cl ass.
60 /** Shows the action bar. */ 69 /** Shows the action bar. */
61 public final void showActionBar() { 70 public final void showActionBar() {
62 mDesktop.showSystemUi(); 71 mDesktop.showSystemUi();
63 } 72 }
64 73
65 /** Shows the software keyboard. */ 74 /** Shows the software keyboard. */
66 public final void showKeyboard() { 75 public final void showKeyboard() {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 113 }
105 114
106 /** Called whenever the user attempts to touch the canvas. */ 115 /** Called whenever the user attempts to touch the canvas. */
107 @Override 116 @Override
108 public final boolean onTouchEvent(MotionEvent event) { 117 public final boolean onTouchEvent(MotionEvent event) {
109 TouchEventParameter parameter = new TouchEventParameter(event); 118 TouchEventParameter parameter = new TouchEventParameter(event);
110 mOnTouch.raise(parameter); 119 mOnTouch.raise(parameter);
111 return parameter.handled; 120 return parameter.handled;
112 } 121 }
113 122
123 /**
124 * Returns the radius of the given feedback type.
125 * 0.0f will be returned if no feedback should be shown.
126 */
127 protected final float getFeedbackRadius(InputFeedbackType feedbackToShow) {
128 switch (feedbackToShow) {
129 case NONE:
130 return 0.0f;
131 case SMALL_ANIMATION:
132 return mSmallFeedbackPixelRadius;
133 case LARGE_ANIMATION:
134 return mLargeFeedbackPixelRadius;
135 default:
136 // Unreachable, but required by Google Java style and findbugs.
137 assert false : "Unreached";
138 return 0.0f;
139 }
140 }
141
114 /** Triggers a brief animation to indicate the existence and location of an input event. */ 142 /** Triggers a brief animation to indicate the existence and location of an input event. */
115 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi nt pos); 143 public abstract void showInputFeedback(InputFeedbackType feedbackToShow, Poi nt pos);
116 144
117 /** 145 /**
118 * Informs the view that its transformation matrix (for rendering the remote desktop bitmap) 146 * Informs the view that its transformation matrix (for rendering the remote desktop bitmap)
119 * has been changed by the TouchInputHandler, which requires repainting. 147 * has been changed by the TouchInputHandler, which requires repainting.
120 */ 148 */
121 public abstract void transformationChanged(); 149 public abstract void transformationChanged();
122 150
123 /** 151 /**
124 * Informs the view that the cursor has been moved by the TouchInputHandler, which requires 152 * Informs the view that the cursor has been moved by the TouchInputHandler, which requires
125 * repainting. 153 * repainting.
126 */ 154 */
127 public abstract void cursorMoved(); 155 public abstract void cursorMoved();
128 156
129 /** 157 /**
130 * Informs the view that the cursor visibility has been changed (for differe nt input mode) by 158 * Informs the view that the cursor visibility has been changed (for differe nt input mode) by
131 * the TouchInputHandler, which requires repainting. 159 * the TouchInputHandler, which requires repainting.
132 */ 160 */
133 public abstract void cursorVisibilityChanged(); 161 public abstract void cursorVisibilityChanged();
134 162
135 /** 163 /**
136 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will 164 * Starts or stops an animation. Whilst the animation is running, the Deskto pView will
137 * periodically call TouchInputHandler.processAnimation() and repaint itself . 165 * periodically call TouchInputHandler.processAnimation() and repaint itself .
138 */ 166 */
139 public abstract void setAnimationEnabled(boolean enabled); 167 public abstract void setAnimationEnabled(boolean enabled);
140 } 168 }
OLDNEW
« no previous file with comments | « remoting/android/java/res/values/dimens.xml ('k') | remoting/android/java/src/org/chromium/chromoting/DesktopView.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698