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

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

Issue 2175353003: [Remoting Android] Define feedback animation size in dp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set up radius inside AbstractDesktopView 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 2016 The Chromium Authors. All rights reserved. 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 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.graphics.Color; 7 import android.graphics.Color;
8 import android.graphics.Paint; 8 import android.graphics.Paint;
9 import android.graphics.Point; 9 import android.graphics.Point;
10 import android.graphics.RadialGradient; 10 import android.graphics.RadialGradient;
(...skipping 18 matching lines...) Expand all
29 29
30 private FeedbackAnimator(float feedbackSizeInPixels, Point pos) { 30 private FeedbackAnimator(float feedbackSizeInPixels, Point pos) {
31 mStartTimeInMs = SystemClock.uptimeMillis(); 31 mStartTimeInMs = SystemClock.uptimeMillis();
32 mFeedbackSizeInPixels = feedbackSizeInPixels; 32 mFeedbackSizeInPixels = feedbackSizeInPixels;
33 mPos = pos; 33 mPos = pos;
34 } 34 }
35 35
36 /** Begins a new animation sequence at position (|pos|). */ 36 /** Begins a new animation sequence at position (|pos|). */
37 public static void startAnimation(DesktopView view, 37 public static void startAnimation(DesktopView view,
38 Point pos, 38 Point pos,
39 DesktopView.InputFeedbackType feedbackType ) { 39 float feedbackRadius) {
40 if (feedbackType == DesktopView.InputFeedbackType.NONE) { 40 if (feedbackRadius <= 0) {
joedow 2016/07/26 03:03:24 it might be clearer to compare with 0.0f here.
Yuwei 2016/07/26 18:47:26 Done.
41 return; 41 return;
42 } 42 }
43 43
44 view.onPaint().addSelfRemovable(new FeedbackAnimator( 44 view.onPaint().addSelfRemovable(new FeedbackAnimator(feedbackRadius, pos ));
45 getInputFeedbackSizeInPixels(feedbackType), pos));
46 }
47
48 private static float getInputFeedbackSizeInPixels(DesktopView.InputFeedbackT ype feedbackType) {
49 switch (feedbackType) {
50 case SMALL_ANIMATION:
51 return 40.0f;
52
53 case LARGE_ANIMATION:
54 return 160.0f;
55
56 default:
57 // Unreachable, but required by Google Java style and findbugs.
58 assert false : "Unreached";
59 return 0.0f;
60 }
61 } 45 }
62 46
63 @Override 47 @Override
64 public Boolean run(PaintEventParameter parameter) { 48 public Boolean run(PaintEventParameter parameter) {
65 float elapsedTimeInMs = SystemClock.uptimeMillis() - mStartTimeInMs; 49 float elapsedTimeInMs = SystemClock.uptimeMillis() - mStartTimeInMs;
66 if (elapsedTimeInMs < 1) { 50 if (elapsedTimeInMs < 1) {
67 return true; 51 return true;
68 } 52 }
69 53
70 // |progress| is 0 at the beginning, 1 at the end. 54 // |progress| is 0 at the beginning, 1 at the end.
(...skipping 13 matching lines...) Expand all
84 int transparentBlack = Color.argb(0, 0, 0, 0); 68 int transparentBlack = Color.argb(0, 0, 0, 0);
85 int white = Color.argb(alpha, 0xff, 0xff, 0xff); 69 int white = Color.argb(alpha, 0xff, 0xff, 0xff);
86 int black = Color.argb(alpha, 0, 0, 0); 70 int black = Color.argb(alpha, 0, 0, 0);
87 mPaint.setShader(new RadialGradient(mPos.x, mPos.y, radius, 71 mPaint.setShader(new RadialGradient(mPos.x, mPos.y, radius,
88 new int[] {transparentBlack, white, black, transparentBlack}, 72 new int[] {transparentBlack, white, black, transparentBlack},
89 new float[] {0.0f, 0.8f, 0.9f, 1.0f}, Shader.TileMode.CLAMP)); 73 new float[] {0.0f, 0.8f, 0.9f, 1.0f}, Shader.TileMode.CLAMP));
90 parameter.canvas.drawCircle(mPos.x, mPos.y, radius, mPaint); 74 parameter.canvas.drawCircle(mPos.x, mPos.y, radius, mPaint);
91 return true; 75 return true;
92 } 76 }
93 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698