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

Commit 07ed3df9 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Move battery icon back to bottom of the screen

This partially reverts ag/5073038

Fixes: 129324135
Test: visual
Change-Id: Ie0f9b19e7f6bac9596356e87913a6cc19fb3dafe
parent 93f714da
Loading
Loading
Loading
Loading
+14 −18
Original line number Diff line number Diff line
@@ -308,11 +308,23 @@ public class KeyguardIndicationController implements StateListener {
            // Walk down a precedence-ordered list of what indication
            // should be shown based on user or device state
            if (mDozing) {
                if (!TextUtils.isEmpty(mTransientIndication)) {
                // When dozing we ignore any text color and use white instead, because
                // colors can be hard to read in low brightness.
                mTextView.setTextColor(Color.WHITE);
                if (!TextUtils.isEmpty(mTransientIndication)) {
                    mTextView.switchIndication(mTransientIndication);
                } else if (mPowerPluggedIn) {
                    String indication = computePowerIndication();
                    if (animate) {
                        animateText(mTextView, indication);
                    } else {
                        mTextView.switchIndication(indication);
                    }
                } else {
                    String percentage = NumberFormat.getPercentInstance()
                            .format(mBatteryLevel / 100f);
                    mTextView.switchIndication(percentage);
                }
                updateAlphas();
                return;
            }

@@ -353,14 +365,6 @@ public class KeyguardIndicationController implements StateListener {
        }
    }

    private void updateAlphas() {
        if (!TextUtils.isEmpty(mTransientIndication)) {
            mTextView.setAlpha(1f);
        } else {
            mTextView.setAlpha(1f - mDarkAmount);
        }
    }

    // animates textView - textView moves up and bounces down
    private void animateText(KeyguardIndicationTextView textView, String indication) {
        int yTranslation = mContext.getResources().getInteger(
@@ -523,14 +527,6 @@ public class KeyguardIndicationController implements StateListener {
        pw.println("  computePowerIndication(): " + computePowerIndication());
    }

    public void setDarkAmount(float darkAmount) {
        if (mDarkAmount == darkAmount) {
            return;
        }
        mDarkAmount = darkAmount;
        updateAlphas();
    }

    @Override
    public void onStateChanged(int newState) {
        // don't care
+22 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone;
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;
import static android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;

import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset;
import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_BUTTON;
import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_LEFT_UNLOCK;
import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_RIGHT_BUTTON;
@@ -172,6 +173,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
    private boolean mDozing;
    private int mIndicationBottomMargin;
    private float mDarkAmount;
    private int mBurnInXOffset;
    private int mBurnInYOffset;
    private ActivityIntentHelper mActivityIntentHelper;

    public KeyguardBottomAreaView(Context context) {
@@ -252,6 +255,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        mIndicationText = findViewById(R.id.keyguard_indication_text);
        mIndicationBottomMargin = getResources().getDimensionPixelSize(
                R.dimen.keyguard_indication_margin_bottom);
        mBurnInYOffset = getResources().getDimensionPixelSize(
                R.dimen.default_burn_in_prevention_offset);
        updateCameraVisibility();
        mUnlockMethodCache = UnlockMethodCache.getInstance(getContext());
        mUnlockMethodCache.addListener(this);
@@ -321,6 +326,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        super.onConfigurationChanged(newConfig);
        mIndicationBottomMargin = getResources().getDimensionPixelSize(
                R.dimen.keyguard_indication_margin_bottom);
        mBurnInYOffset = getResources().getDimensionPixelSize(
                R.dimen.default_burn_in_prevention_offset);
        MarginLayoutParams mlp = (MarginLayoutParams) mIndicationArea.getLayoutParams();
        if (mlp.bottomMargin != mIndicationBottomMargin) {
            mlp.bottomMargin = mIndicationBottomMargin;
@@ -564,8 +571,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
            return;
        }
        mDarkAmount = darkAmount;
        mIndicationController.setDarkAmount(darkAmount);
        mLockIcon.setDarkAmount(darkAmount);
        dozeTimeTick();
    }

    /**
@@ -841,6 +848,20 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
        }
    }

    public void dozeTimeTick() {
        int burnInYOffset = getBurnInOffset(mBurnInYOffset * 2, false /* xAxis */)
                - mBurnInYOffset;
        mIndicationArea.setTranslationY(burnInYOffset * mDarkAmount);
    }

    public void setAntiBurnInOffsetX(int burnInXOffset) {
        if (mBurnInXOffset == burnInXOffset) {
            return;
        }
        mBurnInXOffset = burnInXOffset;
        mIndicationArea.setTranslationX(burnInXOffset);
    }

    /**
     * Sets the alpha of the indication areas and affordances, excluding the lock icon.
     */
+2 −63
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.phone;

import static com.android.systemui.ScreenDecorations.DisplayCutoutView.boundsFromDirection;
import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset;

import android.annotation.ColorInt;
import android.content.Context;
@@ -102,19 +101,6 @@ public class KeyguardStatusBarView extends RelativeLayout
     */
    private int mCutoutSideNudge = 0;

    /**
     * How much to move icons to avoid burn in.
     */
    private int mBurnInOffset;
    private int mCurrentBurnInOffsetX;
    private int mCurrentBurnInOffsetY;

    /**
     * Ratio representing being in ambient mode or not.
     */
    private float mDarkAmount;
    private boolean mDozing;

    public KeyguardStatusBarView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
@@ -186,8 +172,6 @@ public class KeyguardStatusBarView extends RelativeLayout
                R.dimen.system_icons_super_container_avatarless_margin_end);
        mCutoutSideNudge = getResources().getDimensionPixelSize(
                R.dimen.display_cutout_margin_consumption);
        mBurnInOffset = getResources().getDimensionPixelSize(
                R.dimen.default_burn_in_prevention_offset);
        mShowPercentAvailable = getContext().getResources().getBoolean(
                com.android.internal.R.bool.config_battery_percentage_setting_available);
    }
