Consolidate default values for Ripple shader in one place.
Bug: 278564304 Test: Build (Shouldn't break anything) Change-Id: Ia0cbf1ac8564864bb4619f17c2d37ae3d604fdc0
This commit is contained in:
@@ -19,17 +19,11 @@ data class RippleAnimationConfig(
|
||||
val maxHeight: Float = 0f,
|
||||
val pixelDensity: Float = 1f,
|
||||
var color: Int = Color.WHITE,
|
||||
val opacity: Int = RIPPLE_DEFAULT_ALPHA,
|
||||
val sparkleStrength: Float = RIPPLE_SPARKLE_STRENGTH,
|
||||
val opacity: Int = RippleShader.RIPPLE_DEFAULT_ALPHA,
|
||||
val sparkleStrength: Float = RippleShader.RIPPLE_SPARKLE_STRENGTH,
|
||||
// Null means it uses default fade parameter values.
|
||||
val baseRingFadeParams: RippleShader.FadeParams? = null,
|
||||
val sparkleRingFadeParams: RippleShader.FadeParams? = null,
|
||||
val centerFillFadeParams: RippleShader.FadeParams? = null,
|
||||
val shouldDistort: Boolean = true
|
||||
) {
|
||||
companion object {
|
||||
const val RIPPLE_SPARKLE_STRENGTH: Float = 0.3f
|
||||
const val RIPPLE_DEFAULT_COLOR: Int = 0xffffffff.toInt()
|
||||
const val RIPPLE_DEFAULT_ALPHA: Int = 115 // full opacity is 255.
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -60,6 +60,10 @@ class RippleShader(rippleShape: RippleShape = RippleShape.CIRCLE) :
|
||||
const val DEFAULT_CENTER_FILL_FADE_OUT_START = 0f
|
||||
const val DEFAULT_CENTER_FILL_FADE_OUT_END = 0.6f
|
||||
|
||||
const val RIPPLE_SPARKLE_STRENGTH: Float = 0.3f
|
||||
const val RIPPLE_DEFAULT_COLOR: Int = 0xffffffff.toInt()
|
||||
const val RIPPLE_DEFAULT_ALPHA: Int = 115 // full opacity is 255.
|
||||
|
||||
private const val SHADER_UNIFORMS =
|
||||
"""
|
||||
uniform vec2 in_center;
|
||||
|
||||
@@ -72,9 +72,9 @@ open class RippleView(context: Context?, attrs: AttributeSet?) : View(context, a
|
||||
this.rippleShape = rippleShape
|
||||
rippleShader = RippleShader(rippleShape)
|
||||
|
||||
rippleShader.color = RippleAnimationConfig.RIPPLE_DEFAULT_COLOR
|
||||
rippleShader.color = RippleShader.RIPPLE_DEFAULT_COLOR
|
||||
rippleShader.rawProgress = 0f
|
||||
rippleShader.sparkleStrength = RippleAnimationConfig.RIPPLE_SPARKLE_STRENGTH
|
||||
rippleShader.sparkleStrength = RippleShader.RIPPLE_SPARKLE_STRENGTH
|
||||
rippleShader.pixelDensity = resources.displayMetrics.density
|
||||
|
||||
ripplePaint.shader = rippleShader
|
||||
@@ -209,7 +209,7 @@ open class RippleView(context: Context?, attrs: AttributeSet?) : View(context, a
|
||||
*
|
||||
* The alpha value of the color will be applied to the ripple. The alpha range is [0-255].
|
||||
*/
|
||||
fun setColor(color: Int, alpha: Int = RippleAnimationConfig.RIPPLE_DEFAULT_ALPHA) {
|
||||
fun setColor(color: Int, alpha: Int = RippleShader.RIPPLE_DEFAULT_ALPHA) {
|
||||
rippleShader.color = ColorUtils.setAlphaComponent(color, alpha)
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.android.settingslib.Utils;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.animation.Interpolators;
|
||||
import com.android.systemui.shared.recents.utilities.Utilities;
|
||||
import com.android.systemui.surfaceeffects.ripple.RippleAnimationConfig;
|
||||
import com.android.systemui.surfaceeffects.ripple.RippleShader;
|
||||
import com.android.systemui.surfaceeffects.ripple.RippleShader.RippleShape;
|
||||
import com.android.systemui.surfaceeffects.ripple.RippleView;
|
||||
@@ -177,7 +176,7 @@ final class WirelessChargingLayout extends FrameLayout {
|
||||
mRippleView.setBlur(6.5f, 2.5f);
|
||||
} else {
|
||||
mRippleView.setDuration(CIRCLE_RIPPLE_ANIMATION_DURATION);
|
||||
mRippleView.setColor(color, RippleAnimationConfig.RIPPLE_DEFAULT_ALPHA);
|
||||
mRippleView.setColor(color, RippleShader.RIPPLE_DEFAULT_ALPHA);
|
||||
}
|
||||
|
||||
OnAttachStateChangeListener listener = new OnAttachStateChangeListener() {
|
||||
|
||||
Reference in New Issue
Block a user