diff options
3 files changed, 51 insertions, 10 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 3db79d7556d5..16069041bf85 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -902,4 +902,11 @@ <dimen name="config_batteryLevelTextSizeEnd" format="float">32.0</dimen> <!-- Wireless Charging battery level text animation duration --> <integer name="config_batteryLevelTextAnimationDuration">400</integer> + + <!-- Wired charging on AOD, text animation duration --> + <integer name="wired_charging_aod_text_animation_duration_down">500</integer> + <!-- Wired charging on AOD, text animation duration --> + <integer name="wired_charging_aod_text_animation_duration_up">300</integer> + <!-- Wired charging on AOD, text animation distance --> + <integer name="wired_charging_aod_text_animation_distance">-30</integer> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/Interpolators.java b/packages/SystemUI/src/com/android/systemui/Interpolators.java index b8cfa3e48c20..aeef49689517 100644 --- a/packages/SystemUI/src/com/android/systemui/Interpolators.java +++ b/packages/SystemUI/src/com/android/systemui/Interpolators.java @@ -18,6 +18,7 @@ package com.android.systemui; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AccelerateInterpolator; +import android.view.animation.BounceInterpolator; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.view.animation.LinearInterpolator; @@ -43,6 +44,7 @@ public class Interpolators { public static final Interpolator ICON_OVERSHOT = new PathInterpolator(0.4f, 0f, 0.2f, 1.4f); public static final Interpolator PANEL_CLOSE_ACCELERATED = new PathInterpolator(0.3f, 0, 0.5f, 1); + public static final Interpolator BOUNCE = new BounceInterpolator(); /** * Interpolator to be used when animating a move based on a click. Pair with enough duration. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 0a12be4eac7f..b7a15005b170 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -16,6 +16,8 @@ package com.android.systemui.statusbar; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.app.admin.DevicePolicyManager; import android.content.BroadcastReceiver; import android.content.Context; @@ -44,6 +46,7 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.settingslib.Utils; import com.android.systemui.Dependency; +import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.statusbar.phone.KeyguardIndicationTextView; import com.android.systemui.statusbar.phone.LockIcon; @@ -192,7 +195,7 @@ public class KeyguardIndicationController { if (!mHandler.hasMessages(MSG_HIDE_TRANSIENT)) { hideTransientIndication(); } - updateIndication(); + updateIndication(false); } else if (!visible) { // If we unlock and return to keyguard quickly, previous error should not be shown hideTransientIndication(); @@ -204,7 +207,7 @@ public class KeyguardIndicationController { */ public void setRestingIndication(String restingIndication) { mRestingIndication = restingIndication; - updateIndication(); + updateIndication(false); } /** @@ -265,7 +268,8 @@ public class KeyguardIndicationController { mWakeLock.setAcquired(true); hideTransientIndicationDelayed(BaseKeyguardCallback.HIDE_DELAY_MS); } - updateIndication(); + + updateIndication(false); } /** @@ -275,11 +279,11 @@ public class KeyguardIndicationController { if (mTransientIndication != null) { mTransientIndication = null; mHandler.removeMessages(MSG_HIDE_TRANSIENT); - updateIndication(); + updateIndication(false); } } - protected final void updateIndication() { + protected final void updateIndication(boolean animate) { if (TextUtils.isEmpty(mTransientIndication)) { mWakeLock.setAcquired(false); } @@ -295,7 +299,35 @@ public class KeyguardIndicationController { mTextView.switchIndication(mTransientIndication); } else if (mPowerPluggedIn) { String indication = computePowerIndication(); - mTextView.switchIndication(indication); + if (animate) { + int yTranslation = mContext.getResources().getInteger( + R.integer.wired_charging_aod_text_animation_distance); + int animateUpDuration = mContext.getResources().getInteger( + R.integer.wired_charging_aod_text_animation_duration_up); + int animateDownDuration = mContext.getResources().getInteger( + R.integer.wired_charging_aod_text_animation_duration_down); + mTextView.animate() + .translationYBy(yTranslation) + .setInterpolator(Interpolators.LINEAR) + .setDuration(animateUpDuration) + .setListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + mTextView.switchIndication(indication); + } + @Override + public void onAnimationEnd(Animator animation) { + mTextView.animate() + .setDuration(animateDownDuration) + .setInterpolator(Interpolators.BOUNCE) + .translationYBy(-1 * yTranslation) + .setListener(null); + } + }); + } else { + mTextView.switchIndication(indication); + } + } else { String percentage = NumberFormat.getPercentInstance() .format(mBatteryLevel / 100f); @@ -390,7 +422,7 @@ public class KeyguardIndicationController { public void onReceive(Context context, Intent intent) { mHandler.post(() -> { if (mVisible) { - updateIndication(); + updateIndication(false); } }); } @@ -412,7 +444,7 @@ public class KeyguardIndicationController { return; } mDozing = dozing; - updateIndication(); + updateIndication(false); updateDisclosure(); } @@ -445,7 +477,7 @@ public class KeyguardIndicationController { mChargingWattage = status.maxChargingWattage; mChargingSpeed = status.getChargingSpeed(mSlowThreshold, mFastThreshold); mBatteryLevel = status.level; - updateIndication(); + updateIndication(!wasPluggedIn && mPowerPluggedIn); if (mDozing) { if (!wasPluggedIn && mPowerPluggedIn) { showTransientIndication(computePowerIndication()); @@ -551,7 +583,7 @@ public class KeyguardIndicationController { @Override public void onUserUnlocked() { if (mVisible) { - updateIndication(); + updateIndication(false); } } }; |