summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-09-02 15:58:03 -0700
committerAlan Viverette <alanv@google.com>2014-09-02 15:58:03 -0700
commita8a8ff000b2902eb4e187e62be39fd9535c6c839 (patch)
tree76df6ae6e5d6c0f3eb8b60619ff42adb094f8f47 /graphics
parent02aa75a08303796801ffd74b9c0bd2f8079248af (diff)
downloadframeworks_base-a8a8ff000b2902eb4e187e62be39fd9535c6c839.zip
frameworks_base-a8a8ff000b2902eb4e187e62be39fd9535c6c839.tar.gz
frameworks_base-a8a8ff000b2902eb4e187e62be39fd9535c6c839.tar.bz2
Remove partial support for hotspot changes on focus movement
Also removes unused x/y position and tween values on RippleBackground. The background is now always centered within the hotspot area. BUG: 17300399 Change-Id: I1904c9f44e6bebb2b434d2b092205edd42204263
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/drawable/RippleBackground.java127
-rw-r--r--graphics/java/android/graphics/drawable/RippleDrawable.java25
2 files changed, 6 insertions, 146 deletions
diff --git a/graphics/java/android/graphics/drawable/RippleBackground.java b/graphics/java/android/graphics/drawable/RippleBackground.java
index 40a5e18..0fbbe9d 100644
--- a/graphics/java/android/graphics/drawable/RippleBackground.java
+++ b/graphics/java/android/graphics/drawable/RippleBackground.java
@@ -37,10 +37,8 @@ import java.util.ArrayList;
*/
class RippleBackground {
private static final TimeInterpolator LINEAR_INTERPOLATOR = new LinearInterpolator();
- private static final TimeInterpolator DECEL_INTERPOLATOR = new LogInterpolator();
private static final float GLOBAL_SPEED = 1.0f;
- private static final float WAVE_TOUCH_DOWN_ACCELERATION = 1024.0f * GLOBAL_SPEED;
private static final float WAVE_OPACITY_DECAY_VELOCITY = 3.0f / GLOBAL_SPEED;
private static final float WAVE_OUTER_OPACITY_EXIT_VELOCITY_MAX = 4.5f * GLOBAL_SPEED;
private static final float WAVE_OUTER_OPACITY_EXIT_VELOCITY_MIN = 1.5f * GLOBAL_SPEED;
@@ -70,11 +68,6 @@ class RippleBackground {
/** Screen density used to adjust pixel-based velocities. */
private float mDensity;
- private float mStartingX;
- private float mStartingY;
- private float mClampedStartingX;
- private float mClampedStartingY;
-
// Hardware rendering properties.
private CanvasProperty<Paint> mPropOuterPaint;
private CanvasProperty<Float> mPropOuterRadius;
@@ -83,8 +76,6 @@ class RippleBackground {
// Software animators.
private ObjectAnimator mAnimOuterOpacity;
- private ObjectAnimator mAnimX;
- private ObjectAnimator mAnimY;
// Temporary paint used for creating canvas properties.
private Paint mTempPaint;
@@ -94,10 +85,6 @@ class RippleBackground {
private float mOuterX;
private float mOuterY;
- // Values used to tween between the start and end positions.
- private float mTweenX = 0;
- private float mTweenY = 0;
-
/** Whether we should be drawing hardware animations. */
private boolean mHardwareAnimating;
@@ -113,12 +100,9 @@ class RippleBackground {
/**
* Creates a new ripple.
*/
- public RippleBackground(RippleDrawable owner, Rect bounds, float startingX, float startingY) {
+ public RippleBackground(RippleDrawable owner, Rect bounds) {
mOwner = owner;
mBounds = bounds;
-
- mStartingX = startingX;
- mStartingY = startingY;
}
public void setup(int maxRadius, int color, float density) {
@@ -136,25 +120,6 @@ class RippleBackground {
mOuterX = 0;
mOuterY = 0;
mDensity = density;
-
- clampStartingPosition();
- }
-
- private void clampStartingPosition() {
- final float cX = mBounds.exactCenterX();
- final float cY = mBounds.exactCenterY();
- final float dX = mStartingX - cX;
- final float dY = mStartingY - cY;
- final float r = mOuterRadius;
- if (dX * dX + dY * dY > r * r) {
- // Point is outside the circle, clamp to the circumference.
- final double angle = Math.atan2(dY, dX);
- mClampedStartingX = cX + (float) (Math.cos(angle) * r);
- mClampedStartingY = cY + (float) (Math.sin(angle) * r);
- } else {
- mClampedStartingX = mStartingX;
- mClampedStartingY = mStartingY;
- }
}
public void onHotspotBoundsChanged() {
@@ -162,8 +127,6 @@ class RippleBackground {
final float halfWidth = mBounds.width() / 2.0f;
final float halfHeight = mBounds.height() / 2.0f;
mOuterRadius = (float) Math.sqrt(halfWidth * halfWidth + halfHeight * halfHeight);
-
- clampStartingPosition();
}
}
@@ -178,28 +141,6 @@ class RippleBackground {
return mOuterOpacity;
}
- @SuppressWarnings("unused")
- public void setXGravity(float x) {
- mTweenX = x;
- invalidateSelf();
- }
-
- @SuppressWarnings("unused")
- public float getXGravity() {
- return mTweenX;
- }
-
- @SuppressWarnings("unused")
- public void setYGravity(float y) {
- mTweenY = y;
- invalidateSelf();
- }
-
- @SuppressWarnings("unused")
- public float getYGravity() {
- return mTweenY;
- }
-
/**
* Draws the ripple centered at (0,0) using the specified paint.
*/
@@ -273,53 +214,23 @@ class RippleBackground {
}
/**
- * Specifies the starting position relative to the drawable bounds. No-op if
- * the ripple has already entered.
- */
- public void move(float x, float y) {
- mStartingX = x;
- mStartingY = y;
-
- clampStartingPosition();
- }
-
- /**
* Starts the enter animation.
*/
public void enter() {
cancel();
- final int radiusDuration = (int)
- (1000 * Math.sqrt(mOuterRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);
final int outerDuration = (int) (1000 * 1.0f / WAVE_OUTER_OPACITY_ENTER_VELOCITY);
-
- final ObjectAnimator cX = ObjectAnimator.ofFloat(this, "xGravity", 1);
- cX.setAutoCancel(true);
- cX.setDuration(radiusDuration);
- cX.setInterpolator(LINEAR_INTERPOLATOR);
- cX.setStartDelay(RIPPLE_ENTER_DELAY);
-
- final ObjectAnimator cY = ObjectAnimator.ofFloat(this, "yGravity", 1);
- cY.setAutoCancel(true);
- cY.setDuration(radiusDuration);
- cY.setInterpolator(LINEAR_INTERPOLATOR);
- cY.setStartDelay(RIPPLE_ENTER_DELAY);
-
final ObjectAnimator outer = ObjectAnimator.ofFloat(this, "outerOpacity", 0, 1);
outer.setAutoCancel(true);
outer.setDuration(outerDuration);
outer.setInterpolator(LINEAR_INTERPOLATOR);
mAnimOuterOpacity = outer;
- mAnimX = cX;
- mAnimY = cY;
// Enter animations always run on the UI thread, since it's unlikely
// that anything interesting is happening until the user lifts their
// finger.
outer.start();
- cX.start();
- cY.start();
}
/**
@@ -355,12 +266,6 @@ class RippleBackground {
private void exitHardware(int opacityDuration, int outerInflection, int inflectionOpacity) {
mPendingAnimations.clear();
- // TODO: Adjust background by starting position.
- final float startX = MathUtils.lerp(
- mClampedStartingX - mBounds.exactCenterX(), mOuterX, mTweenX);
- final float startY = MathUtils.lerp(
- mClampedStartingY - mBounds.exactCenterY(), mOuterY, mTweenY);
-
final Paint outerPaint = getTempPaint();
outerPaint.setAntiAlias(true);
outerPaint.setColor(mColor);
@@ -424,14 +329,6 @@ class RippleBackground {
if (mAnimOuterOpacity != null) {
mAnimOuterOpacity.end();
}
-
- if (mAnimX != null) {
- mAnimX.end();
- }
-
- if (mAnimY != null) {
- mAnimY.end();
- }
}
private void endHardwareAnimations() {
@@ -460,16 +357,6 @@ class RippleBackground {
}
private void exitSoftware(int opacityDuration, int outerInflection, int inflectionOpacity) {
- final ObjectAnimator xAnim = ObjectAnimator.ofFloat(this, "xGravity", 1);
- xAnim.setAutoCancel(true);
- xAnim.setDuration(opacityDuration);
- xAnim.setInterpolator(DECEL_INTERPOLATOR);
-
- final ObjectAnimator yAnim = ObjectAnimator.ofFloat(this, "yGravity", 1);
- yAnim.setAutoCancel(true);
- yAnim.setDuration(opacityDuration);
- yAnim.setInterpolator(DECEL_INTERPOLATOR);
-
final ObjectAnimator outerOpacityAnim;
if (outerInflection > 0) {
// Outer opacity continues to increase for a bit.
@@ -513,12 +400,8 @@ class RippleBackground {
}
mAnimOuterOpacity = outerOpacityAnim;
- mAnimX = xAnim;
- mAnimY = yAnim;
outerOpacityAnim.start();
- xAnim.start();
- yAnim.start();
}
/**
@@ -536,14 +419,6 @@ class RippleBackground {
if (mAnimOuterOpacity != null) {
mAnimOuterOpacity.cancel();
}
-
- if (mAnimX != null) {
- mAnimX.cancel();
- }
-
- if (mAnimY != null) {
- mAnimY.cancel();
- }
}
/**
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index b90fd81..94dd760 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -248,15 +248,14 @@ public class RippleDrawable extends LayerDrawable {
boolean pressed = false;
boolean focused = false;
- final int N = stateSet.length;
- for (int i = 0; i < N; i++) {
- if (stateSet[i] == R.attr.state_enabled) {
+ for (int state : stateSet) {
+ if (state == R.attr.state_enabled) {
enabled = true;
}
- if (stateSet[i] == R.attr.state_focused) {
+ if (state == R.attr.state_focused) {
focused = true;
}
- if (stateSet[i] == R.attr.state_pressed) {
+ if (state == R.attr.state_pressed) {
pressed = true;
}
}
@@ -478,10 +477,6 @@ public class RippleDrawable extends LayerDrawable {
if (mRipple != null) {
mRipple.move(x, y);
}
-
- if (mBackground != null) {
- mBackground.move(x, y);
- }
}
/**
@@ -489,17 +484,7 @@ public class RippleDrawable extends LayerDrawable {
*/
private void tryBackgroundEnter() {
if (mBackground == null) {
- final float x;
- final float y;
- if (mHasPending) {
- mHasPending = false;
- x = mPendingX;
- y = mPendingY;
- } else {
- x = mHotspotBounds.exactCenterX();
- y = mHotspotBounds.exactCenterY();
- }
- mBackground = new RippleBackground(this, mHotspotBounds, x, y);
+ mBackground = new RippleBackground(this, mHotspotBounds);
}
final int color = mState.mColor.getColorForState(getState(), Color.TRANSPARENT);