diff options
| author | 2024-08-30 10:06:39 +0000 | |
|---|---|---|
| committer | 2024-08-30 10:06:39 +0000 | |
| commit | 6501946fda971d6f68813be0cbf022d7efdadf90 (patch) | |
| tree | ff38f435c37774e2c43730b8bb9b032758706475 | |
| parent | 2af67b9484db8bcfc81bf74c48172ec2e9cc5d8b (diff) | |
| parent | 989607f6dc15f06dfef3c36c068ea62eaee618e5 (diff) | |
Merge changes Idb04c4b9,Ic05953a8 into main
* changes:
[Flexiglass] Don't recalculate expandFraction in the NSSL
[Flexiglass] Simplify NSSL's stack height calculation
8 files changed, 179 insertions, 65 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java index 696e2225d286..d523bc1867c2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java @@ -255,8 +255,8 @@ public class NotificationShelf extends ActivatableNotificationView { } final float stackBottom = SceneContainerFlag.isEnabled() - ? ambientState.getStackTop() + ambientState.getStackHeight() - : ambientState.getStackY() + ambientState.getStackHeight(); + ? ambientState.getStackTop() + ambientState.getInterpolatedStackHeight() + : ambientState.getStackY() + ambientState.getInterpolatedStackHeight(); if (viewState.hidden) { // if the shelf is hidden, position it at the end of the stack (plus the clip diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java index 4be638f5b41f..2f3719a34ac8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/AmbientState.java @@ -173,7 +173,8 @@ public class AmbientState implements Dumpable { } /** - * @return Height of the notifications panel without top padding when expansion completes. + * @return Height of the available space for the notification content, when the shade + * expansion completes. */ public float getStackEndHeight() { return mStackEndHeight; @@ -276,17 +277,18 @@ public class AmbientState implements Dumpable { } /** - * @see #getStackHeight() + * @return Height of the notification content returned by {@link #getStackEndHeight()}, but + * interpolated by the shade expansion fraction. */ - public void setStackHeight(float stackHeight) { - mStackHeight = stackHeight; + public float getInterpolatedStackHeight() { + return mStackHeight; } /** - * @return Height of notifications panel interpolated by the expansion fraction. + * @see #getInterpolatedStackHeight() */ - public float getStackHeight() { - return mStackHeight; + public void setInterpolatedStackHeight(float stackHeight) { + mStackHeight = stackHeight; } @Inject diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 1f767aa1cbbc..64d71240073f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -874,7 +874,7 @@ public class NotificationStackScrollLayout y = (int) (mAmbientState.getStackY()); drawDebugInfo(canvas, y, Color.CYAN, /* label= */ "mAmbientState.getStackY() = " + y); - y = (int) (mAmbientState.getStackY() + mAmbientState.getStackHeight()); + y = (int) (mAmbientState.getStackY() + mAmbientState.getInterpolatedStackHeight()); drawDebugInfo(canvas, y, Color.LTGRAY, /* label= */ "mAmbientState.getStackY() + mAmbientState.getStackHeight() = " + y); @@ -1123,11 +1123,13 @@ public class NotificationStackScrollLayout @Override public void addStackHeightChangedListener(@NonNull Runnable runnable) { + if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return; mStackHeightChangedListeners.addIfAbsent(runnable); } @Override public void removeStackHeightChangedListener(@NonNull Runnable runnable) { + if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return; mStackHeightChangedListeners.remove(runnable); } @@ -1233,7 +1235,6 @@ public class NotificationStackScrollLayout if (mAmbientState.getStackTop() != stackTop) { mAmbientState.setStackTop(stackTop); onTopPaddingChanged(/* animate = */ isAddOrRemoveAnimationPending()); - setExpandedHeight(mExpandedHeight); } } @@ -1476,7 +1477,7 @@ public class NotificationStackScrollLayout @VisibleForTesting public void updateStackEndHeightAndStackHeight(float fraction) { - final float oldStackHeight = mAmbientState.getStackHeight(); + final float oldStackHeight = mAmbientState.getInterpolatedStackHeight(); if (SceneContainerFlag.isEnabled()) { final float endHeight; if (!shouldSkipHeightUpdate()) { @@ -1484,20 +1485,20 @@ public class NotificationStackScrollLayout } else { endHeight = mAmbientState.getStackEndHeight(); } - updateStackHeight(endHeight, fraction); + updateInterpolatedStackHeight(endHeight, fraction); } else { if (mQsExpansionFraction <= 0 && !shouldSkipHeightUpdate()) { final float endHeight = updateStackEndHeight( getHeight(), getEmptyBottomMarginInternal(), getTopPadding()); - updateStackHeight(endHeight, fraction); + updateInterpolatedStackHeight(endHeight, fraction); } else { // Always updateStackHeight to prevent jumps in the stack height when this fraction // suddenly reapplies after a freeze. final float endHeight = mAmbientState.getStackEndHeight(); - updateStackHeight(endHeight, fraction); + updateInterpolatedStackHeight(endHeight, fraction); } } - if (oldStackHeight != mAmbientState.getStackHeight()) { + if (oldStackHeight != mAmbientState.getInterpolatedStackHeight()) { requestChildrenUpdate(); } } @@ -1531,7 +1532,7 @@ public class NotificationStackScrollLayout } @VisibleForTesting - public void updateStackHeight(float endHeight, float fraction) { + public void updateInterpolatedStackHeight(float endHeight, float fraction) { if (!newAodTransition()) { // During the (AOD<=>LS) transition where dozeAmount is changing, // apply dozeAmount to stack height instead of expansionFraction @@ -1541,7 +1542,7 @@ public class NotificationStackScrollLayout fraction = 1f - dozeAmount; } } - mAmbientState.setStackHeight( + mAmbientState.setInterpolatedStackHeight( MathUtils.lerp(endHeight * StackScrollAlgorithm.START_FRACTION, endHeight, fraction)); } @@ -1570,8 +1571,11 @@ public class NotificationStackScrollLayout // Update the expand progress between started/stopped events mAmbientState.setExpansionFraction(expandFraction); - // TODO(b/332577544): don't convert to height which then converts to the fraction again - setExpandedHeight(expandFraction * getHeight()); + + if (!shouldSkipHeightUpdate()) { + updateStackEndHeightAndStackHeight(expandFraction); + updateExpandedHeight(expandFraction); + } // expansion stopped event requires that the expandFraction has already been updated if (!nowExpanding && wasExpanding) { @@ -1580,6 +1584,19 @@ public class NotificationStackScrollLayout } } + private void updateExpandedHeight(float expandFraction) { + if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return; + float expandedHeight = expandFraction * getHeight(); + setIsExpanded(expandedHeight > 0); + + if (mExpandedHeight != expandedHeight) { + mExpandedHeight = expandedHeight; + updateAlgorithmHeightAndPadding(); + requestChildrenUpdate(); + notifyAppearChangedListeners(); + } + } + @Override public void setQsExpandFraction(float expandFraction) { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return; @@ -1592,6 +1609,7 @@ public class NotificationStackScrollLayout * @param height the expanded height of the panel */ public void setExpandedHeight(float height) { + SceneContainerFlag.assertInLegacyMode(); final boolean skipHeightUpdate = shouldSkipHeightUpdate(); updateStackPosition(); @@ -1723,6 +1741,7 @@ public class NotificationStackScrollLayout * Measured relative to the resting position. */ private float getExpandTranslationStart() { + SceneContainerFlag.assertInLegacyMode(); return -getTopPadding() + getMinExpansionHeight() - mShelf.getIntrinsicHeight(); } @@ -1731,6 +1750,7 @@ public class NotificationStackScrollLayout * Measured in absolute height. */ private float getAppearStartPosition() { + SceneContainerFlag.assertInLegacyMode(); if (isHeadsUpTransition()) { final NotificationSection firstVisibleSection = getFirstVisibleSection(); final int pinnedHeight = firstVisibleSection != null @@ -1786,6 +1806,7 @@ public class NotificationStackScrollLayout * have the shelf on its own) */ private float getAppearEndPosition() { + SceneContainerFlag.assertInLegacyMode(); if (FooterViewRefactor.isUnexpectedlyInLegacyMode()) { return getAppearEndPositionLegacy(); } @@ -1846,7 +1867,7 @@ public class NotificationStackScrollLayout */ @FloatRange(from = -1.0, to = 1.0) public float calculateAppearFraction(float height) { - if (isHeadsUpTransition()) { + if (isHeadsUpTransition() && !SceneContainerFlag.isEnabled()) { // HUN is a special case because fraction can go negative if swiping up. And for now // it must go negative as other pieces responsible for proper translation up assume // negative value for HUN going up. @@ -2522,10 +2543,33 @@ public class NotificationStackScrollLayout } @VisibleForTesting - void updateContentHeight() { + void updateStackHeight() { + if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return; + + final int shelfIntrinsicHeight = mShelf != null ? mShelf.getIntrinsicHeight() : 0; + final int footerIntrinsicHeight = + mFooterView != null ? mFooterView.getIntrinsicHeight() : 0; + final int notificationsHeight = (int) mNotificationStackSizeCalculator.computeHeight( + /* notificationStackScrollLayout= */ this, + mMaxDisplayedNotifications, + shelfIntrinsicHeight + ); + mIntrinsicContentHeight = notificationsHeight; + final int fullStackHeight = notificationsHeight + footerIntrinsicHeight + mBottomPadding; + if (mScrollViewFields.getIntrinsicStackHeight() != fullStackHeight) { + mScrollViewFields.setIntrinsicStackHeight(fullStackHeight); + notifyStackHeightChangedListeners(); + } + } + + private void updateContentHeight() { + if (SceneContainerFlag.isEnabled()) { + updateStackHeight(); + return; + } + final float scrimTopPadding = getScrimTopPaddingOrZero(); final int shelfIntrinsicHeight = mShelf != null ? mShelf.getIntrinsicHeight() : 0; - final int footerIntrinsicHeight = mFooterView != null ? mFooterView.getIntrinsicHeight() : 0; final float height = (int) scrimTopPadding + (int) mNotificationStackSizeCalculator.computeHeight( /* notificationStackScrollLayout= */ this, mMaxDisplayedNotifications, @@ -2536,19 +2580,15 @@ public class NotificationStackScrollLayout // state the maxPanelHeight and the contentHeight should be bigger mContentHeight = (int) (height + Math.max(getIntrinsicPadding(), getTopPadding()) + mBottomPadding); - mScrollViewFields.setIntrinsicStackHeight( - (int) (getIntrinsicPadding() + mIntrinsicContentHeight + footerIntrinsicHeight - + mBottomPadding)); updateScrollability(); clampScrollPosition(); updateStackPosition(); mAmbientState.setContentHeight(mContentHeight); - - notifyStackHeightChangedListeners(); } @Override public int getIntrinsicStackHeight() { + if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0; return mScrollViewFields.getIntrinsicStackHeight(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index 08d3e9f2b634..e112c99e19b3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -1408,6 +1408,7 @@ public class NotificationStackScrollLayoutController implements Dumpable { } public float calculateAppearFraction(float height) { + SceneContainerFlag.assertInLegacyMode(); return mView.calculateAppearFraction(height); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java index 0c2b5aeb6feb..ef1bcfc45879 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java @@ -575,7 +575,8 @@ public class StackScrollAlgorithm { final float shelfHeight = showingShelf ? ambientState.getShelf().getIntrinsicHeight() : 0f; final float scrimPadding = getScrimTopPaddingOrZero(ambientState); - final float stackHeight = ambientState.getStackHeight() - shelfHeight - scrimPadding; + final float stackHeight = + ambientState.getInterpolatedStackHeight() - shelfHeight - scrimPadding; final float stackEndHeight = ambientState.getStackEndHeight() - shelfHeight - scrimPadding; if (stackEndHeight == 0f) { // This should not happen, since even when the shade is empty we show EmptyShadeView @@ -734,7 +735,7 @@ public class StackScrollAlgorithm { || ambientState.getDozeAmount() == 1f || bypassPulseNotExpanding ? ambientState.getInnerHeight() - : ambientState.getStackHeight(); + : ambientState.getInterpolatedStackHeight(); final float shelfStart = stackBottom - ambientState.getShelf().getIntrinsicHeight() - mPaddingBetweenElements; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt index e4945fc6e847..1a1af2eecc00 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationShelfTest.kt @@ -342,7 +342,7 @@ open class NotificationShelfTest : SysuiTestCase() { val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) - whenever(ambientState.stackHeight).thenReturn(stackHeight) + whenever(ambientState.interpolatedStackHeight).thenReturn(stackHeight) val shelfTop = stackTop + stackHeight - shelf.height val stackScrollAlgorithmState = StackScrollAlgorithmState() val viewInShelf = mock(ExpandableView::class.java) @@ -378,7 +378,7 @@ open class NotificationShelfTest : SysuiTestCase() { val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) - whenever(ambientState.stackHeight).thenReturn(stackHeight) + whenever(ambientState.interpolatedStackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.isShadeExpanded).thenReturn(true) @@ -404,7 +404,7 @@ open class NotificationShelfTest : SysuiTestCase() { fun updateState_withNullLastVisibleBackgroundChild_hideShelf() { // GIVEN whenever(ambientState.stackY).thenReturn(100f) - whenever(ambientState.stackHeight).thenReturn(100f) + whenever(ambientState.interpolatedStackHeight).thenReturn(100f) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) val endOfStack = 200f + paddingBetweenElements @@ -433,7 +433,7 @@ open class NotificationShelfTest : SysuiTestCase() { val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) - whenever(ambientState.stackHeight).thenReturn(stackHeight) + whenever(ambientState.interpolatedStackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.isShadeExpanded).thenReturn(true) @@ -459,7 +459,7 @@ open class NotificationShelfTest : SysuiTestCase() { fun updateState_withNullFirstViewInShelf_hideShelf() { // GIVEN whenever(ambientState.stackY).thenReturn(100f) - whenever(ambientState.stackHeight).thenReturn(100f) + whenever(ambientState.interpolatedStackHeight).thenReturn(100f) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) val endOfStack = 200f + paddingBetweenElements @@ -488,7 +488,7 @@ open class NotificationShelfTest : SysuiTestCase() { val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) - whenever(ambientState.stackHeight).thenReturn(stackHeight) + whenever(ambientState.interpolatedStackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) val lastVisibleBackgroundChild = mock<ExpandableView>() @@ -514,7 +514,7 @@ open class NotificationShelfTest : SysuiTestCase() { fun updateState_withCollapsedShade_hideShelf() { // GIVEN whenever(ambientState.stackY).thenReturn(100f) - whenever(ambientState.stackHeight).thenReturn(100f) + whenever(ambientState.interpolatedStackHeight).thenReturn(100f) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) val endOfStack = 200f + paddingBetweenElements @@ -543,7 +543,7 @@ open class NotificationShelfTest : SysuiTestCase() { val stackTop = 200f val stackHeight = 800f whenever(ambientState.stackTop).thenReturn(stackTop) - whenever(ambientState.stackHeight).thenReturn(stackHeight) + whenever(ambientState.interpolatedStackHeight).thenReturn(stackHeight) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) whenever(ambientState.isShadeExpanded).thenReturn(true) @@ -583,7 +583,7 @@ open class NotificationShelfTest : SysuiTestCase() { fun updateState_withHiddenSectionBeforeShelf_hideShelf() { // GIVEN whenever(ambientState.stackY).thenReturn(100f) - whenever(ambientState.stackHeight).thenReturn(100f) + whenever(ambientState.interpolatedStackHeight).thenReturn(100f) val paddingBetweenElements = context.resources.getDimensionPixelSize(R.dimen.notification_divider_height) val endOfStack = 200f + paddingBetweenElements diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 8d1228ca5577..a18de68dfcfc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -245,26 +245,12 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { when(mStackSizeCalculator.computeHeight(eq(mStackScroller), anyInt(), anyFloat())) .thenReturn((float) stackHeight); - mStackScroller.updateContentHeight(); + mStackScroller.updateStackHeight(); assertThat(mStackScroller.getIntrinsicStackHeight()).isEqualTo(stackHeight); } @Test - @DisableSceneContainer - public void testIntrinsicStackHeight_includesTopScrimPadding() { - int stackHeight = 300; - int topScrimPadding = px(R.dimen.notification_side_paddings); - when(mStackSizeCalculator.computeHeight(eq(mStackScroller), anyInt(), anyFloat())) - .thenReturn((float) stackHeight); - - mStackScroller.updateContentHeight(); - - assertThat(mStackScroller.getIntrinsicStackHeight()) - .isEqualTo(stackHeight + topScrimPadding); - } - - @Test @DisableSceneContainer // TODO(b/312473478): address disabled test public void testUpdateStackHeight_qsExpansionZero() { final float expansionFraction = 0.2f; @@ -289,8 +275,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { endHeight * StackScrollAlgorithm.START_FRACTION, endHeight, expansionFraction); - mStackScroller.updateStackHeight(endHeight, expansionFraction); - assertThat(mAmbientState.getStackHeight()).isEqualTo(expected); + mStackScroller.updateInterpolatedStackHeight(endHeight, expansionFraction); + assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(expected); } @Test @@ -309,7 +295,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { // THEN stackHeight and stackEndHeight are the same verify(mAmbientState).setStackEndHeight(stackEndHeight); - verify(mAmbientState).setStackHeight(stackEndHeight); + verify(mAmbientState).setInterpolatedStackHeight(stackEndHeight); } @Test @@ -329,7 +315,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { // THEN stackHeight is changed by the expansion frac verify(mAmbientState).setStackEndHeight(stackEndHeight); - verify(mAmbientState).setStackHeight(stackEndHeight * 0.75f); + verify(mAmbientState).setInterpolatedStackHeight(stackEndHeight * 0.75f); } @Test @@ -349,7 +335,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { // THEN stackHeight is measured from the stack top verify(mAmbientState).setStackEndHeight(stackEndHeight); - verify(mAmbientState).setStackHeight(stackEndHeight); + verify(mAmbientState).setInterpolatedStackHeight(stackEndHeight); } @Test @@ -363,7 +349,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { clearInvocations(mAmbientState); mStackScroller.updateStackEndHeightAndStackHeight(1f); - verify(mAmbientState).setStackHeight(eq(300f)); + verify(mAmbientState).setInterpolatedStackHeight(eq(300f)); } @Test @@ -376,7 +362,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { clearInvocations(mAmbientState); mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); verify(mAmbientState, never()).setStackEndHeight(anyFloat()); - verify(mAmbientState).setStackHeight(anyFloat()); + verify(mAmbientState).setInterpolatedStackHeight(anyFloat()); } @Test @@ -391,14 +377,14 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { clearInvocations(mAmbientState); mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); verify(mAmbientState, never()).setStackEndHeight(anyFloat()); - verify(mAmbientState).setStackHeight(anyFloat()); + verify(mAmbientState).setInterpolatedStackHeight(anyFloat()); // Validate that when the animation ends the stackEndHeight is recalculated immediately clearInvocations(mAmbientState); mStackScroller.setPanelFlinging(false); verify(mAmbientState).setFlinging(eq(false)); verify(mAmbientState).setStackEndHeight(anyFloat()); - verify(mAmbientState).setStackHeight(anyFloat()); + verify(mAmbientState).setInterpolatedStackHeight(anyFloat()); } @Test @@ -440,6 +426,86 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { } @Test + @EnableSceneContainer + public void setExpandFraction_fullyCollapsed() { + // Given: NSSL has a height + when(mStackScroller.getHeight()).thenReturn(1200); + // And: stack bounds are set + float expandFraction = 0.0f; + float stackTop = 100; + float stackCutoff = 1100; + float stackHeight = stackCutoff - stackTop; + mStackScroller.setStackTop(stackTop); + mStackScroller.setStackCutoff(stackCutoff); + + // When: panel is fully collapsed + mStackScroller.setExpandFraction(expandFraction); + + // Then + assertThat(mAmbientState.getExpansionFraction()).isEqualTo(expandFraction); + assertThat(mAmbientState.isExpansionChanging()).isFalse(); + assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackHeight); + assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo( + stackHeight * StackScrollAlgorithm.START_FRACTION); + assertThat(mAmbientState.isShadeExpanded()).isFalse(); + assertThat(mStackScroller.getExpandedHeight()).isZero(); + } + + @Test + @EnableSceneContainer + public void setExpandFraction_expanding() { + // Given: NSSL has a height + when(mStackScroller.getHeight()).thenReturn(1200); + // And: stack bounds are set + float expandFraction = 0.6f; + float stackTop = 100; + float stackCutoff = 1100; + float stackHeight = stackCutoff - stackTop; + mStackScroller.setStackTop(stackTop); + mStackScroller.setStackCutoff(stackCutoff); + + // When: panel is expanding + mStackScroller.setExpandFraction(expandFraction); + + // Then + assertThat(mAmbientState.getExpansionFraction()).isEqualTo(expandFraction); + assertThat(mAmbientState.isExpansionChanging()).isTrue(); + assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackHeight); + assertThat(mAmbientState.getInterpolatedStackHeight()).isGreaterThan( + stackHeight * StackScrollAlgorithm.START_FRACTION); + assertThat(mAmbientState.getInterpolatedStackHeight()).isLessThan(stackHeight); + assertThat(mStackScroller.getExpandedHeight()).isGreaterThan(0f); + assertThat(mAmbientState.isShadeExpanded()).isTrue(); + } + + @Test + @EnableSceneContainer + public void setExpandFraction_fullyExpanded() { + // Given: NSSL has a height + int viewHeight = 1200; + when(mStackScroller.getHeight()).thenReturn(viewHeight); + // And: stack bounds are set + float expandFraction = 1.0f; + float stackTop = 100; + float stackCutoff = 1100; + float stackHeight = stackCutoff - stackTop; + mStackScroller.setStackTop(stackTop); + mStackScroller.setStackCutoff(stackCutoff); + + // When: panel is fully expanded + mStackScroller.setExpandFraction(expandFraction); + + // Then + assertThat(mAmbientState.getExpansionFraction()).isEqualTo(expandFraction); + assertThat(mAmbientState.isExpansionChanging()).isFalse(); + assertThat(mAmbientState.getStackEndHeight()).isEqualTo(stackHeight); + assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(stackHeight); + assertThat(mStackScroller.getExpandedHeight()).isEqualTo(viewHeight); + assertThat(mAmbientState.isShadeExpanded()).isTrue(); + } + + @Test + @DisableSceneContainer public void testSetExpandedHeight_listenerReceivedCallbacks() { final float expectedHeight = 0f; @@ -466,6 +532,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { } @Test + @DisableSceneContainer public void testSetExpandedHeight_withSplitShade_doesntInterpolateStackHeight() { mTestableResources .addOverride(R.bool.config_use_split_notification_shade, /* value= */ true); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt index 7e790197ccd1..3e8bf4792f02 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt @@ -1114,6 +1114,7 @@ class StackScrollAlgorithmTest : SysuiTestCase() { } @Test + @DisableSceneContainer fun shadeOpened_hunDoesNotOverlapQQS_hunShouldHaveNoShadow() { // Given: shade is opened, yTranslation of HUN is equal to QQS Panel's height, // the height of HUN is equal to the height of QQS Panel, @@ -1144,6 +1145,7 @@ class StackScrollAlgorithmTest : SysuiTestCase() { } @Test + @DisableSceneContainer fun shadeClosed_hunShouldHaveFullShadow() { // Given: shade is closed, ambientState.stackTranslation == -ambientState.topPadding, // the height of HUN is equal to the height of QQS Panel, @@ -1172,6 +1174,7 @@ class StackScrollAlgorithmTest : SysuiTestCase() { } @Test + @DisableSceneContainer fun draggingHunToOpenShade_hunShouldHavePartialShadow() { // Given: shade is closed when HUN pops up, // now drags down the HUN to open shade @@ -1447,7 +1450,7 @@ class StackScrollAlgorithmTest : SysuiTestCase() { // set stackEndHeight and stackHeight // ExpansionFractionWithoutShelf == stackHeight / stackEndHeight ambientState.stackEndHeight = 100f - ambientState.stackHeight = ambientState.stackEndHeight * fraction + ambientState.interpolatedStackHeight = ambientState.stackEndHeight * fraction } private fun resetViewStates_hunYTranslationIs(expected: Float) { @@ -1531,7 +1534,7 @@ class StackScrollAlgorithmTest : SysuiTestCase() { // shade is fully open ambientState.expansionFraction = 1.0f with(fullStackHeight) { - ambientState.stackHeight = this + ambientState.interpolatedStackHeight = this ambientState.stackEndHeight = this } stackScrollAlgorithm.setIsExpanded(true) |