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

Unified 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: Add mapper 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 side-by-side diff with in-line comments
Download patch
Index: remoting/android/java/src/org/chromium/chromoting/InputFeedbackRadiusMapper.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/InputFeedbackRadiusMapper.java b/remoting/android/java/src/org/chromium/chromoting/InputFeedbackRadiusMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..ceb13c2d0937215a4ec1e68779e96e5783114763
--- /dev/null
+++ b/remoting/android/java/src/org/chromium/chromoting/InputFeedbackRadiusMapper.java
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chromoting;
+
+/**
+ * Helper class for mapping a feedback type to the max radius of the feedback animation.
+ */
+public final class InputFeedbackRadiusMapper {
+ private final int mTinyFeedbackPixelRadius;
+ private final int mSmallFeedbackPixelRadius;
+ private final int mLargeFeedbackPixelRadius;
+
+ public InputFeedbackRadiusMapper(DesktopView view) {
Hzj_jie 2016/08/31 01:31:59 DesktopView -> View
Yuwei 2016/08/31 18:25:34 Done.
+ mTinyFeedbackPixelRadius = view.getResources()
+ .getDimensionPixelSize(R.dimen.feedback_animation_radius_tiny);
+
+ mSmallFeedbackPixelRadius = view.getResources()
+ .getDimensionPixelSize(R.dimen.feedback_animation_radius_small);
+
+ mLargeFeedbackPixelRadius = view.getResources()
+ .getDimensionPixelSize(R.dimen.feedback_animation_radius_large);
+ }
+
+ /**
+ * Returns the radius of the given feedback type.
+ * 0.0f will be returned if no feedback should be shown.
+ */
+ public float getFeedbackRadius(DesktopView.InputFeedbackType feedbackToShow,
Hzj_jie 2016/08/31 01:31:59 Won't InputFeedbackType be in RenderStub? I suppo
Yuwei 2016/08/31 01:36:13 Probably not. I think it makes more sense to be a
Hzj_jie 2016/08/31 01:38:43 No, I mean DesktopView.InputFeedbackType -> Render
Yuwei 2016/08/31 18:25:34 Yep.
+ float scaleFactor) {
+ switch (feedbackToShow) {
+ case NONE:
+ return 0.0f;
+ case SHORT_TOUCH_ANIMATION:
+ return mSmallFeedbackPixelRadius / scaleFactor;
+ case LONG_TOUCH_ANIMATION:
+ return mLargeFeedbackPixelRadius / scaleFactor;
+ case LONG_TRACKPAD_ANIMATION:
+ // The size of the longpress trackpad animation is supposed to be close to the
+ // size of the cursor so it doesn't need to be normalized and should be scaled
+ // with the canvas.
+ return mTinyFeedbackPixelRadius;
+ default:
+ // Unreachable, but required by Google Java style and findbugs.
+ assert false : "Unreached";
+ return 0.0f;
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698