am 1f8f3695: am 1f211a18: am 3778a6aa: Merge "Remove partial support for hotspot changes on focus movement" into lmp-dev

* commit '1f8f369519429a7d7606217e2545369525db996d':
  Remove partial support for hotspot changes on focus movement
This commit is contained in:
Alan Viverette
2014-09-03 23:59:33 +00:00
committed by Android Git Automerger
3 changed files with 6 additions and 173 deletions

View File

@@ -4908,35 +4908,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
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 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
onFocusChanged(false, 0, null);
manageFocusHotspot(false, focused);
refreshDrawableState();
if (propagate && (!refocus || !rootViewRequestFocus())) {

View File

@@ -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;
@@ -110,12 +97,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) {
@@ -133,25 +117,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() {
@@ -159,8 +124,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();
}
}
@@ -175,28 +138,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.
*/
@@ -269,54 +210,24 @@ class RippleBackground {
bounds.set(outerX - r, outerY - r, outerX + r, outerY + r);
}
/**
* 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 @@ 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);
@@ -422,14 +327,6 @@ class RippleBackground {
if (mAnimOuterOpacity != null) {
mAnimOuterOpacity.end();
}
if (mAnimX != null) {
mAnimX.end();
}
if (mAnimY != null) {
mAnimY.end();
}
}
private void endHardwareAnimations() {
@@ -457,16 +354,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.
@@ -510,12 +397,8 @@ class RippleBackground {
}
mAnimOuterOpacity = outerOpacityAnim;
mAnimX = xAnim;
mAnimY = yAnim;
outerOpacityAnim.start();
xAnim.start();
yAnim.start();
}
/**
@@ -531,14 +414,6 @@ class RippleBackground {
if (mAnimOuterOpacity != null) {
mAnimOuterOpacity.cancel();
}
if (mAnimX != null) {
mAnimX.cancel();
}
if (mAnimY != null) {
mAnimY.cancel();
}
}
/**

View File

@@ -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);