From 93a2bb2063fdbca9f844202f0eca12330605511b Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Mon, 2 Jun 2014 19:57:28 +0200 Subject: [PATCH] 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 --- .../phone/KeyguardPageSwipeHelper.java | 4 +-- .../phone/NotificationPanelView.java | 26 +++++++++++++++++++ .../statusbar/phone/PhoneStatusBar.java | 19 +++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) 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 25bb41a732235..086a266c443a1 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 @@ import java.util.ArrayList; 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 252f1539ba128..14c447c8bdaac 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.ViewTreeObserver; 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 @@ public class NotificationPanelView extends PanelView implements mStatusBar.onHintFinished(); } }); + startHighlightIconAnimation(right ? getRightIcon() : getLeftIcon()); boolean start = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? right : !right; if (start) { mStatusBar.onPhoneHintStarted(); @@ -869,6 +871,30 @@ public class NotificationPanelView extends PanelView implements } } + @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 bb0785cec326e..85fe99bbc5a3d 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 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, /** 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 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } }; + 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 class PhoneStatusBar extends BaseStatusBar implements DemoMode, } 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); }