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

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

Merge "Animate charging text on lockscreen"

parents a8601413 85499d92
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -924,15 +924,16 @@
    <integer name="wireless_charging_fade_duration">200</integer>
    <integer name="wireless_charging_fade_duration">200</integer>


    <!-- Wired charging on AOD, text animation duration -->
    <!-- Wired charging on AOD, text animation duration -->
    <integer name="wired_charging_aod_text_animation_duration_down">500</integer>
    <integer name="wired_charging_keyguard_text_animation_duration_down">500</integer>
    <!-- Wired charging on AOD, text animation duration -->
    <!-- Wired charging on AOD, text animation duration -->
    <integer name="wired_charging_aod_text_animation_duration_up">300</integer>
    <integer name="wired_charging_keyguard_text_animation_duration_up">300</integer>
    <!-- Wired charging on AOD, text animation distance -->
    <!-- Wired charging on AOD, text animation distance -->
    <integer name="wired_charging_aod_text_animation_distance">-30</integer>
    <integer name="wired_charging_keyguard_text_animation_distance">-30</integer>


    <!-- Logout button -->
    <!-- Logout button -->
    <dimen name="logout_button_layout_height">32dp</dimen>
    <dimen name="logout_button_layout_height">32dp</dimen>
    <dimen name="logout_button_padding_horizontal">16dp</dimen>
    <dimen name="logout_button_padding_horizontal">16dp</dimen>
    <dimen name="logout_button_margin_bottom">12dp</dimen>
    <dimen name="logout_button_margin_bottom">12dp</dimen>
    <dimen name="logout_button_corner_radius">2dp</dimen>
    <dimen name="logout_button_corner_radius">2dp</dimen>

</resources>
</resources>
+34 −26
Original line number Original line Diff line number Diff line
@@ -300,34 +300,10 @@ public class KeyguardIndicationController {
                } else if (mPowerPluggedIn) {
                } else if (mPowerPluggedIn) {
                    String indication = computePowerIndication();
                    String indication = computePowerIndication();
                    if (animate) {
                    if (animate) {
                        int yTranslation = mContext.getResources().getInteger(
                        animateText(mTextView, indication);
                                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 {
                    } else {
                        mTextView.switchIndication(indication);
                        mTextView.switchIndication(indication);
                    }
                    }

                } else {
                } else {
                    String percentage = NumberFormat.getPercentInstance()
                    String percentage = NumberFormat.getPercentInstance()
                            .format(mBatteryLevel / 100f);
                            .format(mBatteryLevel / 100f);
@@ -355,8 +331,12 @@ public class KeyguardIndicationController {
                if (DEBUG_CHARGING_SPEED) {
                if (DEBUG_CHARGING_SPEED) {
                    indication += ",  " + (mChargingWattage / 1000) + " mW";
                    indication += ",  " + (mChargingWattage / 1000) + " mW";
                }
                }
                mTextView.switchIndication(indication);
                mTextView.setTextColor(mInitialTextColor);
                mTextView.setTextColor(mInitialTextColor);
                if (animate) {
                    animateText(mTextView, indication);
                } else {
                    mTextView.switchIndication(indication);
                }
            } else if (!TextUtils.isEmpty(trustManagedIndication)
            } else if (!TextUtils.isEmpty(trustManagedIndication)
                    && updateMonitor.getUserTrustIsManaged(userId)
                    && updateMonitor.getUserTrustIsManaged(userId)
                    && !updateMonitor.getUserHasTrust(userId)) {
                    && !updateMonitor.getUserHasTrust(userId)) {
@@ -369,6 +349,34 @@ public class KeyguardIndicationController {
        }
        }
    }
    }


    // animates textView - textView moves up and bounces down
    private void animateText(KeyguardIndicationTextView textView, String indication) {
        int yTranslation = mContext.getResources().getInteger(
                R.integer.wired_charging_keyguard_text_animation_distance);
        int animateUpDuration = mContext.getResources().getInteger(
                R.integer.wired_charging_keyguard_text_animation_duration_up);
        int animateDownDuration = mContext.getResources().getInteger(
                R.integer.wired_charging_keyguard_text_animation_duration_down);
        textView.animate()
                .translationYBy(yTranslation)
                .setInterpolator(Interpolators.LINEAR)
                .setDuration(animateUpDuration)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                        textView.switchIndication(indication);
                    }
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        textView.animate()
                                .setDuration(animateDownDuration)
                                .setInterpolator(Interpolators.BOUNCE)
                                .translationYBy(-1 * yTranslation)
                                .setListener(null);
                    }
                });
    }

    private String computePowerIndication() {
    private String computePowerIndication() {
        if (mPowerCharged) {
        if (mPowerCharged) {
            return mContext.getResources().getString(R.string.keyguard_charged);
            return mContext.getResources().getString(R.string.keyguard_charged);