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

Commit 85499d92 authored by Beverly's avatar Beverly
Browse files

Animate charging text on lockscreen

Test: manual, plug usb into phone on the lockscreen and see animation
Change-Id: I5790b053bc8464f7188f61ba782927d7ca172d7b
parent 8d79feb8
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -920,15 +920,16 @@
    <integer name="wireless_charging_fade_duration">200</integer>

    <!-- 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 -->
    <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 -->
    <integer name="wired_charging_aod_text_animation_distance">-30</integer>
    <integer name="wired_charging_keyguard_text_animation_distance">-30</integer>

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

</resources>
+34 −26
Original line number Diff line number Diff line
@@ -300,34 +300,10 @@ public class KeyguardIndicationController {
                } 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);
                                    }
                                });
                        animateText(mTextView, indication);
                    } else {
                        mTextView.switchIndication(indication);
                    }

                } else {
                    String percentage = NumberFormat.getPercentInstance()
                            .format(mBatteryLevel / 100f);
@@ -355,8 +331,12 @@ public class KeyguardIndicationController {
                if (DEBUG_CHARGING_SPEED) {
                    indication += ",  " + (mChargingWattage / 1000) + " mW";
                }
                mTextView.switchIndication(indication);
                mTextView.setTextColor(mInitialTextColor);
                if (animate) {
                    animateText(mTextView, indication);
                } else {
                    mTextView.switchIndication(indication);
                }
            } else if (!TextUtils.isEmpty(trustManagedIndication)
                    && updateMonitor.getUserTrustIsManaged(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() {
        if (mPowerCharged) {
            return mContext.getResources().getString(R.string.keyguard_charged);