diff options
3 files changed, 58 insertions, 26 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 52b93eeaea90..6f69483106e5 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -677,6 +677,8 @@ <dimen name="keyguard_clock_top_margin">36dp</dimen> <!-- The margin between top of clock and bottom of lock icon. --> <dimen name="keyguard_clock_lock_margin">16dp</dimen> + <!-- The amount to shift the clocks during a small/large transition --> + <dimen name="keyguard_clock_switch_y_shift">10dp</dimen> <item name="scrim_behind_alpha" format="float" type="dimen">0.62</item> diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java index ab7ba8a0f358..323449af0850 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java @@ -1,6 +1,8 @@ package com.android.keyguard; import android.animation.Animator; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Paint; @@ -48,6 +50,9 @@ public class KeyguardClockSwitch extends RelativeLayout { */ private static final float TO_BOLD_TRANSITION_FRACTION = 0.7f; + private static final long CLOCK_OUT_MILLIS = 150; + private static final long CLOCK_IN_MILLIS = 200; + /** * Layout transition that scales the default clock face. */ @@ -112,6 +117,7 @@ public class KeyguardClockSwitch extends RelativeLayout { private int[] mColorPalette; private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL; + private int mClockSwitchYAmount; public KeyguardClockSwitch(Context context, AttributeSet attrs) { super(context, attrs); @@ -131,6 +137,17 @@ public class KeyguardClockSwitch extends RelativeLayout { } /** + * Apply dp changes on font/scale change + */ + public void onDensityOrFontScaleChanged() { + setTextSize(TypedValue.COMPLEX_UNIT_PX, mContext.getResources() + .getDimensionPixelSize(R.dimen.widget_big_font_size)); + + mClockSwitchYAmount = mContext.getResources().getDimensionPixelSize( + R.dimen.keyguard_clock_switch_y_shift); + } + + /** * Returns if this view is presenting a custom clock, or the default implementation. */ public boolean hasCustomClock() { @@ -181,6 +198,8 @@ public class KeyguardClockSwitch extends RelativeLayout { mNewLockscreenLargeClockFrame = findViewById(R.id.new_lockscreen_clock_view_large); mSmallClockFrame = findViewById(R.id.clock_view); mKeyguardStatusArea = findViewById(R.id.keyguard_status_area); + + onDensityOrFontScaleChanged(); } void setClockPlugin(ClockPlugin plugin, int statusBarState) { @@ -296,31 +315,43 @@ public class KeyguardClockSwitch extends RelativeLayout { mClockViewBold.setFormat24Hour(format); } - private void updateClockLayout(boolean useLargeClock) { + private void animateClockChange(boolean useLargeClock) { if (mLockScreenMode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) return; - Fade fadeIn = new Fade(); - fadeIn.setDuration(KeyguardSliceView.DEFAULT_ANIM_DURATION); - fadeIn.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); - - Fade fadeOut = new Fade(); - fadeOut.setDuration(KeyguardSliceView.DEFAULT_ANIM_DURATION / 2); - fadeOut.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN); - + View in, out; + int direction = 1; if (useLargeClock) { - TransitionManager.beginDelayedTransition(mNewLockscreenClockFrame, fadeOut); - TransitionManager.beginDelayedTransition(mNewLockscreenLargeClockFrame, fadeIn); - - mNewLockscreenClockFrame.setVisibility(View.INVISIBLE); - addView(mNewLockscreenLargeClockFrame); - mNewLockscreenLargeClockFrame.setVisibility(View.VISIBLE); + out = mNewLockscreenClockFrame; + in = mNewLockscreenLargeClockFrame; + addView(in); + direction = -1; } else { - TransitionManager.beginDelayedTransition(mNewLockscreenClockFrame, fadeIn); - TransitionManager.beginDelayedTransition(mNewLockscreenLargeClockFrame, fadeOut); - - removeView(mNewLockscreenLargeClockFrame); - mNewLockscreenClockFrame.setVisibility(View.VISIBLE); - } + in = mNewLockscreenClockFrame; + out = mNewLockscreenLargeClockFrame; + + // Must remove in order for notifications to appear in the proper place + removeView(out); + } + + AnimatorSet outAnim = new AnimatorSet(); + outAnim.setDuration(CLOCK_OUT_MILLIS); + outAnim.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN); + outAnim.playTogether( + ObjectAnimator.ofFloat(out, View.ALPHA, 0f), + ObjectAnimator.ofFloat(out, View.TRANSLATION_Y, 0, + direction * -mClockSwitchYAmount)); + + in.setAlpha(0); + in.setVisibility(View.VISIBLE); + AnimatorSet inAnim = new AnimatorSet(); + inAnim.setDuration(CLOCK_IN_MILLIS); + inAnim.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); + inAnim.playTogether(ObjectAnimator.ofFloat(in, View.ALPHA, 1f), + ObjectAnimator.ofFloat(in, View.TRANSLATION_Y, direction * mClockSwitchYAmount, 0)); + inAnim.setStartDelay(CLOCK_OUT_MILLIS / 2); + + inAnim.start(); + outAnim.start(); } /** @@ -343,7 +374,8 @@ public class KeyguardClockSwitch extends RelativeLayout { if (hasVisibleNotifications == mHasVisibleNotifications) { return; } - updateClockLayout(!hasVisibleNotifications); + + animateClockChange(!hasVisibleNotifications); mHasVisibleNotifications = hasVisibleNotifications; if (mDarkAmount == 0f && mBigClockContainer != null) { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index 4d6e8a90e57b..e0de180e657c 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -21,7 +21,6 @@ import android.content.ContentResolver; import android.content.res.Resources; import android.provider.Settings; import android.text.format.DateFormat; -import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; @@ -146,11 +145,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } /** - * Updates clock's text + * Apply dp changes on font/scale change */ public void onDensityOrFontScaleChanged() { - mView.setTextSize(TypedValue.COMPLEX_UNIT_PX, - mResources.getDimensionPixelSize(R.dimen.widget_big_font_size)); + mView.onDensityOrFontScaleChanged(); } /** |