am 1f211a18: am 3778a6aa: Merge "Remove partial support for hotspot changes on focus movement" into lmp-dev
* commit '1f211a187fe60814f2b7729919600fb30c93475b':
Remove partial support for hotspot changes on focus movement
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index fce6f0b..21e7c6b 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4908,36 +4908,11 @@
}
onFocusChanged(true, direction, previouslyFocusedRect);
- manageFocusHotspot(true, oldFocus);
refreshDrawableState();
}
}
/**
- * Forwards focus information to the background drawable, if necessary. When
- * the view is gaining focus, <code>v</code> is the previous focus holder.
- * When the view is losing focus, <code>v</code> is the next focus holder.
- *
- * @param focused whether this view is focused
- * @param v previous or the next focus holder, or null if none
- */
- private void manageFocusHotspot(boolean focused, View v) {
- final Rect r = new Rect();
- if (v != null && mAttachInfo != null) {
- v.getHotspotBounds(r);
- final int[] location = mAttachInfo.mTmpLocation;
- getLocationOnScreen(location);
- r.offset(-location[0], -location[1]);
- } else {
- r.set(0, 0, mRight - mLeft, mBottom - mTop);
- }
-
- final float x = r.exactCenterX();
- final float y = r.exactCenterY();
- drawableHotspotChanged(x, y);
- }
-
- /**
* Populates <code>outRect</code> with the hotspot bounds. By default,
* the hotspot bounds are identical to the screen bounds.
*
@@ -5060,8 +5035,6 @@
}
onFocusChanged(false, 0, null);
-
- manageFocusHotspot(false, focused);
refreshDrawableState();
if (propagate && (!refocus || !rootViewRequestFocus())) {
diff --git a/graphics/java/android/graphics/drawable/RippleBackground.java b/graphics/java/android/graphics/drawable/RippleBackground.java
index ab43e01..4e68a60 100644
--- a/graphics/java/android/graphics/drawable/RippleBackground.java
+++ b/graphics/java/android/graphics/drawable/RippleBackground.java
@@ -37,10 +37,8 @@
*/
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 @@
/** 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 @@
// 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 @@
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;
@@ -110,12 +97,9 @@
/**
* 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) {
@@ -133,25 +117,6 @@
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() {
@@ -159,8 +124,6 @@
final float halfWidth = mBounds.width() / 2.0f;
final float halfHeight = mBounds.height() / 2.0f;
mOuterRadius = (float) Math.sqrt(halfWidth * halfWidth + halfHeight * halfHeight);
-
- clampStartingPosition();
}
}
@@ -175,28 +138,6 @@
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.
*/
@@ -270,53 +211,23 @@
}
/**
- * 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();
}
/**
@@ -352,12 +263,6 @@
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);
@@ -422,14 +327,6 @@
if (mAnimOuterOpacity != null) {
mAnimOuterOpacity.end();
}
-
- if (mAnimX != null) {
- mAnimX.end();
- }
-
- if (mAnimY != null) {
- mAnimY.end();
- }
}
private void endHardwareAnimations() {
@@ -457,16 +354,6 @@
}
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.
@@ -510,12 +397,8 @@
}
mAnimOuterOpacity = outerOpacityAnim;
- mAnimX = xAnim;
- mAnimY = yAnim;
outerOpacityAnim.start();
- xAnim.start();
- yAnim.start();
}
/**
@@ -531,14 +414,6 @@
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 e87a114..fa762b7 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -248,15 +248,14 @@
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 @@
if (mRipple != null) {
mRipple.move(x, y);
}
-
- if (mBackground != null) {
- mBackground.move(x, y);
- }
}
/**
@@ -489,17 +484,7 @@
*/
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);