Merge "Fixing expansion state in NotificationPanelViewController" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-03-07 17:50:14 +00:00
committed by Android (Google) Code Review
5 changed files with 70 additions and 48 deletions

View File

@@ -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();
}

View File

@@ -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) {

View File

@@ -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(

View File

@@ -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;
@@ -1689,11 +1699,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);
@@ -1730,7 +1745,7 @@ public class NotificationPanelViewController extends PanelViewController {
public void expandWithQs() {
if (isQsExpansionEnabled()) {
mQsExpandImmediate = true;
mNotificationStackScrollLayoutController.setShouldShowShelfOnly(true);
setShowShelfOnly(true);
}
if (isFullyCollapsed()) {
expand(true /* animate */);
@@ -1929,7 +1944,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) {
@@ -1994,8 +2017,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 */);
@@ -2010,7 +2035,7 @@ public class NotificationPanelViewController extends PanelViewController {
}
if (!mQsExpandImmediate && mQsTracking) {
onQsTouch(event);
if (!mConflictingQsExpansionGesture) {
if (!mConflictingQsExpansionGesture && !mShouldUseSplitNotificationShade) {
return true;
}
}
@@ -2024,7 +2049,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
@@ -2095,6 +2120,9 @@ public class NotificationPanelViewController extends PanelViewController {
if (!isFullyCollapsed()) {
return;
}
if (mShouldUseSplitNotificationShade) {
mQsExpandImmediate = true;
}
mExpectingSynthesizedDown = true;
onTrackingStarted();
updatePanelExpanded();
@@ -2301,12 +2329,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) {
@@ -2351,7 +2377,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();
@@ -3199,7 +3225,7 @@ public class NotificationPanelViewController extends PanelViewController {
setListening(true);
}
mQsExpandImmediate = false;
mNotificationStackScrollLayoutController.setShouldShowShelfOnly(false);
setShowShelfOnly(false);
mTwoFingerQsExpandPossible = false;
updateTrackingHeadsUp(null);
mExpandingFromHeadsUp = false;
@@ -3255,9 +3281,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();
@@ -3962,10 +3986,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
@@ -4876,7 +4896,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;
}

View File

@@ -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));
}
}