Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt +12 −3 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt +12 −3 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading