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

Commit b8b70b0a authored by Michał Brzeziński's avatar Michał Brzeziński Committed by Android (Google) Code Review
Browse files

Merge "Properly fixing expansion state in lockscreen to shade transition" into tm-qpr-dev

parents 38f58fb7 397a969c
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -309,9 +309,12 @@ public class KeyguardClockPositionAlgorithm {
     */
    private float getClockAlpha(int y) {
        float alphaKeyguard = Math.max(0, y / Math.max(1f, getClockY(1f, mDarkAmount)));
        if (!mIsSplitShade) {
            // in split shade QS are always expanded so this factor shouldn't apply
            float qsAlphaFactor = MathUtils.saturate(mQsExpansion / 0.3f);
            qsAlphaFactor = 1f - qsAlphaFactor;
            alphaKeyguard *= qsAlphaFactor;
        }
        alphaKeyguard = Interpolators.ACCELERATE.getInterpolation(alphaKeyguard);
        return MathUtils.lerp(alphaKeyguard, 1f, mDarkAmount);
    }
+19 −8
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_N
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.StatusBarState.SHADE_LOCKED;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL;
import static com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_FOLD_TO_AOD;
import static com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManagerKt.STATE_CLOSED;
@@ -2703,8 +2704,8 @@ public class NotificationPanelViewController extends PanelViewController {
    }

    private float calculateNotificationsTopPadding() {
        if (mSplitShadeEnabled && !mKeyguardShowing) {
            return 0;
        if (mSplitShadeEnabled) {
            return mKeyguardShowing ? getKeyguardNotificationStaticPadding() : 0;
        }
        if (mKeyguardShowing && (mQsExpandImmediate
                || mIsExpanding && mQsExpandedWhenExpandingStarted)) {
@@ -2778,6 +2779,9 @@ public class NotificationPanelViewController extends PanelViewController {
            mIsQsTranslationResetAnimator = mQsTranslationForFullShadeTransition > 0.0f;
        }

        if (mSplitShadeEnabled) {
            updateQsExpansionForLockscreenToShadeTransition(pxAmount);
        }
        float endPosition = 0;
        if (pxAmount > 0.0f) {
            if (mNotificationStackScrollLayoutController.getVisibleNotificationCount() == 0
@@ -2817,6 +2821,18 @@ public class NotificationPanelViewController extends PanelViewController {
        updateQsExpansion();
    }

    private void updateQsExpansionForLockscreenToShadeTransition(float pxAmount) {
        float qsExpansion = 0;
        if (pxAmount > 0.0f) {
            qsExpansion = MathUtils.lerp(mQsMinExpansionHeight, mQsMaxExpansionHeight,
                    mLockscreenShadeTransitionController.getQSDragProgress());
        }
        // SHADE_LOCKED means transition is over and we don't want further updates
        if (mBarState != SHADE_LOCKED) {
            setQsExpansion(qsExpansion);
        }
    }

    /**
     * Notify the panel that the pulse expansion has finished and that we're going to the full
     * shade
@@ -3020,7 +3036,7 @@ public class NotificationPanelViewController extends PanelViewController {
        }
        int maxHeight;
        if (mQsExpandImmediate || mQsExpanded || mIsExpanding && mQsExpandedWhenExpandingStarted
                || mPulsing) {
                || mPulsing || mSplitShadeEnabled) {
            maxHeight = calculatePanelHeightQsExpanded();
        } else {
            maxHeight = calculatePanelHeightShade();
@@ -4771,11 +4787,6 @@ public class NotificationPanelViewController extends PanelViewController {
                    duration = StackStateAnimator.ANIMATION_DURATION_STANDARD;
                }
                mKeyguardStatusBarViewController.animateKeyguardStatusBarOut(startDelay, duration);
                if (mSplitShadeEnabled) {
                    // temporary workaround for QS height not being updated during lockscreen to
                    // shade transition
                    setQsExpanded(true);
                }
                updateQSMinHeight();
            } else if (oldState == StatusBarState.SHADE_LOCKED
                    && statusBarState == KEYGUARD) {
+16 −4
Original line number Diff line number Diff line
@@ -266,7 +266,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
    @Test
    public void clockPositionedDependingOnMarginInSplitShade() {
        setSplitShadeTopMargin(400);
        mClockPositionAlgorithm.loadDimens(mResources);
        givenLockScreen();
        mIsSplitShade = true;
        // WHEN the position algorithm is run
@@ -294,7 +293,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
    public void notifPaddingAccountsForMultiUserSwitcherInSplitShade() {
        setSplitShadeTopMargin(100);
        mUserSwitchHeight = 150;
        mClockPositionAlgorithm.loadDimens(mResources);
        givenLockScreen();
        mIsSplitShade = true;
        // WHEN the position algorithm is run
@@ -307,7 +305,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
    public void clockDoesntAccountForMultiUserSwitcherInSplitShade() {
        setSplitShadeTopMargin(100);
        mUserSwitchHeight = 150;
        mClockPositionAlgorithm.loadDimens(mResources);
        givenLockScreen();
        mIsSplitShade = true;
        // WHEN the position algorithm is run
@@ -382,10 +379,24 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
        mQsExpansion = 1;
        // WHEN the clock position algorithm is run
        positionClock();
        // THEN the clock Y position is the middle of the screen (SCREEN_HEIGHT / 2).
        // THEN the clock is transparent.
        assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT);
    }

    @Test
    public void clockNotHiddenWhenQsIsExpandedInSplitShade() {
        // GIVEN on the split lock screen with QS expansion
        givenLockScreen();
        mIsSplitShade = true;
        setSplitShadeTopMargin(100);
        mQsExpansion = 1;

        // WHEN the clock position algorithm is run
        positionClock();

        assertThat(mClockPosition.clockAlpha).isEqualTo(1);
    }

    @Test
    public void clockPositionMinimizesBurnInMovementToAvoidUdfpsOnAOD() {
        // GIVEN a center aligned clock
@@ -524,6 +535,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
    private void setSplitShadeTopMargin(int value) {
        when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin))
                .thenReturn(value);
        mClockPositionAlgorithm.loadDimens(mResources);
    }

    private void givenHighestBurnInOffset() {