Improve hint animations.

Show the hint text longer so that users have enough time to read it,
also "highlight" the corresponding icon by making it fully opaque
during the gesture.

Bug: 15189049
Change-Id: Ie0429752b63bae41bb6992778ebb3bd5678f9676
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPageSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPageSwipeHelper.java
index 25bb41a..086a266 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPageSwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardPageSwipeHelper.java
@@ -40,8 +40,8 @@
 public class KeyguardPageSwipeHelper {
 
     private static final float SWIPE_MAX_ICON_SCALE_AMOUNT = 2.0f;
-    private static final float SWIPE_RESTING_ALPHA_AMOUNT = 0.7f;
-    private static final long HINT_PHASE1_DURATION = 250;
+    public static final float SWIPE_RESTING_ALPHA_AMOUNT = 0.5f;
+    public static final long HINT_PHASE1_DURATION = 250;
     private static final long HINT_PHASE2_DURATION = 450;
 
     private final Context mContext;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 252f153..14c447c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -32,6 +32,7 @@
 import android.view.accessibility.AccessibilityEvent;
 import android.view.animation.AnimationUtils;
 import android.view.animation.Interpolator;
+import android.view.animation.LinearInterpolator;
 import android.widget.LinearLayout;
 
 import com.android.systemui.R;
@@ -861,6 +862,7 @@
                 mStatusBar.onHintFinished();
             }
         });
+        startHighlightIconAnimation(right ? getRightIcon() : getLeftIcon());
         boolean start = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? right : !right;
         if (start) {
             mStatusBar.onPhoneHintStarted();
@@ -870,6 +872,30 @@
     }
 
     @Override
+    protected void startUnlockHintAnimation() {
+        super.startUnlockHintAnimation();
+        startHighlightIconAnimation(getCenterIcon());
+    }
+
+    /**
+     * Starts the highlight (making it fully opaque) animation on an icon.
+     */
+    private void startHighlightIconAnimation(final View icon) {
+        icon.animate()
+                .alpha(1.0f)
+                .setDuration(KeyguardPageSwipeHelper.HINT_PHASE1_DURATION)
+                .setInterpolator(mFastOutSlowInInterpolator)
+                .withEndAction(new Runnable() {
+                    @Override
+                    public void run() {
+                        icon.animate().alpha(KeyguardPageSwipeHelper.SWIPE_RESTING_ALPHA_AMOUNT)
+                                .setDuration(KeyguardPageSwipeHelper.HINT_PHASE1_DURATION)
+                                .setInterpolator(mFastOutSlowInInterpolator);
+                    }
+                });
+    }
+
+    @Override
     public float getPageWidth() {
         return getWidth();
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index bb0785c..85fe99b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -174,6 +174,11 @@
     /** The minimum delay in ms between reports of notification visibility. */
     private static final int VISIBILITY_REPORT_MIN_DELAY_MS = 500;
 
+    /**
+     * The delay to reset the hint text when the hint animation is finished running.
+     */
+    private static final int HINT_RESET_DELAY_MS = 1200;
+
     // fling gesture tuning parameters, scaled to display density
     private float mSelfExpandVelocityPx; // classic value: 2000px/s
     private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up")
@@ -491,6 +496,13 @@
         }
     };
 
+    private final Runnable mResetIndicationRunnable = new Runnable() {
+        @Override
+        public void run() {
+            mKeyguardIndicationTextView.switchIndication(mKeyguardHotwordPhrase);
+        }
+    };
+
     @Override
     public void setZenMode(int mode) {
         super.setZenMode(mode);
@@ -2960,18 +2972,23 @@
     }
 
     public void onUnlockHintStarted() {
+        mStatusBarView.removeCallbacks(mResetIndicationRunnable);
         mKeyguardIndicationTextView.switchIndication(R.string.keyguard_unlock);
     }
 
     public void onHintFinished() {
-        mKeyguardIndicationTextView.switchIndication(mKeyguardHotwordPhrase);
+
+        // Delay the reset a bit so the user can read the text.
+        mStatusBarView.postDelayed(mResetIndicationRunnable, HINT_RESET_DELAY_MS);
     }
 
     public void onCameraHintStarted() {
+        mStatusBarView.removeCallbacks(mResetIndicationRunnable);
         mKeyguardIndicationTextView.switchIndication(R.string.camera_hint);
     }
 
     public void onPhoneHintStarted() {
+        mStatusBarView.removeCallbacks(mResetIndicationRunnable);
         mKeyguardIndicationTextView.switchIndication(R.string.phone_hint);
     }