@@ -211,7 +195,7 @@ public class KeyguardStatusBarView extends RelativeLayout
                mMultiUserSwitch.setVisibility(View.GONE);
            }
        }
        mBatteryView.setForceShowPercent(mBatteryCharging && mShowPercentAvailable || mDozing);
        mBatteryView.setForceShowPercent(mBatteryCharging && mShowPercentAvailable);
    }

    private void updateSystemIconsLayoutParams() {
@@ -348,7 +332,6 @@ public class KeyguardStatusBarView extends RelativeLayout
        mIconManager = new TintedIconManager(findViewById(R.id.statusIcons));
        Dependency.get(StatusBarIconController.class).addIconGroup(mIconManager);
        onThemeChanged();
        updateDarkState();
    }

    @Override
@@ -492,7 +475,7 @@ public class KeyguardStatusBarView extends RelativeLayout
            mIconManager.setTint(iconColor);
        }

        applyDarkness(R.id.battery, mEmptyRect, intensity * (1f - mDarkAmount), iconColor);
        applyDarkness(R.id.battery, mEmptyRect, intensity, iconColor);
        applyDarkness(R.id.clock, mEmptyRect, intensity, iconColor);
    }

@@ -513,48 +496,4 @@ public class KeyguardStatusBarView extends RelativeLayout
            mBatteryView.dump(fd, pw, args);
        }
    }

    public void setDozing(boolean dozing) {
        if (mDozing == dozing) {
            return;
        }
        mDozing = dozing;
        setClipChildren(!dozing);
        setClipToPadding(!dozing);
        updateVisibilities();
    }

    public void setDarkAmount(float darkAmount) {
        mDarkAmount = darkAmount;
        if (darkAmount == 0) {
            dozeTimeTick();
        }
        updateDarkState();
    }

    public void dozeTimeTick() {
        mCurrentBurnInOffsetX = getBurnInOffset(mBurnInOffset, true /* xAxis */);
        mCurrentBurnInOffsetY = getBurnInOffset(mBurnInOffset, false /* xAxis */);
        updateDarkState();
    }

    private void updateDarkState() {
        float alpha = 1f - mDarkAmount;
        int visibility = alpha != 0f ? VISIBLE : INVISIBLE;
        mCarrierLabel.setAlpha(alpha * alpha);
        mStatusIconContainer.setAlpha(alpha);
        mStatusIconContainer.setVisibility(visibility);

        float iconsX = -mCurrentBurnInOffsetX;
        if (mMultiUserSwitch.getVisibility() == VISIBLE) {
            // Squared alpha to add a nice easing curve and avoid overlap during animation.
            mMultiUserAvatar.setAlpha(alpha * alpha);
            iconsX += mMultiUserAvatar.getPaddingLeft() + mMultiUserAvatar.getWidth()
                    + mMultiUserAvatar.getPaddingRight();
        }
        mSystemIconsContainer.setTranslationX(iconsX * mDarkAmount);
        mSystemIconsContainer.setTranslationY(mCurrentBurnInOffsetY * mDarkAmount);
        updateIconsAndTextColors();
    }

}
+7 −8
Original line number Diff line number Diff line
@@ -635,6 +635,7 @@ public class NotificationPanelView extends PanelView implements
        }
        mNotificationStackScroller.setIntrinsicPadding(stackScrollerPadding);
        mNotificationStackScroller.setAntiBurnInOffsetX(mClockPositionResult.clockX);
        mKeyguardBottomArea.setAntiBurnInOffsetX(mClockPositionResult.clockX);

        mStackScrollerMeasuringPass++;
        requestScrollerTopPaddingUpdate(animate);
