diff options
2 files changed, 13 insertions, 4 deletions
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 b801e5d89b84..b52048b854d3 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 @@ -1066,7 +1066,7 @@ public class StackScrollAlgorithm { private void clampHunToMaxTranslation(float headsUpTop, float headsUpBottom, ExpandableViewState viewState) { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return; - final float maxHeight = headsUpTop - headsUpBottom; + final float maxHeight = Math.max(0f, headsUpBottom - headsUpTop); viewState.setYTranslation(Math.min(headsUpTop, viewState.getYTranslation())); viewState.height = (int) Math.min(maxHeight, viewState.height); } 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 b7ebebec7ca7..c2622db1cbb1 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 @@ -279,16 +279,23 @@ class StackScrollAlgorithmTest : SysuiTestCase() { fun resetViewStates_defaultHun_showingQS_hunTranslatedToHeadsUpTop() { // Given: the shade is open and scrolled to the bottom to show the QuickSettings val headsUpTop = 2000f + val intrinsicHunHeight = 300 fakeHunInShade( headsUpTop = headsUpTop, stackTop = 2600f, // stack scrolled below the screen stackCutoff = 4000f, collapsedHeight = 100, - intrinsicHeight = 300 + intrinsicHeight = intrinsicHunHeight, ) whenever(notificationRow.isAboveShelf).thenReturn(true) - resetViewStates_hunYTranslationIs(headsUpTop) + // When + stackScrollAlgorithm.resetViewStates(ambientState, 0) + + // Then: HUN is translated to the headsUpTop + assertThat(notificationRow.viewState.yTranslation).isEqualTo(headsUpTop) + // And: HUN maintained its full height + assertThat(notificationRow.viewState.height).isEqualTo(intrinsicHunHeight) } @Test @@ -1419,14 +1426,16 @@ class StackScrollAlgorithmTest : SysuiTestCase() { /** fakes the notification row under test, to be a HUN in a fully opened shade */ private fun fakeHunInShade( - headsUpTop: Float, collapsedHeight: Int, intrinsicHeight: Int, + headsUpTop: Float, + headsUpBottom: Float = headsUpTop + intrinsicHeight, // assume all the space available stackTop: Float, stackCutoff: Float = 2000f, fullStackHeight: Float = 3000f ) { ambientState.headsUpTop = headsUpTop + ambientState.headsUpBottom = headsUpBottom ambientState.stackTop = stackTop ambientState.stackCutoff = stackCutoff |