Merge "Updating QS state to default when going from or to split shade" into tm-dev

This commit is contained in:
Michał Brzeziński
2022-05-16 09:38:50 +00:00
committed by Android (Google) Code Review
2 changed files with 63 additions and 48 deletions

View File

@@ -322,7 +322,7 @@ public class NotificationPanelViewController extends PanelViewController {
private final LargeScreenShadeHeaderController mLargeScreenShadeHeaderController;
private final RecordingController mRecordingController;
private final PanelEventsEmitter mPanelEventsEmitter;
private boolean mShouldUseSplitNotificationShade;
private boolean mSplitShadeEnabled;
// The bottom padding reserved for elements of the keyguard measuring notifications
private float mKeyguardNotificationBottomPadding;
/**
@@ -813,7 +813,7 @@ public class NotificationPanelViewController extends PanelViewController {
mKeyguardUserSwitcherComponentFactory = keyguardUserSwitcherComponentFactory;
mFragmentService = fragmentService;
mSettingsChangeObserver = new SettingsChangeObserver(handler);
mShouldUseSplitNotificationShade =
mSplitShadeEnabled =
LargeScreenUtils.shouldUseSplitNotificationShade(mResources);
mView.setWillNotDraw(!DEBUG);
mLargeScreenShadeHeaderController = largeScreenShadeHeaderController;
@@ -1028,7 +1028,7 @@ public class NotificationPanelViewController extends PanelViewController {
});
mView.setAccessibilityDelegate(mAccessibilityDelegate);
if (mShouldUseSplitNotificationShade) {
if (mSplitShadeEnabled) {
updateResources();
}
@@ -1125,20 +1125,18 @@ public class NotificationPanelViewController extends PanelViewController {
mSplitShadeNotificationsScrimMarginBottom =
mResources.getDimensionPixelSize(
R.dimen.split_shade_notifications_scrim_margin_bottom);
mShelfAndLockIconOverlap =
mResources.getDimensionPixelSize(R.dimen.shelf_and_lock_icon_overlap);
final boolean newShouldUseSplitNotificationShade =
final boolean newSplitShadeEnabled =
LargeScreenUtils.shouldUseSplitNotificationShade(mResources);
final boolean splitNotificationShadeChanged =
mShouldUseSplitNotificationShade != newShouldUseSplitNotificationShade;
final boolean splitShadeChanged = mSplitShadeEnabled != newSplitShadeEnabled;
mSplitShadeEnabled = newSplitShadeEnabled;
mShouldUseSplitNotificationShade = newShouldUseSplitNotificationShade;
boolean useLargeScreenShadeHeader =
LargeScreenUtils.shouldUseLargeScreenShadeHeader(mView.getResources());
if (mQs != null) {
mQs.setInSplitShade(mShouldUseSplitNotificationShade);
mQs.setInSplitShade(mSplitShadeEnabled);
}
mLargeScreenShadeHeaderHeight =
mResources.getDimensionPixelSize(R.dimen.large_screen_shade_header_height);
@@ -1154,7 +1152,12 @@ public class NotificationPanelViewController extends PanelViewController {
mKeyguardMediaController.refreshMediaPosition();
if (splitNotificationShadeChanged) {
if (splitShadeChanged) {
// when we switch from split shade to regular shade we want to enforce setting qs to
// the default state: expanded for split shade and collapsed otherwise
if (!isOnKeyguard() && mPanelExpanded) {
setQsExpanded(mSplitShadeEnabled);
}
updateClockAppearance();
updateQsState();
mNotificationStackScrollLayoutController.updateFooter();
@@ -1383,7 +1386,7 @@ public class NotificationPanelViewController extends PanelViewController {
updateClockAppearance();
}
if (!onKeyguard) {
if (mShouldUseSplitNotificationShade) {
if (mSplitShadeEnabled) {
// Quick settings are not on the top of the notifications
// when in split shade mode (they are on the left side),
// so we should not add a padding for them
@@ -1411,10 +1414,9 @@ public class NotificationPanelViewController extends PanelViewController {
.getVisibleNotificationCount() != 0
|| mMediaDataManager.hasActiveMediaOrRecommendation();
boolean splitShadeWithActiveMedia =
mShouldUseSplitNotificationShade
&& mMediaDataManager.hasActiveMediaOrRecommendation();
mSplitShadeEnabled && mMediaDataManager.hasActiveMediaOrRecommendation();
boolean shouldAnimateClockChange = mScreenOffAnimationController.shouldAnimateClockChange();
if ((hasVisibleNotifications && !mShouldUseSplitNotificationShade)
if ((hasVisibleNotifications && !mSplitShadeEnabled)
|| (splitShadeWithActiveMedia && !mDozing)) {
mKeyguardStatusViewController.displayClock(SMALL, shouldAnimateClockChange);
} else {
@@ -1451,7 +1453,7 @@ public class NotificationPanelViewController extends PanelViewController {
bypassEnabled, getUnlockedStackScrollerPadding(),
computeQsExpansionFraction(),
mDisplayTopInset,
mShouldUseSplitNotificationShade,
mSplitShadeEnabled,
udfpsAodTopLocation,
mKeyguardStatusViewController.getClockBottom(mStatusBarHeaderHeightKeyguard),
mKeyguardStatusViewController.isClockTopAligned());
@@ -1481,8 +1483,7 @@ public class NotificationPanelViewController extends PanelViewController {
boolean hasVisibleNotifications = mNotificationStackScrollLayoutController
.getVisibleNotificationCount() != 0
|| mMediaDataManager.hasActiveMediaOrRecommendation();
boolean shouldBeCentered = !mShouldUseSplitNotificationShade || !hasVisibleNotifications
|| mDozing;
boolean shouldBeCentered = !mSplitShadeEnabled || !hasVisibleNotifications || mDozing;
if (mStatusViewCentered != shouldBeCentered) {
mStatusViewCentered = shouldBeCentered;
ConstraintSet constraintSet = new ConstraintSet();
@@ -1491,7 +1492,7 @@ public class NotificationPanelViewController extends PanelViewController {
constraintSet.connect(R.id.keyguard_status_view, END, statusConstraint, END);
if (animate) {
ChangeBounds transition = new ChangeBounds();
if (mShouldUseSplitNotificationShade) {
if (mSplitShadeEnabled) {
// Excluding media from the transition on split-shade, as it doesn't transition
// horizontally properly.
transition.excludeTarget(R.id.status_view_media_container, true);
@@ -1648,7 +1649,7 @@ public class NotificationPanelViewController extends PanelViewController {
private void setShowShelfOnly(boolean shelfOnly) {
mNotificationStackScrollLayoutController.setShouldShowShelfOnly(
shelfOnly && !mShouldUseSplitNotificationShade);
shelfOnly && !mSplitShadeEnabled);
}
public void closeQs() {
@@ -1689,7 +1690,7 @@ public class NotificationPanelViewController extends PanelViewController {
mQsExpandImmediate = true;
setShowShelfOnly(true);
}
if (mShouldUseSplitNotificationShade && isOnKeyguard()) {
if (mSplitShadeEnabled && isOnKeyguard()) {
// It's a special case as this method is likely to not be initiated by finger movement
// but rather called from adb shell or accessibility service.
// We're using LockscreenShadeTransitionController because on lockscreen that's the
@@ -1919,7 +1920,7 @@ public class NotificationPanelViewController extends PanelViewController {
int flingType;
if (expandsQs && !isCancelMotionEvent) {
flingType = FLING_EXPAND;
} else if (mShouldUseSplitNotificationShade) {
} else if (mSplitShadeEnabled) {
flingType = FLING_HIDE;
} else {
flingType = FLING_COLLAPSE;
@@ -1985,11 +1986,11 @@ public class NotificationPanelViewController extends PanelViewController {
private boolean handleQsTouch(MotionEvent event) {
if (mShouldUseSplitNotificationShade && touchXOutsideOfQs(event.getX())) {
if (mSplitShadeEnabled && touchXOutsideOfQs(event.getX())) {
return false;
}
final int action = event.getActionMasked();
boolean collapsedQs = !mQsExpanded && !mShouldUseSplitNotificationShade;
boolean collapsedQs = !mQsExpanded && !mSplitShadeEnabled;
boolean expandedShadeCollapsedQs = getExpandedFraction() == 1f && mBarState != KEYGUARD
&& collapsedQs && isQsExpansionEnabled();
if (action == MotionEvent.ACTION_DOWN && expandedShadeCollapsedQs) {
@@ -2007,7 +2008,7 @@ public class NotificationPanelViewController extends PanelViewController {
}
if (!mQsExpandImmediate && mQsTracking) {
onQsTouch(event);
if (!mConflictingQsExpansionGesture && !mShouldUseSplitNotificationShade) {
if (!mConflictingQsExpansionGesture && !mSplitShadeEnabled) {
return true;
}
}
@@ -2298,7 +2299,7 @@ public class NotificationPanelViewController extends PanelViewController {
}
private void updateQsState() {
boolean qsFullScreen = mQsExpanded && !mShouldUseSplitNotificationShade;
boolean qsFullScreen = mQsExpanded && !mSplitShadeEnabled;
mNotificationStackScrollLayoutController.setQsFullScreen(qsFullScreen);
mNotificationStackScrollLayoutController.setScrollingEnabled(
mBarState != KEYGUARD && (!qsFullScreen || mQsExpansionFromOverscroll));
@@ -2346,7 +2347,7 @@ public class NotificationPanelViewController extends PanelViewController {
private void updateQsExpansion() {
if (mQs == null) return;
final float squishiness;
if ((mQsExpandImmediate || mQsExpanded) && !mShouldUseSplitNotificationShade) {
if ((mQsExpandImmediate || mQsExpanded) && !mSplitShadeEnabled) {
squishiness = 1;
} else if (mLockscreenShadeTransitionController.getQSDragProgress() > 0) {
squishiness = mLockscreenShadeTransitionController.getQSDragProgress();
@@ -2355,7 +2356,7 @@ public class NotificationPanelViewController extends PanelViewController {
.getNotificationSquishinessFraction();
}
final float qsExpansionFraction = computeQsExpansionFraction();
final float adjustedExpansionFraction = mShouldUseSplitNotificationShade
final float adjustedExpansionFraction = mSplitShadeEnabled
? 1f : computeQsExpansionFraction();
mQs.setQsExpansion(adjustedExpansionFraction, getExpandedFraction(), getHeaderTranslation(),
squishiness);
@@ -2364,7 +2365,7 @@ public class NotificationPanelViewController extends PanelViewController {
mScrimController.setQsPosition(qsExpansionFraction, qsPanelBottomY);
setQSClippingBounds();
if (mShouldUseSplitNotificationShade) {
if (mSplitShadeEnabled) {
// In split shade we want to pretend that QS are always collapsed so their behaviour and
// interactions don't influence notifications as they do in portrait. But we want to set
// 0 explicitly in case we're rotating from non-split shade with QS expansion of 1.
@@ -2404,7 +2405,7 @@ public class NotificationPanelViewController extends PanelViewController {
private void updateQSExpansionEnabledAmbient() {
final float scrollRangeToTop = mAmbientState.getTopPadding() - mQuickQsHeaderHeight;
mQsExpansionEnabledAmbient = mShouldUseSplitNotificationShade
mQsExpansionEnabledAmbient = mSplitShadeEnabled
|| (mAmbientState.getScrollY() <= scrollRangeToTop);
setQsExpansionEnabled();
}
@@ -2428,7 +2429,7 @@ public class NotificationPanelViewController extends PanelViewController {
private int calculateTopQsClippingBound(int qsPanelBottomY) {
int top;
if (mShouldUseSplitNotificationShade) {
if (mSplitShadeEnabled) {
top = Math.min(qsPanelBottomY, mLargeScreenShadeHeaderHeight);
} else {
if (mTransitioningToFullShadeProgress > 0.0f) {
@@ -2462,7 +2463,7 @@ public class NotificationPanelViewController extends PanelViewController {
}
private int calculateBottomQsClippingBound(int top) {
if (mShouldUseSplitNotificationShade) {
if (mSplitShadeEnabled) {
return top + mNotificationStackScrollLayoutController.getHeight()
+ mSplitShadeNotificationsScrimMarginBottom;
} else {
@@ -2559,7 +2560,7 @@ public class NotificationPanelViewController extends PanelViewController {
// qsTranslation should only be positive during pulse expansion because it's
// already translating in from the top
qsTranslation = Math.max(0, (top - mQs.getHeader().getHeight()) / 2.0f);
} else if (!mShouldUseSplitNotificationShade) {
} else if (!mSplitShadeEnabled) {
qsTranslation = (top - mQs.getHeader().getHeight()) * QS_PARALLAX_AMOUNT;
}
}
@@ -2573,11 +2574,11 @@ public class NotificationPanelViewController extends PanelViewController {
mQsClipTop,
mQsClipBottom,
radius, qsVisible
&& !mShouldUseSplitNotificationShade);
&& !mSplitShadeEnabled);
}
mKeyguardStatusViewController.setClipBounds(
clipStatusView ? mKeyguardStatusAreaClipBounds : null);
if (!qsVisible && mShouldUseSplitNotificationShade) {
if (!qsVisible && mSplitShadeEnabled) {
// On the lockscreen when qs isn't visible, we don't want the bounds of the shade to
// be visible, otherwise you can see the bounds once swiping up to see bouncer
mScrimController.setNotificationsBounds(0, 0, 0, 0);
@@ -2585,12 +2586,11 @@ public class NotificationPanelViewController extends PanelViewController {
// Increase the height of the notifications scrim when not in split shade
// (e.g. portrait tablet) so the rounded corners are not visible at the bottom,
// in this case they are rendered off-screen
final int notificationsScrimBottom =
mShouldUseSplitNotificationShade ? bottom : bottom + radius;
final int notificationsScrimBottom = mSplitShadeEnabled ? bottom : bottom + radius;
mScrimController.setNotificationsBounds(left, top, right, notificationsScrimBottom);
}
if (mShouldUseSplitNotificationShade) {
if (mSplitShadeEnabled) {
mKeyguardStatusBarViewController.setNoTopClipping();
} else {
mKeyguardStatusBarViewController.updateTopClipping(top);
@@ -2604,7 +2604,7 @@ public class NotificationPanelViewController extends PanelViewController {
int nsslRight = right - mNotificationStackScrollLayoutController.getLeft();
int nsslTop = top - mNotificationStackScrollLayoutController.getTop();
int nsslBottom = bottom - mNotificationStackScrollLayoutController.getTop();
int bottomRadius = mShouldUseSplitNotificationShade ? radius : 0;
int bottomRadius = mSplitShadeEnabled ? radius : 0;
mNotificationStackScrollLayoutController.setRoundedClippingBounds(
nsslLeft, nsslTop, nsslRight, nsslBottom, radius, bottomRadius);
}
@@ -2646,7 +2646,7 @@ public class NotificationPanelViewController extends PanelViewController {
}
private float calculateNotificationsTopPadding() {
if (mShouldUseSplitNotificationShade && !mKeyguardShowing) {
if (mSplitShadeEnabled && !mKeyguardShowing) {
return 0;
}
if (mKeyguardShowing && (mQsExpandImmediate
@@ -2919,7 +2919,7 @@ public class NotificationPanelViewController extends PanelViewController {
private boolean shouldQuickSettingsIntercept(float x, float y, float yDiff) {
if (!isQsExpansionEnabled() || mCollapsedOnDown
|| (mKeyguardShowing && mKeyguardBypassController.getBypassEnabled())
|| mShouldUseSplitNotificationShade) {
|| mSplitShadeEnabled) {
return false;
}
View header = mKeyguardShowing || mQs == null ? mKeyguardStatusBar : mQs.getHeader();
@@ -2950,7 +2950,7 @@ public class NotificationPanelViewController extends PanelViewController {
return true;
}
return !mShouldUseSplitNotificationShade && (isInSettings() || mIsPanelCollapseOnQQS);
return !mSplitShadeEnabled && (isInSettings() || mIsPanelCollapseOnQQS);
}
@Override
@@ -3134,7 +3134,7 @@ public class NotificationPanelViewController extends PanelViewController {
float appearAmount = mNotificationStackScrollLayoutController
.calculateAppearFraction(mExpandedHeight);
float startHeight = -mQsExpansionHeight;
if (!mShouldUseSplitNotificationShade && mBarState == StatusBarState.SHADE) {
if (!mSplitShadeEnabled && mBarState == StatusBarState.SHADE) {
// Small parallax as we pull down and clip QS
startHeight = -mQsExpansionHeight * QS_PARALLAX_AMOUNT;
}
@@ -3682,7 +3682,7 @@ public class NotificationPanelViewController extends PanelViewController {
mQs.setCollapseExpandAction(mCollapseExpandAction);
mQs.setHeaderClickable(isQsExpansionEnabled());
mQs.setOverscrolling(mStackScrollerOverscrolling);
mQs.setInSplitShade(mShouldUseSplitNotificationShade);
mQs.setInSplitShade(mSplitShadeEnabled);
// recompute internal state when qspanel height changes
mQs.getView().addOnLayoutChangeListener(
@@ -4353,7 +4353,7 @@ public class NotificationPanelViewController extends PanelViewController {
@Override
public void onOverscrollTopChanged(float amount, boolean isRubberbanded) {
// When in split shade, overscroll shouldn't carry through to QS
if (mShouldUseSplitNotificationShade) {
if (mSplitShadeEnabled) {
return;
}
cancelQsAnimation();
@@ -4371,7 +4371,7 @@ public class NotificationPanelViewController extends PanelViewController {
@Override
public void flingTopOverscroll(float velocity, boolean open) {
// in split shade mode we want to expand/collapse QS only when touch happens within QS
if (mShouldUseSplitNotificationShade && touchXOutsideOfQs(mInitialTouchX)) {
if (mSplitShadeEnabled && touchXOutsideOfQs(mInitialTouchX)) {
return;
}
mLastOverscroll = 0f;
@@ -4711,7 +4711,7 @@ public class NotificationPanelViewController extends PanelViewController {
// the top of QS
if (!mQsExpanded) {
// TODO(b/185683835) Nicer clipping when using new spacial model
if (mShouldUseSplitNotificationShade) {
if (mSplitShadeEnabled) {
mQs.animateHeaderSlidingOut();
}
}
@@ -4908,7 +4908,7 @@ public class NotificationPanelViewController extends PanelViewController {
private void updateQSMinHeight() {
float previousMin = mQsMinExpansionHeight;
if (mKeyguardShowing || mShouldUseSplitNotificationShade) {
if (mKeyguardShowing || mSplitShadeEnabled) {
mQsMinExpansionHeight = 0;
} else {
mQsMinExpansionHeight = mQs.getQsMinExpansionHeight();
@@ -5042,7 +5042,7 @@ public class NotificationPanelViewController extends PanelViewController {
// we need to ignore it on keyguard as this is a false alarm - transition from unlocked
// to locked will trigger this event and we're not actually in the process of opening
// the shade, lockscreen is just always expanded
if (mShouldUseSplitNotificationShade && !isOnKeyguard()) {
if (mSplitShadeEnabled && !isOnKeyguard()) {
mQsExpandImmediate = true;
}
mCentralSurfaces.makeExpandedVisible(false);

View File

@@ -1089,6 +1089,21 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
assertThat(mNotificationPanelViewController.mQsExpandImmediate).isFalse();
}
@Test
public void testQsExpansionChangedToDefaultWhenRotatingFromOrToSplitShade() {
// to make sure shade is in expanded state
mNotificationPanelViewController.startWaitingForOpenPanelGesture();
assertThat(mNotificationPanelViewController.isQsExpanded()).isFalse();
// switch to split shade from portrait (default state)
enableSplitShade(/* enabled= */ true);
assertThat(mNotificationPanelViewController.isQsExpanded()).isTrue();
// switch to portrait from split shade
enableSplitShade(/* enabled= */ false);
assertThat(mNotificationPanelViewController.isQsExpanded()).isFalse();
}
@Test
public void interceptTouchEvent_withinQs_shadeExpanded_startsQsTracking() {
mNotificationPanelViewController.mQs = mQs;