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

Commit d6ae817d authored by Michał Brzeziński's avatar Michał Brzeziński Committed by Automerger Merge Worker
Browse files

Merge changes from topic "qs_expanded_state_fix" into tm-qpr-dev am: 6bcb40d0

parents b551226c 6bcb40d0
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -442,20 +442,19 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
    }
    }


    private void updateQsState() {
    private void updateQsState() {
        final boolean expanded = mQsExpanded || mInSplitShade;
        final boolean expandVisually = mQsExpanded || mStackScrollerOverscrolling
        final boolean expandVisually = expanded || mStackScrollerOverscrolling
                || mHeaderAnimating;
                || mHeaderAnimating;
        mQSPanelController.setExpanded(expanded);
        mQSPanelController.setExpanded(mQsExpanded);
        boolean keyguardShowing = isKeyguardState();
        boolean keyguardShowing = isKeyguardState();
        mHeader.setVisibility((expanded || !keyguardShowing || mHeaderAnimating
        mHeader.setVisibility((mQsExpanded || !keyguardShowing || mHeaderAnimating
                || mShowCollapsedOnKeyguard)
                || mShowCollapsedOnKeyguard)
                ? View.VISIBLE
                ? View.VISIBLE
                : View.INVISIBLE);
                : View.INVISIBLE);
        mHeader.setExpanded((keyguardShowing && !mHeaderAnimating && !mShowCollapsedOnKeyguard)
        mHeader.setExpanded((keyguardShowing && !mHeaderAnimating && !mShowCollapsedOnKeyguard)
                || (expanded && !mStackScrollerOverscrolling), mQuickQSPanelController);
                || (mQsExpanded && !mStackScrollerOverscrolling), mQuickQSPanelController);
        boolean qsPanelVisible = !mQsDisabled && expandVisually;
        boolean qsPanelVisible = !mQsDisabled && expandVisually;
        boolean footerVisible = qsPanelVisible &&  (expanded || !keyguardShowing || mHeaderAnimating
        boolean footerVisible = qsPanelVisible && (mQsExpanded || !keyguardShowing
                || mShowCollapsedOnKeyguard);
                || mHeaderAnimating || mShowCollapsedOnKeyguard);
        mFooter.setVisibility(footerVisible ? View.VISIBLE : View.INVISIBLE);
        mFooter.setVisibility(footerVisible ? View.VISIBLE : View.INVISIBLE);
        if (mQSFooterActionController != null) {
        if (mQSFooterActionController != null) {
            mQSFooterActionController.setVisible(footerVisible);
            mQSFooterActionController.setVisible(footerVisible);
@@ -463,7 +462,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
            mQSFooterActionsViewModel.onVisibilityChangeRequested(footerVisible);
            mQSFooterActionsViewModel.onVisibilityChangeRequested(footerVisible);
        }
        }
        mFooter.setExpanded((keyguardShowing && !mHeaderAnimating && !mShowCollapsedOnKeyguard)
        mFooter.setExpanded((keyguardShowing && !mHeaderAnimating && !mShowCollapsedOnKeyguard)
                || (expanded && !mStackScrollerOverscrolling));
                || (mQsExpanded && !mStackScrollerOverscrolling));
        mQSPanelController.setVisibility(qsPanelVisible ? View.VISIBLE : View.INVISIBLE);
        mQSPanelController.setVisibility(qsPanelVisible ? View.VISIBLE : View.INVISIBLE);
        if (DEBUG) {
        if (DEBUG) {
            Log.d(TAG, "Footer: " + footerVisible + ", QS Panel: " + qsPanelVisible);
            Log.d(TAG, "Footer: " + footerVisible + ", QS Panel: " + qsPanelVisible);
+22 −15
Original line number Original line Diff line number Diff line
@@ -430,6 +430,7 @@ public final class NotificationPanelViewController extends PanelViewController {
    /**
    /**
     * Determines if QS should be already expanded when expanding shade.
     * Determines if QS should be already expanded when expanding shade.
     * Used for split shade, two finger gesture as well as accessibility shortcut to QS.
     * Used for split shade, two finger gesture as well as accessibility shortcut to QS.
     * It needs to be set when movement starts as it resets at the end of expansion/collapse.
     */
     */
    @VisibleForTesting
    @VisibleForTesting
    boolean mQsExpandImmediate;
    boolean mQsExpandImmediate;
@@ -1737,9 +1738,11 @@ public final class NotificationPanelViewController extends PanelViewController {
    }
    }


    private void setQsExpandImmediate(boolean expandImmediate) {
    private void setQsExpandImmediate(boolean expandImmediate) {
        if (expandImmediate != mQsExpandImmediate) {
            mQsExpandImmediate = expandImmediate;
            mQsExpandImmediate = expandImmediate;
            mPanelEventsEmitter.notifyExpandImmediateChange(expandImmediate);
            mPanelEventsEmitter.notifyExpandImmediateChange(expandImmediate);
        }
        }
    }


    private void setShowShelfOnly(boolean shelfOnly) {
    private void setShowShelfOnly(boolean shelfOnly) {
        mNotificationStackScrollLayoutController.setShouldShowShelfOnly(
        mNotificationStackScrollLayoutController.setShouldShowShelfOnly(
@@ -3124,26 +3127,24 @@ public final class NotificationPanelViewController extends PanelViewController {
        }
        }
        if (mQsExpandImmediate || (mQsExpanded && !mQsTracking && mQsExpansionAnimator == null
        if (mQsExpandImmediate || (mQsExpanded && !mQsTracking && mQsExpansionAnimator == null
                && !mQsExpansionFromOverscroll)) {
                && !mQsExpansionFromOverscroll)) {
            float t;
            float qsExpansionFraction;
            if (mKeyguardShowing) {
            if (mSplitShadeEnabled) {

                qsExpansionFraction = 1;
            } else if (mKeyguardShowing) {
                // On Keyguard, interpolate the QS expansion linearly to the panel expansion
                // On Keyguard, interpolate the QS expansion linearly to the panel expansion
                t = expandedHeight / (getMaxPanelHeight());
                qsExpansionFraction = expandedHeight / (getMaxPanelHeight());
            } else {
            } else {
                // In Shade, interpolate linearly such that QS is closed whenever panel height is
                // In Shade, interpolate linearly such that QS is closed whenever panel height is
                // minimum QS expansion + minStackHeight
                // minimum QS expansion + minStackHeight
                float
                float panelHeightQsCollapsed =
                        panelHeightQsCollapsed =
                        mNotificationStackScrollLayoutController.getIntrinsicPadding()
                        mNotificationStackScrollLayoutController.getIntrinsicPadding()
                                + mNotificationStackScrollLayoutController.getLayoutMinHeight();
                                + mNotificationStackScrollLayoutController.getLayoutMinHeight();
                float panelHeightQsExpanded = calculatePanelHeightQsExpanded();
                float panelHeightQsExpanded = calculatePanelHeightQsExpanded();
                t =
                qsExpansionFraction = (expandedHeight - panelHeightQsCollapsed)
                        (expandedHeight - panelHeightQsCollapsed) / (panelHeightQsExpanded
                        / (panelHeightQsExpanded - panelHeightQsCollapsed);
                                - panelHeightQsCollapsed);
            }
            }
            float
            float targetHeight = mQsMinExpansionHeight
                    targetHeight =
                    + qsExpansionFraction * (mQsMaxExpansionHeight - mQsMinExpansionHeight);
                    mQsMinExpansionHeight + t * (mQsMaxExpansionHeight - mQsMinExpansionHeight);
            setQsExpansion(targetHeight);
            setQsExpansion(targetHeight);
        }
        }
        updateExpandedHeight(expandedHeight);
        updateExpandedHeight(expandedHeight);
@@ -3329,7 +3330,11 @@ public final class NotificationPanelViewController extends PanelViewController {
        } else {
        } else {
            setListening(true);
            setListening(true);
        }
        }
        if (mBarState != SHADE) {
            // updating qsExpandImmediate is done in onPanelStateChanged for unlocked shade but
            // on keyguard panel state is always OPEN so we need to have that extra update
            setQsExpandImmediate(false);
            setQsExpandImmediate(false);
        }
        setShowShelfOnly(false);
        setShowShelfOnly(false);
        mTwoFingerQsExpandPossible = false;
        mTwoFingerQsExpandPossible = false;
        updateTrackingHeadsUp(null);
        updateTrackingHeadsUp(null);
@@ -4993,6 +4998,7 @@ public final class NotificationPanelViewController extends PanelViewController {
        updateQSExpansionEnabledAmbient();
        updateQSExpansionEnabledAmbient();


        if (state == STATE_OPEN && mCurrentPanelState != state) {
        if (state == STATE_OPEN && mCurrentPanelState != state) {
            setQsExpandImmediate(false);
            mView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
            mView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
        }
        }
        if (state == STATE_OPENING) {
        if (state == STATE_OPENING) {
@@ -5005,6 +5011,7 @@ public final class NotificationPanelViewController extends PanelViewController {
            mCentralSurfaces.makeExpandedVisible(false);
            mCentralSurfaces.makeExpandedVisible(false);
        }
        }
        if (state == STATE_CLOSED) {
        if (state == STATE_CLOSED) {
            setQsExpandImmediate(false);
            // Close the status bar in the next frame so we can show the end of the
            // Close the status bar in the next frame so we can show the end of the
            // animation.
            // animation.
            mView.post(mMaybeHideExpandedRunnable);
            mView.post(mMaybeHideExpandedRunnable);
+13 −0
Original line number Original line Diff line number Diff line
@@ -402,6 +402,19 @@ public class QSFragmentTest extends SysuiBaseFragmentTest {
        verify(mQSPanelController).setListening(eq(true), anyBoolean());
        verify(mQSPanelController).setListening(eq(true), anyBoolean());
    }
    }


    @Test
    public void passCorrectExpansionState_inSplitShade() {
        QSFragment fragment = resumeAndGetFragment();
        enableSplitShade();
        clearInvocations(mQSPanelController);

        fragment.setExpanded(true);
        verify(mQSPanelController).setExpanded(true);

        fragment.setExpanded(false);
        verify(mQSPanelController).setExpanded(false);
    }

    @Override
    @Override
    protected Fragment instantiate(Context context, String className, Bundle arguments) {
    protected Fragment instantiate(Context context, String className, Bundle arguments) {
        MockitoAnnotations.initMocks(this);
        MockitoAnnotations.initMocks(this);
+19 −12
Original line number Original line Diff line number Diff line
@@ -23,6 +23,9 @@ import static com.android.keyguard.KeyguardClockSwitch.SMALL;
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.StatusBarState.SHADE_LOCKED;
import static com.android.systemui.statusbar.StatusBarState.SHADE_LOCKED;
import static com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManagerKt.STATE_CLOSED;
import static com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManagerKt.STATE_OPEN;
import static com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManagerKt.STATE_OPENING;


import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertThat;


@@ -1249,14 +1252,10 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
    @Test
    @Test
    public void testQsToBeImmediatelyExpandedWhenOpeningPanelInSplitShade() {
    public void testQsToBeImmediatelyExpandedWhenOpeningPanelInSplitShade() {
        enableSplitShade(/* enabled= */ true);
        enableSplitShade(/* enabled= */ true);
        // set panel state to CLOSED
        mPanelExpansionStateManager.updateState(STATE_CLOSED);
        mPanelExpansionStateManager.onPanelExpansionChanged(/* fraction= */ 0,
                /* expanded= */ false, /* tracking= */ false, /* dragDownPxAmount= */ 0);
        assertThat(mNotificationPanelViewController.mQsExpandImmediate).isFalse();
        assertThat(mNotificationPanelViewController.mQsExpandImmediate).isFalse();


        // change panel state to OPENING
        mPanelExpansionStateManager.updateState(STATE_OPENING);
        mPanelExpansionStateManager.onPanelExpansionChanged(/* fraction= */ 0.5f,
                /* expanded= */ true, /* tracking= */ true, /* dragDownPxAmount= */ 100);


        assertThat(mNotificationPanelViewController.mQsExpandImmediate).isTrue();
        assertThat(mNotificationPanelViewController.mQsExpandImmediate).isTrue();
    }
    }
@@ -1264,15 +1263,23 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
    @Test
    @Test
    public void testQsNotToBeImmediatelyExpandedWhenGoingFromUnlockedToLocked() {
    public void testQsNotToBeImmediatelyExpandedWhenGoingFromUnlockedToLocked() {
        enableSplitShade(/* enabled= */ true);
        enableSplitShade(/* enabled= */ true);
        // set panel state to CLOSED
        mPanelExpansionStateManager.updateState(STATE_CLOSED);
        mPanelExpansionStateManager.onPanelExpansionChanged(/* fraction= */ 0,
                /* expanded= */ false, /* tracking= */ false, /* dragDownPxAmount= */ 0);


        // go to lockscreen, which also sets fraction to 1.0f and makes shade "expanded"
        mStatusBarStateController.setState(KEYGUARD);
        mStatusBarStateController.setState(KEYGUARD);
        mPanelExpansionStateManager.onPanelExpansionChanged(/* fraction= */ 1,
        // going to lockscreen would trigger STATE_OPENING
                /* expanded= */ true, /* tracking= */ true, /* dragDownPxAmount= */ 0);
        mPanelExpansionStateManager.updateState(STATE_OPENING);

        assertThat(mNotificationPanelViewController.mQsExpandImmediate).isFalse();
    }

    @Test
    public void testQsImmediateResetsWhenPanelOpensOrCloses() {
        mNotificationPanelViewController.mQsExpandImmediate = true;
        mPanelExpansionStateManager.updateState(STATE_OPEN);
        assertThat(mNotificationPanelViewController.mQsExpandImmediate).isFalse();


        mNotificationPanelViewController.mQsExpandImmediate = true;
        mPanelExpansionStateManager.updateState(STATE_CLOSED);
        assertThat(mNotificationPanelViewController.mQsExpandImmediate).isFalse();
        assertThat(mNotificationPanelViewController.mQsExpandImmediate).isFalse();
    }
    }