am 466f5581: Merge "Slow down ripple background fade in from press" into lmp-mr1-dev
* commit '466f5581ef1b45e601dc40db53a5ebd2d465ae14': Slow down ripple background fade in from press
This commit is contained in:
@@ -43,10 +43,12 @@ class RippleBackground {
|
|||||||
private static final float WAVE_OPACITY_DECAY_VELOCITY = 3.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_MAX = 4.5f * GLOBAL_SPEED;
|
||||||
private static final float WAVE_OUTER_OPACITY_EXIT_VELOCITY_MIN = 1.5f * GLOBAL_SPEED;
|
private static final float WAVE_OUTER_OPACITY_EXIT_VELOCITY_MIN = 1.5f * GLOBAL_SPEED;
|
||||||
private static final float WAVE_OUTER_OPACITY_ENTER_VELOCITY = 10.0f * GLOBAL_SPEED;
|
|
||||||
private static final float WAVE_OUTER_SIZE_INFLUENCE_MAX = 200f;
|
private static final float WAVE_OUTER_SIZE_INFLUENCE_MAX = 200f;
|
||||||
private static final float WAVE_OUTER_SIZE_INFLUENCE_MIN = 40f;
|
private static final float WAVE_OUTER_SIZE_INFLUENCE_MIN = 40f;
|
||||||
|
|
||||||
|
private static final int ENTER_DURATION = 667;
|
||||||
|
private static final int ENTER_DURATION_FAST = 100;
|
||||||
|
|
||||||
// Hardware animators.
|
// Hardware animators.
|
||||||
private final ArrayList<RenderNodeAnimator> mRunningAnimations =
|
private final ArrayList<RenderNodeAnimator> mRunningAnimations =
|
||||||
new ArrayList<RenderNodeAnimator>();
|
new ArrayList<RenderNodeAnimator>();
|
||||||
@@ -224,21 +226,20 @@ class RippleBackground {
|
|||||||
/**
|
/**
|
||||||
* Starts the enter animation.
|
* Starts the enter animation.
|
||||||
*/
|
*/
|
||||||
public void enter() {
|
public void enter(boolean fast) {
|
||||||
cancel();
|
cancel();
|
||||||
|
|
||||||
final int outerDuration = (int) (1000 * 1.0f / WAVE_OUTER_OPACITY_ENTER_VELOCITY);
|
final ObjectAnimator opacity = ObjectAnimator.ofFloat(this, "outerOpacity", 0, 1);
|
||||||
final ObjectAnimator outer = ObjectAnimator.ofFloat(this, "outerOpacity", 0, 1);
|
opacity.setAutoCancel(true);
|
||||||
outer.setAutoCancel(true);
|
opacity.setDuration(fast ? ENTER_DURATION_FAST : ENTER_DURATION);
|
||||||
outer.setDuration(outerDuration);
|
opacity.setInterpolator(LINEAR_INTERPOLATOR);
|
||||||
outer.setInterpolator(LINEAR_INTERPOLATOR);
|
|
||||||
|
|
||||||
mAnimOuterOpacity = outer;
|
mAnimOuterOpacity = opacity;
|
||||||
|
|
||||||
// Enter animations always run on the UI thread, since it's unlikely
|
// Enter animations always run on the UI thread, since it's unlikely
|
||||||
// that anything interesting is happening until the user lifts their
|
// that anything interesting is happening until the user lifts their
|
||||||
// finger.
|
// finger.
|
||||||
outer.start();
|
opacity.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setRippleActive(enabled && pressed);
|
setRippleActive(enabled && pressed);
|
||||||
setBackgroundActive(focused || (enabled && pressed));
|
setBackgroundActive(focused || (enabled && pressed), focused);
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
@@ -296,11 +296,11 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBackgroundActive(boolean active) {
|
private void setBackgroundActive(boolean active, boolean focused) {
|
||||||
if (mBackgroundActive != active) {
|
if (mBackgroundActive != active) {
|
||||||
mBackgroundActive = active;
|
mBackgroundActive = active;
|
||||||
if (active) {
|
if (active) {
|
||||||
tryBackgroundEnter();
|
tryBackgroundEnter(focused);
|
||||||
} else {
|
} else {
|
||||||
tryBackgroundExit();
|
tryBackgroundExit();
|
||||||
}
|
}
|
||||||
@@ -333,8 +333,11 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mBackgroundActive) {
|
if (mBackgroundActive) {
|
||||||
tryBackgroundEnter();
|
tryBackgroundEnter(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip animations, just show the correct final states.
|
||||||
|
jumpToCurrentState();
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
@@ -489,14 +492,14 @@ public class RippleDrawable extends LayerDrawable {
|
|||||||
/**
|
/**
|
||||||
* Creates an active hotspot at the specified location.
|
* Creates an active hotspot at the specified location.
|
||||||
*/
|
*/
|
||||||
private void tryBackgroundEnter() {
|
private void tryBackgroundEnter(boolean focused) {
|
||||||
if (mBackground == null) {
|
if (mBackground == null) {
|
||||||
mBackground = new RippleBackground(this, mHotspotBounds);
|
mBackground = new RippleBackground(this, mHotspotBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
final int color = mState.mColor.getColorForState(getState(), Color.TRANSPARENT);
|
final int color = mState.mColor.getColorForState(getState(), Color.TRANSPARENT);
|
||||||
mBackground.setup(mState.mMaxRadius, color, mDensity);
|
mBackground.setup(mState.mMaxRadius, color, mDensity);
|
||||||
mBackground.enter();
|
mBackground.enter(focused);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryBackgroundExit() {
|
private void tryBackgroundExit() {
|
||||||
|
|||||||
Reference in New Issue
Block a user