Merge "Auth ripple updates" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6ce7011395
@@ -1462,6 +1462,10 @@
|
|||||||
<!-- Maximum overshoot for the pulse expansion -->
|
<!-- Maximum overshoot for the pulse expansion -->
|
||||||
<dimen name="pulse_expansion_max_top_overshoot">32dp</dimen>
|
<dimen name="pulse_expansion_max_top_overshoot">32dp</dimen>
|
||||||
|
|
||||||
|
<!-- Alpha in duration in ms for the auth ripple to become fully vislble. If set to 0,
|
||||||
|
it is immediately visible. -->
|
||||||
|
<integer name="auth_ripple_alpha_in_duration">100</integer>
|
||||||
|
|
||||||
<dimen name="people_space_widget_radius">28dp</dimen>
|
<dimen name="people_space_widget_radius">28dp</dimen>
|
||||||
<dimen name="people_space_image_radius">20dp</dimen>
|
<dimen name="people_space_image_radius">20dp</dimen>
|
||||||
<dimen name="people_space_messages_count_radius">12dp</dimen>
|
<dimen name="people_space_messages_count_radius">12dp</dimen>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import androidx.annotation.VisibleForTesting
|
|||||||
import com.android.keyguard.KeyguardUpdateMonitor
|
import com.android.keyguard.KeyguardUpdateMonitor
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
||||||
import com.android.settingslib.Utils
|
import com.android.settingslib.Utils
|
||||||
|
import com.android.systemui.R
|
||||||
import com.android.systemui.statusbar.CircleReveal
|
import com.android.systemui.statusbar.CircleReveal
|
||||||
import com.android.systemui.statusbar.LightRevealEffect
|
import com.android.systemui.statusbar.LightRevealEffect
|
||||||
import com.android.systemui.statusbar.NotificationShadeWindowController
|
import com.android.systemui.statusbar.NotificationShadeWindowController
|
||||||
@@ -59,6 +60,11 @@ class AuthRippleController @Inject constructor(
|
|||||||
private var faceSensorLocation: PointF? = null
|
private var faceSensorLocation: PointF? = null
|
||||||
private var circleReveal: LightRevealEffect? = null
|
private var circleReveal: LightRevealEffect? = null
|
||||||
|
|
||||||
|
override fun onInit() {
|
||||||
|
mView.setAlphaInDuration(sysuiContext.resources.getInteger(
|
||||||
|
R.integer.auth_ripple_alpha_in_duration).toLong())
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public override fun onViewAttached() {
|
public override fun onViewAttached() {
|
||||||
updateRippleColor()
|
updateRippleColor()
|
||||||
@@ -79,7 +85,7 @@ class AuthRippleController @Inject constructor(
|
|||||||
notificationShadeWindowController.setForcePluginOpen(false, this)
|
notificationShadeWindowController.setForcePluginOpen(false, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showRipple(biometricSourceType: BiometricSourceType?) {
|
fun showRipple(biometricSourceType: BiometricSourceType?) {
|
||||||
if (!keyguardUpdateMonitor.isKeyguardVisible ||
|
if (!keyguardUpdateMonitor.isKeyguardVisible ||
|
||||||
keyguardUpdateMonitor.userNeedsStrongAuth()) {
|
keyguardUpdateMonitor.userNeedsStrongAuth()) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ private const val RIPPLE_SPARKLE_STRENGTH: Float = 0.4f
|
|||||||
* launcher.
|
* launcher.
|
||||||
*/
|
*/
|
||||||
class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {
|
class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {
|
||||||
|
private var alphaInDuration: Long = 0
|
||||||
private var rippleInProgress: Boolean = false
|
private var rippleInProgress: Boolean = false
|
||||||
private val rippleShader = RippleShader()
|
private val rippleShader = RippleShader()
|
||||||
private val ripplePaint = Paint()
|
private val ripplePaint = Paint()
|
||||||
@@ -66,47 +67,37 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at
|
|||||||
.toFloat()
|
.toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setAlphaInDuration(duration: Long) {
|
||||||
|
alphaInDuration = duration
|
||||||
|
}
|
||||||
|
|
||||||
fun startRipple(onAnimationEnd: Runnable?, lightReveal: LightRevealScrim?) {
|
fun startRipple(onAnimationEnd: Runnable?, lightReveal: LightRevealScrim?) {
|
||||||
if (rippleInProgress) {
|
if (rippleInProgress) {
|
||||||
return // Ignore if ripple effect is already playing
|
return // Ignore if ripple effect is already playing
|
||||||
}
|
}
|
||||||
|
|
||||||
val rippleAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
|
val rippleAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
|
||||||
interpolator = PathInterpolator(0.4f, 0f, 0f, 1f)
|
interpolator = PathInterpolator(0f, 0f, .2f, 1f)
|
||||||
duration = RIPPLE_ANIMATION_DURATION
|
duration = RIPPLE_ANIMATION_DURATION
|
||||||
addUpdateListener { animator ->
|
addUpdateListener { animator ->
|
||||||
val now = animator.currentPlayTime
|
val now = animator.currentPlayTime
|
||||||
rippleShader.progress = animator.animatedValue as Float
|
rippleShader.progress = animator.animatedValue as Float
|
||||||
rippleShader.time = now.toFloat()
|
rippleShader.time = now.toFloat()
|
||||||
|
|
||||||
lightReveal?.revealAmount = animator.animatedValue as Float
|
|
||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val revealAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
|
val revealAnimator = ValueAnimator.ofFloat(.1f, 1f).apply {
|
||||||
interpolator = rippleAnimator.interpolator
|
interpolator = rippleAnimator.interpolator
|
||||||
startDelay = 10
|
|
||||||
duration = rippleAnimator.duration
|
duration = rippleAnimator.duration
|
||||||
addUpdateListener { animator ->
|
addUpdateListener { animator ->
|
||||||
lightReveal?.revealAmount = animator.animatedValue as Float
|
lightReveal?.revealAmount = animator.animatedValue as Float
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val alphaInAnimator = ValueAnimator.ofInt(0, 127).apply {
|
val alphaInAnimator = ValueAnimator.ofInt(0, 255).apply {
|
||||||
duration = 167
|
duration = alphaInDuration
|
||||||
addUpdateListener { animator ->
|
|
||||||
rippleShader.color = ColorUtils.setAlphaComponent(
|
|
||||||
rippleShader.color,
|
|
||||||
animator.animatedValue as Int
|
|
||||||
)
|
|
||||||
invalidate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val alphaOutAnimator = ValueAnimator.ofInt(127, 0).apply {
|
|
||||||
startDelay = 417
|
|
||||||
duration = 1116
|
|
||||||
addUpdateListener { animator ->
|
addUpdateListener { animator ->
|
||||||
rippleShader.color = ColorUtils.setAlphaComponent(
|
rippleShader.color = ColorUtils.setAlphaComponent(
|
||||||
rippleShader.color,
|
rippleShader.color,
|
||||||
@@ -120,8 +111,7 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at
|
|||||||
playTogether(
|
playTogether(
|
||||||
rippleAnimator,
|
rippleAnimator,
|
||||||
revealAnimator,
|
revealAnimator,
|
||||||
alphaInAnimator,
|
alphaInAnimator
|
||||||
alphaOutAnimator
|
|
||||||
)
|
)
|
||||||
addListener(object : AnimatorListenerAdapter() {
|
addListener(object : AnimatorListenerAdapter() {
|
||||||
override fun onAnimationStart(animation: Animator?) {
|
override fun onAnimationStart(animation: Animator?) {
|
||||||
@@ -148,7 +138,7 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at
|
|||||||
// the active effect area. Values here should be kept in sync with the
|
// the active effect area. Values here should be kept in sync with the
|
||||||
// animation implementation in the ripple shader.
|
// animation implementation in the ripple shader.
|
||||||
val maskRadius = (1 - (1 - rippleShader.progress) * (1 - rippleShader.progress) *
|
val maskRadius = (1 - (1 - rippleShader.progress) * (1 - rippleShader.progress) *
|
||||||
(1 - rippleShader.progress)) * radius * 1.5f
|
(1 - rippleShader.progress)) * radius * 2f
|
||||||
canvas?.drawCircle(origin.x, origin.y, maskRadius, ripplePaint)
|
canvas?.drawCircle(origin.x, origin.y, maskRadius, ripplePaint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user