Isolate & fix animation logic for BP icon/overlay
Separates and corrects logic of BiometricPrompt icon animation and overlay animation to ensure animation plays after device rotations Test: Open BiometricPrompt on SFPS device, observe animation is played after rotations Fixes: 263343756 Change-Id: I72ed42894e261fd944fbe4363dc3f02b86c6c000
This commit is contained in:
@@ -35,13 +35,13 @@ class AuthBiometricFingerprintAndFaceIconController(
|
||||
|
||||
override val actsAsConfirmButton: Boolean = true
|
||||
|
||||
override fun shouldAnimateForTransition(
|
||||
override fun shouldAnimateIconViewForTransition(
|
||||
@BiometricState oldState: Int,
|
||||
@BiometricState newState: Int
|
||||
): Boolean = when (newState) {
|
||||
STATE_PENDING_CONFIRMATION -> true
|
||||
STATE_AUTHENTICATED -> false
|
||||
else -> super.shouldAnimateForTransition(oldState, newState)
|
||||
else -> super.shouldAnimateIconViewForTransition(oldState, newState)
|
||||
}
|
||||
|
||||
@RawRes
|
||||
|
||||
@@ -104,12 +104,14 @@ open class AuthBiometricFingerprintIconController(
|
||||
|
||||
iconView.frame = 0
|
||||
iconViewOverlay.frame = 0
|
||||
if (shouldAnimateForTransition(lastState, newState)) {
|
||||
iconView.playAnimation()
|
||||
iconViewOverlay.playAnimation()
|
||||
} else if (lastState == STATE_IDLE && newState == STATE_AUTHENTICATING_ANIMATING_IN) {
|
||||
if (shouldAnimateIconViewForTransition(lastState, newState)) {
|
||||
iconView.playAnimation()
|
||||
}
|
||||
|
||||
if (shouldAnimateIconViewOverlayForTransition(lastState, newState)) {
|
||||
iconViewOverlay.playAnimation()
|
||||
}
|
||||
|
||||
LottieColorUtils.applyDynamicColors(context, iconView)
|
||||
LottieColorUtils.applyDynamicColors(context, iconViewOverlay)
|
||||
}
|
||||
@@ -127,7 +129,7 @@ open class AuthBiometricFingerprintIconController(
|
||||
}
|
||||
|
||||
iconView.frame = 0
|
||||
if (shouldAnimateForTransition(lastState, newState)) {
|
||||
if (shouldAnimateIconViewForTransition(lastState, newState)) {
|
||||
iconView.playAnimation()
|
||||
}
|
||||
LottieColorUtils.applyDynamicColors(context, iconView)
|
||||
@@ -160,7 +162,20 @@ open class AuthBiometricFingerprintIconController(
|
||||
return if (id != null) context.getString(id) else null
|
||||
}
|
||||
|
||||
protected open fun shouldAnimateForTransition(
|
||||
protected open fun shouldAnimateIconViewForTransition(
|
||||
@BiometricState oldState: Int,
|
||||
@BiometricState newState: Int
|
||||
) = when (newState) {
|
||||
STATE_HELP,
|
||||
STATE_ERROR -> true
|
||||
STATE_AUTHENTICATING_ANIMATING_IN,
|
||||
STATE_AUTHENTICATING ->
|
||||
oldState == STATE_ERROR || oldState == STATE_HELP || oldState == STATE_IDLE
|
||||
STATE_AUTHENTICATED -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
protected open fun shouldAnimateIconViewOverlayForTransition(
|
||||
@BiometricState oldState: Int,
|
||||
@BiometricState newState: Int
|
||||
) = when (newState) {
|
||||
|
||||
Reference in New Issue
Block a user