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

Commit 8c785898 authored by Beverly's avatar Beverly
Browse files

Wired charging animation on aod

Test: manual
Bug: 67598445
Change-Id: I320a05e4e5aafa0b011fe9543691ebc068fe362b
parent c13b5436
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -902,4 +902,11 @@
    <dimen name="config_batteryLevelTextSizeEnd" format="float">32.0</dimen>
    <dimen name="config_batteryLevelTextSizeEnd" format="float">32.0</dimen>
    <!-- Wireless Charging battery level text animation duration -->
    <!-- Wireless Charging battery level text animation duration -->
    <integer name="config_batteryLevelTextAnimationDuration">400</integer>
    <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>
</resources>
+2 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui;


import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.BounceInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
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 ICON_OVERSHOT = new PathInterpolator(0.4f, 0f, 0.2f, 1.4f);
    public static final Interpolator PANEL_CLOSE_ACCELERATED
    public static final Interpolator PANEL_CLOSE_ACCELERATED
            = new PathInterpolator(0.3f, 0, 0.5f, 1);
            = 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.
     * Interpolator to be used when animating a move based on a click. Pair with enough duration.
+42 −10
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.systemui.statusbar;
package com.android.systemui.statusbar;


import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.admin.DevicePolicyManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
@@ -44,6 +46,7 @@ import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.settingslib.Utils;
import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
import com.android.systemui.statusbar.phone.LockIcon;
import com.android.systemui.statusbar.phone.LockIcon;
@@ -192,7 +195,7 @@ public class KeyguardIndicationController {
            if  (!mHandler.hasMessages(MSG_HIDE_TRANSIENT)) {
            if  (!mHandler.hasMessages(MSG_HIDE_TRANSIENT)) {
                hideTransientIndication();
                hideTransientIndication();
            }
            }
            updateIndication();
            updateIndication(false);
        } else if (!visible) {
        } else if (!visible) {
            // If we unlock and return to keyguard quickly, previous error should not be shown
            // If we unlock and return to keyguard quickly, previous error should not be shown
            hideTransientIndication();
            hideTransientIndication();
@@ -204,7 +207,7 @@ public class KeyguardIndicationController {
     */
     */
    public void setRestingIndication(String restingIndication) {
    public void setRestingIndication(String restingIndication) {
        mRestingIndication = restingIndication;
        mRestingIndication = restingIndication;
        updateIndication();
        updateIndication(false);
    }
    }


    /**
    /**
@@ -265,7 +268,8 @@ public class KeyguardIndicationController {
            mWakeLock.setAcquired(true);
            mWakeLock.setAcquired(true);
            hideTransientIndicationDelayed(BaseKeyguardCallback.HIDE_DELAY_MS);
            hideTransientIndicationDelayed(BaseKeyguardCallback.HIDE_DELAY_MS);
        }
        }
        updateIndication();

        updateIndication(false);
    }
    }


    /**
    /**
@@ -275,11 +279,11 @@ public class KeyguardIndicationController {
        if (mTransientIndication != null) {
        if (mTransientIndication != null) {
            mTransientIndication = null;
            mTransientIndication = null;
            mHandler.removeMessages(MSG_HIDE_TRANSIENT);
            mHandler.removeMessages(MSG_HIDE_TRANSIENT);
            updateIndication();
            updateIndication(false);
        }
        }
    }
    }


    protected final void updateIndication() {
    protected final void updateIndication(boolean animate) {
        if (TextUtils.isEmpty(mTransientIndication)) {
        if (TextUtils.isEmpty(mTransientIndication)) {
            mWakeLock.setAcquired(false);
            mWakeLock.setAcquired(false);
        }
        }
@@ -295,7 +299,35 @@ public class KeyguardIndicationController {
                    mTextView.switchIndication(mTransientIndication);
                    mTextView.switchIndication(mTransientIndication);
                } else if (mPowerPluggedIn) {
                } else if (mPowerPluggedIn) {
                    String indication = computePowerIndication();
                    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);
                        mTextView.switchIndication(indication);
                    }

                } else {
                } else {
                    String percentage = NumberFormat.getPercentInstance()
                    String percentage = NumberFormat.getPercentInstance()
                            .format(mBatteryLevel / 100f);
                            .format(mBatteryLevel / 100f);
@@ -390,7 +422,7 @@ public class KeyguardIndicationController {
        public void onReceive(Context context, Intent intent) {
        public void onReceive(Context context, Intent intent) {
            mHandler.post(() -> {
            mHandler.post(() -> {
                if (mVisible) {
                if (mVisible) {
                    updateIndication();
                    updateIndication(false);
                }
                }
            });
            });
        }
        }
@@ -412,7 +444,7 @@ public class KeyguardIndicationController {
            return;
            return;
        }
        }
        mDozing = dozing;
        mDozing = dozing;
        updateIndication();
        updateIndication(false);
        updateDisclosure();
        updateDisclosure();
    }
    }


@@ -445,7 +477,7 @@ public class KeyguardIndicationController {
            mChargingWattage = status.maxChargingWattage;
            mChargingWattage = status.maxChargingWattage;
            mChargingSpeed = status.getChargingSpeed(mSlowThreshold, mFastThreshold);
            mChargingSpeed = status.getChargingSpeed(mSlowThreshold, mFastThreshold);
            mBatteryLevel = status.level;
            mBatteryLevel = status.level;
            updateIndication();
            updateIndication(!wasPluggedIn && mPowerPluggedIn);
            if (mDozing) {
            if (mDozing) {
                if (!wasPluggedIn && mPowerPluggedIn) {
                if (!wasPluggedIn && mPowerPluggedIn) {
                    showTransientIndication(computePowerIndication());
                    showTransientIndication(computePowerIndication());
@@ -551,7 +583,7 @@ public class KeyguardIndicationController {
        @Override
        @Override
        public void onUserUnlocked() {
        public void onUserUnlocked() {
            if (mVisible) {
            if (mVisible) {
                updateIndication();
                updateIndication(false);
            }
            }
        }
        }
    };
    };