Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64b7ccee authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Wired charging animation on aod"

parents 863ad0ee 8c785898
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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>
+2 −0
Original line number Diff line number Diff line
@@ -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.
+42 −10
Original line number Diff line number Diff line
@@ -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();
                    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);
            }
        }
    };