Loading graphics/java/android/graphics/drawable/RippleBackground.java +16 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.view.animation.LinearInterpolator; * Draws a ripple background. */ class RippleBackground extends RippleComponent { private static final TimeInterpolator LINEAR_INTERPOLATOR = new LinearInterpolator(); private static final int OPACITY_ENTER_DURATION = 600; Loading @@ -48,8 +49,14 @@ class RippleBackground extends RippleComponent { // Software rendering properties. private float mOpacity = 0; public RippleBackground(RippleDrawable owner, Rect bounds, boolean forceSoftware) { /** Whether this ripple is bounded. */ private boolean mIsBounded; public RippleBackground(RippleDrawable owner, Rect bounds, boolean isBounded, boolean forceSoftware) { super(owner, bounds, forceSoftware); mIsBounded = isBounded; } public boolean isVisible() { Loading Loading @@ -105,7 +112,8 @@ class RippleBackground extends RippleComponent { final AnimatorSet.Builder builder = set.play(exit); // Linear "fast" enter based on current opacity. final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST); final int fastEnterDuration = mIsBounded ? (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST) : 0; if (fastEnterDuration > 0) { final ObjectAnimator enter = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 1); enter.setInterpolator(LINEAR_INTERPOLATOR); Loading @@ -131,15 +139,18 @@ class RippleBackground extends RippleComponent { mPropX = CanvasProperty.createFloat(0); mPropY = CanvasProperty.createFloat(0); final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST); final int fastEnterDuration = mIsBounded ? (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST) : 0; // Linear exit after enter is completed. final RenderNodeAnimator exit = new RenderNodeAnimator( mPropPaint, RenderNodeAnimator.PAINT_ALPHA, 0); exit.setInterpolator(LINEAR_INTERPOLATOR); exit.setDuration(OPACITY_EXIT_DURATION); if (fastEnterDuration > 0) { exit.setStartDelay(fastEnterDuration); exit.setStartValue(targetAlpha); } set.add(exit); // Linear "fast" enter based on current opacity. Loading graphics/java/android/graphics/drawable/RippleDrawable.java +2 −1 Original line number Diff line number Diff line Loading @@ -540,7 +540,8 @@ public class RippleDrawable extends LayerDrawable { */ private void tryBackgroundEnter(boolean focused) { if (mBackground == null) { mBackground = new RippleBackground(this, mHotspotBounds, mForceSoftware); final boolean isBounded = isBounded(); mBackground = new RippleBackground(this, mHotspotBounds, isBounded, mForceSoftware); } mBackground.setup(mState.mMaxRadius, mDensity); Loading Loading
graphics/java/android/graphics/drawable/RippleBackground.java +16 −5 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.view.animation.LinearInterpolator; * Draws a ripple background. */ class RippleBackground extends RippleComponent { private static final TimeInterpolator LINEAR_INTERPOLATOR = new LinearInterpolator(); private static final int OPACITY_ENTER_DURATION = 600; Loading @@ -48,8 +49,14 @@ class RippleBackground extends RippleComponent { // Software rendering properties. private float mOpacity = 0; public RippleBackground(RippleDrawable owner, Rect bounds, boolean forceSoftware) { /** Whether this ripple is bounded. */ private boolean mIsBounded; public RippleBackground(RippleDrawable owner, Rect bounds, boolean isBounded, boolean forceSoftware) { super(owner, bounds, forceSoftware); mIsBounded = isBounded; } public boolean isVisible() { Loading Loading @@ -105,7 +112,8 @@ class RippleBackground extends RippleComponent { final AnimatorSet.Builder builder = set.play(exit); // Linear "fast" enter based on current opacity. final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST); final int fastEnterDuration = mIsBounded ? (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST) : 0; if (fastEnterDuration > 0) { final ObjectAnimator enter = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 1); enter.setInterpolator(LINEAR_INTERPOLATOR); Loading @@ -131,15 +139,18 @@ class RippleBackground extends RippleComponent { mPropX = CanvasProperty.createFloat(0); mPropY = CanvasProperty.createFloat(0); final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST); final int fastEnterDuration = mIsBounded ? (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST) : 0; // Linear exit after enter is completed. final RenderNodeAnimator exit = new RenderNodeAnimator( mPropPaint, RenderNodeAnimator.PAINT_ALPHA, 0); exit.setInterpolator(LINEAR_INTERPOLATOR); exit.setDuration(OPACITY_EXIT_DURATION); if (fastEnterDuration > 0) { exit.setStartDelay(fastEnterDuration); exit.setStartValue(targetAlpha); } set.add(exit); // Linear "fast" enter based on current opacity. Loading
graphics/java/android/graphics/drawable/RippleDrawable.java +2 −1 Original line number Diff line number Diff line Loading @@ -540,7 +540,8 @@ public class RippleDrawable extends LayerDrawable { */ private void tryBackgroundEnter(boolean focused) { if (mBackground == null) { mBackground = new RippleBackground(this, mHotspotBounds, mForceSoftware); final boolean isBounded = isBounded(); mBackground = new RippleBackground(this, mHotspotBounds, isBounded, mForceSoftware); } mBackground.setup(mState.mMaxRadius, mDensity); Loading