Update ripple alphas

Bug: 63635160
Test: clicked, hovered, and focused stuff
Change-Id: Ic3ba65b467706969c904d7fe313bd3d659dcc4af
This commit is contained in:
John Reck
2018-01-10 16:12:19 -08:00
parent 03033385af
commit 2d0735fe91
3 changed files with 9 additions and 18 deletions

View File

@@ -77,9 +77,9 @@
<item name="secondary_content_alpha_material_dark" format="float" type="dimen">.7</item>
<item name="secondary_content_alpha_material_light" format="float" type="dimen">0.54</item>
<item name="highlight_alpha_material_light" format="float" type="dimen">0.12</item>
<item name="highlight_alpha_material_dark" format="float" type="dimen">0.20</item>
<item name="highlight_alpha_material_colored" format="float" type="dimen">0.26</item>
<item name="highlight_alpha_material_light" format="float" type="dimen">0.16</item>
<item name="highlight_alpha_material_dark" format="float" type="dimen">0.32</item>
<item name="highlight_alpha_material_colored" format="float" type="dimen">0.48</item>
<!-- Primary & accent colors -->
<eat-comment />

View File

@@ -16,17 +16,12 @@
package android.graphics.drawable;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.graphics.Canvas;
import android.graphics.CanvasProperty;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.FloatProperty;
import android.view.DisplayListCanvas;
import android.view.RenderNodeAnimator;
import android.view.animation.LinearInterpolator;
/**
@@ -78,8 +73,8 @@ class RippleBackground extends RippleComponent {
private void onStateChanged(boolean animateChanged) {
float newOpacity = 0.0f;
if (mHovered) newOpacity += 1.0f;
if (mFocused) newOpacity += 1.0f;
if (mHovered) newOpacity += .25f;
if (mFocused) newOpacity += .75f;
if (mAnimator != null) {
mAnimator.cancel();
mAnimator = null;

View File

@@ -264,8 +264,8 @@ public class RippleDrawable extends LayerDrawable {
}
setRippleActive(enabled && pressed);
setBackgroundActive(hovered, focused);
return changed;
}
@@ -879,22 +879,18 @@ public class RippleDrawable extends LayerDrawable {
// Grab the color for the current state and cut the alpha channel in
// half so that the ripple and background together yield full alpha.
final int color = mState.mColor.getColorForState(getState(), Color.BLACK);
final int halfAlpha = (Color.alpha(color) / 2) << 24;
final Paint p = mRipplePaint;
if (mMaskColorFilter != null) {
// The ripple timing depends on the paint's alpha value, so we need
// to push just the alpha channel into the paint and let the filter
// handle the full-alpha color.
final int fullAlphaColor = color | (0xFF << 24);
mMaskColorFilter.setColor(fullAlphaColor);
p.setColor(halfAlpha);
mMaskColorFilter.setColor(color | 0xFF000000);
p.setColor(color & 0xFF000000);
p.setColorFilter(mMaskColorFilter);
p.setShader(mMaskShader);
} else {
final int halfAlphaColor = (color & 0xFFFFFF) | halfAlpha;
p.setColor(halfAlphaColor);
p.setColor(color);
p.setColorFilter(null);
p.setShader(null);
}