@@ -1886,7 +1887,7 @@ public class NotificationPanelView extends PanelView implements
        float newAlpha = Math.min(getKeyguardContentsAlpha(), alphaQsExpansion)
                * mKeyguardStatusBarAnimateAlpha;
        mKeyguardStatusBar.setAlpha(newAlpha);
        mKeyguardStatusBar.setVisibility(newAlpha != 0f ? VISIBLE : INVISIBLE);
        mKeyguardStatusBar.setVisibility(newAlpha != 0f && !mDozing ? VISIBLE : INVISIBLE);
    }

    private void updateKeyguardBottomAreaAlpha() {
@@ -2373,12 +2374,11 @@ public class NotificationPanelView extends PanelView implements
        positionClockAndNotifications();
    }

    private static float interpolate(float t, float start, float end) {
        return (1 - t) * start + t * end;
    }

    private void updateDozingVisibilities(boolean animate) {
        mKeyguardBottomArea.setDozing(mDozing, animate);
        if (!mDozing && animate) {
            animateKeyguardStatusBarIn(StackStateAnimator.ANIMATION_DURATION_STANDARD);
        }
    }

    @Override
@@ -2814,7 +2814,7 @@ public class NotificationPanelView extends PanelView implements
        if (mDozing) {
            mNotificationStackScroller.setShowDarkShelf(!hasCustomClock());
        }
        mKeyguardStatusBar.setDozing(mDozing);
        mKeyguardBottomArea.setDozing(mDozing, animate);

        if (mBarState == StatusBarState.KEYGUARD
                || mBarState == StatusBarState.SHADE_LOCKED) {
@@ -2829,7 +2829,6 @@ public class NotificationPanelView extends PanelView implements
    public void onDozeAmountChanged(float linearAmount, float amount) {
        mInterpolatedDarkAmount = amount;
        mLinearDarkAmount = linearAmount;
        mKeyguardStatusBar.setDarkAmount(mInterpolatedDarkAmount);
        mKeyguardStatusView.setDarkAmount(mInterpolatedDarkAmount);
        mKeyguardBottomArea.setDarkAmount(mInterpolatedDarkAmount);
        positionClockAndNotifications();
@@ -2861,7 +2860,7 @@ public class NotificationPanelView extends PanelView implements
    }

    public void dozeTimeTick() {
        mKeyguardStatusBar.dozeTimeTick();
        mKeyguardBottomArea.dozeTimeTick();
        mKeyguardStatusView.dozeTimeTick();
        if (mInterpolatedDarkAmount > 0) {
            positionClockAndNotifications();
+3 −0
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
    @Mock
    private KeyguardStatusView mKeyguardStatusView;
    @Mock
    private KeyguardBottomAreaView mKeyguardBottomArea;
    @Mock
    private KeyguardStatusBarView mKeyguardStatusBar;
    private NotificationPanelView mNotificationPanelView;

@@ -113,6 +115,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
            mNotificationStackScroller = mNotificationStackScrollLayout;
            mKeyguardStatusView = NotificationPanelViewTest.this.mKeyguardStatusView;
            mKeyguardStatusBar = NotificationPanelViewTest.this.mKeyguardStatusBar;
            mKeyguardBottomArea = NotificationPanelViewTest.this.mKeyguardBottomArea;
        }
    }
}