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

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

Issue 2297073002: [Remoting Android] Move feedback type to radius logic out of DesktopView (Closed)
Patch Set: Merge ToT 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
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/GlDesktopView.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chromoting;
6
7 import android.view.View;
8
9 /**
10 * Helper class for mapping a feedback type to the max radius of the feedback an imation circle.
11 */
12 public final class InputFeedbackRadiusMapper {
13 private final int mTinyFeedbackPixelRadius;
14 private final int mSmallFeedbackPixelRadius;
15 private final int mLargeFeedbackPixelRadius;
16
17 public InputFeedbackRadiusMapper(View view) {
18 mTinyFeedbackPixelRadius = view.getResources()
19 .getDimensionPixelSize(R.dimen.feedback_animation_radius_tiny);
20
21 mSmallFeedbackPixelRadius = view.getResources()
22 .getDimensionPixelSize(R.dimen.feedback_animation_radius_small);
23
24 mLargeFeedbackPixelRadius = view.getResources()
25 .getDimensionPixelSize(R.dimen.feedback_animation_radius_large);
26 }
27
28 /**
29 * @param feedbackToShow the feedback type to be mapped to the radius of the feedback circle.
30 * @param scaleFactor Current scale factor of the desktop canvas.
31 * @return the radius of the given feedback type. It may be 0, in which case nothing needs to
32 * be shown.
33 */
34 public float getFeedbackRadius(DesktopView.InputFeedbackType feedbackToShow,
35 float scaleFactor) {
36 switch (feedbackToShow) {
37 case NONE:
38 return 0.0f;
39 case SHORT_TOUCH_ANIMATION:
40 return mSmallFeedbackPixelRadius / scaleFactor;
41 case LONG_TOUCH_ANIMATION:
42 return mLargeFeedbackPixelRadius / scaleFactor;
43 case LONG_TRACKPAD_ANIMATION:
44 // The size of the longpress trackpad animation is supposed to b e close to the
45 // size of the cursor so it doesn't need to be normalized and sh ould be scaled
46 // with the canvas.
47 return mTinyFeedbackPixelRadius;
48 default:
49 // Unreachable, but required by Google Java style and findbugs.
50 assert false : "Unreached";
51 return 0.0f;
52 }
53 }
54 }
OLDNEW
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/GlDesktopView.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698