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

Commit 019d7292 authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Fixing expansion state in NotificationPanelViewController

This also reverts ag/16835086, which was just a quick hack while this is a proper long-term solution.
The main change here is making sure mQsExpanded flag accurately represents the state in split shade. To do that, mQsExpandImmediately is reused and it makes sure that QS ends up in proper state once shade is expanded.
That cascaded to other changes/fixes, one of the major one being changing mQsExpanded in NotificationStackScrollLayout to mQsFullScreen - otherwise every use of mQsExpanded would have to be updated with checking if we’re in split shade mode. mQsFullScreen better represents change in notifications behaviour depending on the state.

Fixes: 218268829
Test: Expand split shade and check all tiles - especially on the second page - are working correctly
Change-Id: Id65c73c034fb8705eed8274416f125e4d861ac30
parent cdb9f0c8
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -199,9 +199,7 @@ public class QSPanelController extends QSPanelControllerBase<QSPanel> {

    /** */
    public void setListening(boolean listening, boolean expanded) {
        // TODO(218268829): checking for split shade is workaround but when proper fix lands
        //  "|| mShouldUseSplitNotificationShade" should be removed
        setListening(listening && (expanded || mShouldUseSplitNotificationShade));
        setListening(listening && expanded);
        if (mView.isListening()) {
            refreshAllTiles();
        }
+13 −12
Original line number Diff line number Diff line
@@ -404,7 +404,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
     */
    private float mBackgroundXFactor = 1f;

    private boolean mQsExpanded;
    /**
     * Indicates QS are full screen and pushing notifications out of the screen.
     * It's different from QS just being expanded as in split shade QS can be expanded and
     * still don't take full screen nor influence notifications.
     */
    private boolean mQsFullScreen;
    private boolean mForwardScrollable;
    private boolean mBackwardScrollable;
    private NotificationShelf mShelf;
@@ -1130,7 +1135,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable

    @ShadeViewRefactor(RefactorComponent.LAYOUT_ALGORITHM)
    private void updateAlgorithmLayoutMinHeight() {
        mAmbientState.setLayoutMinHeight(mQsExpanded || isHeadsUpTransition()
        mAmbientState.setLayoutMinHeight(mQsFullScreen || isHeadsUpTransition()
                ? getLayoutMinHeight() : 0);
    }

@@ -1361,7 +1366,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            translationY = 0;
            if (mShouldShowShelfOnly) {
                stackHeight = mTopPadding + mShelf.getIntrinsicHeight();
            } else if (mQsExpanded) {
            } else if (mQsFullScreen) {
                int stackStartPosition = mContentHeight - mTopPadding + mIntrinsicPadding;
                int stackEndPosition = mMaxTopPadding + mShelf.getIntrinsicHeight();
                if (stackStartPosition <= stackEndPosition) {
@@ -2318,7 +2323,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    private void updateScrollability() {
        boolean scrollable = !mQsExpanded && getScrollRange() > 0;
        boolean scrollable = !mQsFullScreen && getScrollRange() > 0;
        if (scrollable != mScrollable) {
            mScrollable = scrollable;
            setFocusable(scrollable);
@@ -4839,14 +4844,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    public void setQsExpanded(boolean qsExpanded) {
        mQsExpanded = qsExpanded;
    public void setQsFullScreen(boolean qsFullScreen) {
        mQsFullScreen = qsFullScreen;
        updateAlgorithmLayoutMinHeight();
        updateScrollability();
    }

    boolean isQsExpanded() {
        return mQsExpanded;
    boolean isQsFullScreen() {
        return mQsFullScreen;
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
@@ -5807,10 +5812,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mSwipeHelper.resetExposedMenuView(animate, force);
    }

    boolean isUsingSplitNotificationShade() {
        return mShouldUseSplitNotificationShade;
    }

    static boolean matchesSelection(
            ExpandableNotificationRow row,
            @SelectedRows int selection) {
+4 −4
Original line number Diff line number Diff line
@@ -111,13 +111,13 @@ import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.row.NotificationGuts;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.row.NotificationSnooze;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
@@ -1086,8 +1086,8 @@ public class NotificationStackScrollLayoutController {
        }
    }

    public void setQsExpanded(boolean expanded) {
        mView.setQsExpanded(expanded);
    public void setQsFullScreen(boolean fullScreen) {
        mView.setQsFullScreen(fullScreen);
        updateShowEmptyShadeView();
    }

@@ -1204,7 +1204,7 @@ public class NotificationStackScrollLayoutController {
    public void updateShowEmptyShadeView() {
        Trace.beginSection("NSSLC.updateShowEmptyShadeView");
        mShowEmptyShadeView = mBarState != KEYGUARD
                && (!mView.isQsExpanded() || mView.isUsingSplitNotificationShade())
                && !mView.isQsFullScreen()
                && getVisibleNotificationCount() == 0;

        mView.updateEmptyShadeView(
+47 −23
Original line number Diff line number Diff line
@@ -358,6 +358,12 @@ public class NotificationPanelViewController extends PanelViewController {
    private boolean mConflictingQsExpansionGesture;

    private boolean mPanelExpanded;

    /**
     * Indicates that QS is in expanded state which can happen by:
     * - single pane shade: expanding shade and then expanding QS
     * - split shade: just expanding shade (QS are expanded automatically)
     */
    private boolean mQsExpanded;
    private boolean mQsExpandedWhenExpandingStarted;
    private boolean mQsFullyExpanded;
@@ -401,7 +407,11 @@ public class NotificationPanelViewController extends PanelViewController {
    private boolean mIsExpanding;

    private boolean mBlockTouches;
    // Used for two finger gesture as well as accessibility shortcut to QS.

    /**
     * Determines if QS should be already expanded when expanding shade.
     * Used for split shade, two finger gesture as well as accessibility shortcut to QS.
     */
    private boolean mQsExpandImmediate;
    private boolean mTwoFingerQsExpandPossible;
    private String mHeaderDebugInfo;
@@ -1684,11 +1694,16 @@ public class NotificationPanelViewController extends PanelViewController {

        if (mQsExpanded) {
            mQsExpandImmediate = true;
            mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
            setShowShelfOnly(true);
        }
        super.collapse(delayed, speedUpFactor);
    }

    private void setShowShelfOnly(boolean shelfOnly) {
        mNotificationStackScrollLayoutController.setShouldShowShelfOnly(
                shelfOnly && !mShouldUseSplitNotificationShade);
    }

    public void closeQs() {
        cancelQsAnimation();
        setQsExpansion(mQsMinExpansionHeight);
@@ -1725,7 +1740,7 @@ public class NotificationPanelViewController extends PanelViewController {
    public void expandWithQs() {
        if (isQsExpansionEnabled()) {
            mQsExpandImmediate = true;
            mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
            setShowShelfOnly(true);
        }
        if (isFullyCollapsed()) {
            expand(true /* animate */);
@@ -1924,7 +1939,15 @@ public class NotificationPanelViewController extends PanelViewController {
            mFalsingManager.isFalseTouch(QS_COLLAPSE);
        }

        flingSettings(vel, expandsQs && !isCancelMotionEvent ? FLING_EXPAND : FLING_COLLAPSE);
        int flingType;
        if (expandsQs && !isCancelMotionEvent) {
            flingType = FLING_EXPAND;
        } else if (mShouldUseSplitNotificationShade) {
            flingType = FLING_HIDE;
        } else {
            flingType = FLING_COLLAPSE;
        }
        flingSettings(vel, flingType);
    }

    private void logQsSwipeDown(float y) {
@@ -1989,8 +2012,10 @@ public class NotificationPanelViewController extends PanelViewController {
            return false;
        }
        final int action = event.getActionMasked();
        if (action == MotionEvent.ACTION_DOWN && getExpandedFraction() == 1f
                && mBarState != KEYGUARD && !mQsExpanded && isQsExpansionEnabled()) {
        boolean collapsedQs = !mQsExpanded && !mShouldUseSplitNotificationShade;
        boolean expandedShadeCollapsedQs = getExpandedFraction() == 1f && mBarState != KEYGUARD
                && collapsedQs && isQsExpansionEnabled();
        if (action == MotionEvent.ACTION_DOWN && expandedShadeCollapsedQs) {
            // Down in the empty area while fully expanded - go to QS.
            mQsTracking = true;
            traceQsJank(true /* startTracing */, false /* wasCancelled */);
@@ -2005,7 +2030,7 @@ public class NotificationPanelViewController extends PanelViewController {
        }
        if (!mQsExpandImmediate && mQsTracking) {
            onQsTouch(event);
            if (!mConflictingQsExpansionGesture) {
            if (!mConflictingQsExpansionGesture && !mShouldUseSplitNotificationShade) {
                return true;
            }
        }
@@ -2019,7 +2044,7 @@ public class NotificationPanelViewController extends PanelViewController {
                < mStatusBarMinHeight) {
            mMetricsLogger.count(COUNTER_PANEL_OPEN_QS, 1);
            mQsExpandImmediate = true;
            mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
            setShowShelfOnly(true);
            requestPanelHeightUpdate();

            // Normally, we start listening when the panel is expanded, but here we need to start
@@ -2090,6 +2115,9 @@ public class NotificationPanelViewController extends PanelViewController {
        if (!isFullyCollapsed()) {
            return;
        }
        if (mShouldUseSplitNotificationShade) {
            mQsExpandImmediate = true;
        }
        mExpectingSynthesizedDown = true;
        onTrackingStarted();
        updatePanelExpanded();
@@ -2296,12 +2324,10 @@ public class NotificationPanelViewController extends PanelViewController {
    }

    private void updateQsState() {
        mNotificationStackScrollLayoutController.setQsExpanded(mQsExpanded);
        boolean qsFullScreen = mQsExpanded && !mShouldUseSplitNotificationShade;
        mNotificationStackScrollLayoutController.setQsFullScreen(qsFullScreen);
        mNotificationStackScrollLayoutController.setScrollingEnabled(
                mBarState != KEYGUARD
                        && (!mQsExpanded
                            || mQsExpansionFromOverscroll
                            || mShouldUseSplitNotificationShade));
                mBarState != KEYGUARD && (!qsFullScreen || mQsExpansionFromOverscroll));

        if (mKeyguardUserSwitcherController != null && mQsExpanded
                && !mStackScrollerOverscrolling) {
@@ -2346,7 +2372,7 @@ public class NotificationPanelViewController extends PanelViewController {
    private void updateQsExpansion() {
        if (mQs == null) return;
        final float squishiness;
        if (mQsExpandImmediate || mQsExpanded) {
        if ((mQsExpandImmediate || mQsExpanded) && !mShouldUseSplitNotificationShade) {
            squishiness = 1;
        } else if (mLockscreenShadeTransitionController.getQSDragProgress() > 0) {
            squishiness = mLockscreenShadeTransitionController.getQSDragProgress();
@@ -3194,7 +3220,7 @@ public class NotificationPanelViewController extends PanelViewController {
            setListening(true);
        }
        mQsExpandImmediate = false;
        mNotificationStackScrollLayoutController.setShouldShowShelfOnly(false);
        setShowShelfOnly(false);
        mTwoFingerQsExpandPossible = false;
        updateTrackingHeadsUp(null);
        mExpandingFromHeadsUp = false;
@@ -3250,9 +3276,7 @@ public class NotificationPanelViewController extends PanelViewController {
        mScrimController.onTrackingStarted();
        if (mQsFullyExpanded) {
            mQsExpandImmediate = true;
            if (!mShouldUseSplitNotificationShade) {
                mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
            }
            setShowShelfOnly(true);
        }
        if (mBarState == KEYGUARD || mBarState == StatusBarState.SHADE_LOCKED) {
            mAffordanceHelper.animateHideLeftRightIcon();
@@ -3957,10 +3981,6 @@ public class NotificationPanelViewController extends PanelViewController {
        mNotificationStackScrollLayoutController.runAfterAnimationFinished(r);
    }

    public void setScrollingEnabled(boolean b) {
        mNotificationStackScrollLayoutController.setScrollingEnabled(b);
    }

    private Runnable mHideExpandedRunnable;
    private final Runnable mMaybeHideExpandedRunnable = new Runnable() {
        @Override
@@ -4871,7 +4891,11 @@ public class NotificationPanelViewController extends PanelViewController {

    private void updateQSMinHeight() {
        float previousMin = mQsMinExpansionHeight;
        mQsMinExpansionHeight = mKeyguardShowing ? 0 : mQs.getQsMinExpansionHeight();
        if (mKeyguardShowing || mShouldUseSplitNotificationShade) {
            mQsMinExpansionHeight = 0;
        } else {
            mQsMinExpansionHeight = mQs.getQsMinExpansionHeight();
        }
        if (mQsExpansionHeight == previousMin) {
            mQsExpansionHeight = mQsMinExpansionHeight;
        }
+5 −6
Original line number Diff line number Diff line
@@ -69,11 +69,11 @@ import com.android.systemui.statusbar.notification.collection.render.SectionHead
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController.NotificationPanelEvent;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.ZenModeController;
@@ -278,18 +278,17 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
                mStateListenerArgumentCaptor.capture(), anyInt());
        StatusBarStateController.StateListener stateListener =
                mStateListenerArgumentCaptor.getValue();
        when(mNotificationStackScrollLayout.isUsingSplitNotificationShade()).thenReturn(true);
        stateListener.onStateChanged(SHADE);
        mController.getView().removeAllViews();

        mController.setQsExpanded(false);
        mController.setQsFullScreen(false);
        reset(mNotificationStackScrollLayout);
        mController.updateShowEmptyShadeView();
        verify(mNotificationStackScrollLayout).updateEmptyShadeView(
                /* visible= */ true,
                /* notifVisibleInShade= */ false);

        mController.setQsExpanded(true);
        mController.setQsFullScreen(true);
        reset(mNotificationStackScrollLayout);
        mController.updateShowEmptyShadeView();
        verify(mNotificationStackScrollLayout).updateEmptyShadeView(
@@ -411,11 +410,11 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
            boolean toShow) {
        if (toShow) {
            statusBarStateListener.onStateChanged(SHADE);
            mController.setQsExpanded(false);
            mController.setQsFullScreen(false);
            mController.getView().removeAllViews();
        } else {
            statusBarStateListener.onStateChanged(KEYGUARD);
            mController.setQsExpanded(true);
            mController.setQsFullScreen(true);
            mController.getView().addContainerView(mock(ExpandableNotificationRow.class));
        }
    }