Chromium Code Reviews| OLD | NEW |
|---|---|
| (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. | |
| 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 * Returns the radius of the given feedback type. | |
| 30 * 0.0f will be returned if no feedback should be shown. | |
|
joedow
2016/08/31 22:14:12
I'd either remove this line or use javadoc style f
Yuwei
2016/08/31 22:24:57
Done. Use javadoc style and give more useful comme
| |
| 31 */ | |
| 32 public float getFeedbackRadius(DesktopView.InputFeedbackType feedbackToShow, | |
| 33 float scaleFactor) { | |
| 34 switch (feedbackToShow) { | |
| 35 case NONE: | |
| 36 return 0.0f; | |
| 37 case SHORT_TOUCH_ANIMATION: | |
| 38 return mSmallFeedbackPixelRadius / scaleFactor; | |
| 39 case LONG_TOUCH_ANIMATION: | |
| 40 return mLargeFeedbackPixelRadius / scaleFactor; | |
| 41 case LONG_TRACKPAD_ANIMATION: | |
| 42 // The size of the longpress trackpad animation is supposed to b e close to the | |
| 43 // size of the cursor so it doesn't need to be normalized and sh ould be scaled | |
| 44 // with the canvas. | |
| 45 return mTinyFeedbackPixelRadius; | |
| 46 default: | |
| 47 // Unreachable, but required by Google Java style and findbugs. | |
| 48 assert false : "Unreached"; | |
| 49 return 0.0f; | |
| 50 } | |
| 51 } | |
| 52 } | |
| OLD | NEW |