Merge "Remove alpha clamping from ripple drawable" into tm-qpr-dev

This commit is contained in:
Jay Aliomer
2023-01-19 21:47:10 +00:00
committed by Android (Google) Code Review
2 changed files with 5 additions and 13 deletions

View File

@@ -72,8 +72,8 @@
<item name="secondary_content_alpha_material_dark" format="float" type="dimen">.7</item> <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.60</item> <item name="secondary_content_alpha_material_light" format="float" type="dimen">0.60</item>
<item name="highlight_alpha_material_light" format="float" type="dimen">0.10</item> <item name="highlight_alpha_material_light" format="float" type="dimen">0.5</item>
<item name="highlight_alpha_material_dark" format="float" type="dimen">0.10</item> <item name="highlight_alpha_material_dark" format="float" type="dimen">0.5</item>
<item name="highlight_alpha_material_colored" format="float" type="dimen">0.10</item> <item name="highlight_alpha_material_colored" format="float" type="dimen">0.10</item>
<!-- Primary & accent colors --> <!-- Primary & accent colors -->

View File

@@ -23,7 +23,6 @@ import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.SOURCE; import static java.lang.annotation.RetentionPolicy.SOURCE;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.ColorInt;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
@@ -983,9 +982,9 @@ public class RippleDrawable extends LayerDrawable {
RippleShader shader = new RippleShader(); RippleShader shader = new RippleShader();
// Grab the color for the current state and cut the alpha channel in // Grab the color for the current state and cut the alpha channel in
// half so that the ripple and background together yield full alpha. // half so that the ripple and background together yield full alpha.
final int color = clampAlpha(mMaskColorFilter == null final int color = mMaskColorFilter == null
? mState.mColor.getColorForState(getState(), Color.BLACK) ? mState.mColor.getColorForState(getState(), Color.BLACK)
: mMaskColorFilter.getColor()); : mMaskColorFilter.getColor();
final int effectColor = mState.mEffectColor.getColorForState(getState(), Color.MAGENTA); final int effectColor = mState.mEffectColor.getColorForState(getState(), Color.MAGENTA);
final float noisePhase = AnimationUtils.currentAnimationTimeMillis(); final float noisePhase = AnimationUtils.currentAnimationTimeMillis();
shader.setColor(color, effectColor); shader.setColor(color, effectColor);
@@ -1008,13 +1007,6 @@ public class RippleDrawable extends LayerDrawable {
return properties; return properties;
} }
private int clampAlpha(@ColorInt int color) {
if (Color.alpha(color) < 128) {
return (color & 0x00FFFFFF) | 0x80000000;
}
return color;
}
@Override @Override
public void invalidateSelf() { public void invalidateSelf() {
invalidateSelf(true); invalidateSelf(true);
@@ -1229,7 +1221,7 @@ public class RippleDrawable extends LayerDrawable {
// Grab the color for the current state and cut the alpha channel in // Grab the color for the current state and cut the alpha channel in
// half so that the ripple and background together yield full alpha. // half so that the ripple and background together yield full alpha.
final int color = clampAlpha(mState.mColor.getColorForState(getState(), Color.BLACK)); final int color = mState.mColor.getColorForState(getState(), Color.BLACK);
final Paint p = mRipplePaint; final Paint p = mRipplePaint;
if (mMaskColorFilter != null) { if (mMaskColorFilter != null) {