1717package com .android .internal .policy .impl .keyguard ;
1818
1919import android .animation .Animator ;
20+ import android .animation .AnimatorListenerAdapter ;
2021import android .animation .ObjectAnimator ;
2122import android .graphics .drawable .Drawable ;
2223import android .view .View ;
2728public class KeyguardSecurityViewHelper {
2829
2930 public static void showBouncer (SecurityMessageDisplay securityMessageDisplay ,
30- View ecaView , Drawable bouncerFrame , int duration ) {
31+ final View ecaView , Drawable bouncerFrame , int duration ) {
3132 if (securityMessageDisplay != null ) {
3233 securityMessageDisplay .showBouncer (duration );
3334 }
3435 if (ecaView != null ) {
3536 if (duration > 0 ) {
3637 Animator anim = ObjectAnimator .ofFloat (ecaView , "alpha" , 0f );
3738 anim .setDuration (duration );
39+ anim .addListener (new AnimatorListenerAdapter () {
40+ private boolean mCanceled ;
41+ @ Override
42+ public void onAnimationCancel (Animator animation ) {
43+ // Fail safe and show the emergency button in onAnimationEnd()
44+ mCanceled = true ;
45+ ecaView .setAlpha (1f );
46+ }
47+ @ Override
48+ public void onAnimationEnd (Animator animation ) {
49+ ecaView .setVisibility (mCanceled ? View .VISIBLE : View .INVISIBLE );
50+ }
51+ });
3852 anim .start ();
3953 } else {
4054 ecaView .setAlpha (0f );
55+ ecaView .setVisibility (View .INVISIBLE );
4156 }
4257 }
4358 if (bouncerFrame != null ) {
@@ -57,6 +72,7 @@ public static void hideBouncer(SecurityMessageDisplay securityMessageDisplay,
5772 securityMessageDisplay .hideBouncer (duration );
5873 }
5974 if (ecaView != null ) {
75+ ecaView .setVisibility (View .VISIBLE );
6076 if (duration > 0 ) {
6177 Animator anim = ObjectAnimator .ofFloat (ecaView , "alpha" , 1f );
6278 anim .setDuration (duration );
0 commit comments