Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt +16 −10 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ constructor( private var maxKeyguardNotifications by notNull<Int>() /** Minimum space between two notifications, see [calculateGapAndDividerHeight]. */ private var dividerHeight by notNull<Int>() private var dividerHeight by notNull<Float>() init { updateResources() Loading Loading @@ -142,9 +142,13 @@ constructor( if (i == children.lastIndex) { 0f // No shelf needed. } else { val firstViewInShelfIndex = i + 1 val spaceBeforeShelf = calculateGapAndDividerHeight( stack, previous = currentNotification, current = children[i + 1], i) stack, previous = currentNotification, current = children[firstViewInShelfIndex], currentIndex = firstViewInShelfIndex) spaceBeforeShelf + shelfIntrinsicHeight } Loading @@ -156,7 +160,8 @@ constructor( maxKeyguardNotifications = infiniteIfNegative(resources.getInteger(R.integer.keyguard_max_notification_count)) dividerHeight = max(1, resources.getDimensionPixelSize(R.dimen.notification_divider_height)) dividerHeight = max(1f, resources.getDimensionPixelSize(R.dimen.notification_divider_height).toFloat()) } private val NotificationStackScrollLayout.childrenSequence: Sequence<ExpandableView> Loading @@ -164,8 +169,8 @@ constructor( @VisibleForTesting fun onLockscreen(): Boolean { return statusBarStateController.state == KEYGUARD && lockscreenShadeTransitionController.fractionToShade == 0f return statusBarStateController.state == KEYGUARD && lockscreenShadeTransitionController.fractionToShade == 0f } @VisibleForTesting Loading Loading @@ -207,11 +212,12 @@ constructor( stack: NotificationStackScrollLayout, previous: ExpandableView?, current: ExpandableView?, visibleIndex: Int currentIndex: Int ): Float { var height = stack.calculateGapHeight(previous, current, visibleIndex) height += dividerHeight return height if (currentIndex == 0) { return 0f } return stack.calculateGapHeight(previous, current, currentIndex) + dividerHeight } private fun NotificationStackScrollLayout.showableChildren() = Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculatorTest.kt +5 −7 Original line number Diff line number Diff line Loading @@ -125,8 +125,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() { // Each row in separate section. setGapHeight(gapHeight) val spaceUsed = listOf( dividerHeight + rowHeight, listOf(rowHeight, dividerHeight + gapHeight + rowHeight, dividerHeight + gapHeight + shelfHeight) .sum() Loading @@ -149,8 +148,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() { val rowHeight = rowHeight val shelfHeight = shelfHeight val spaceUsed = listOf( dividerHeight + rowHeight, listOf(rowHeight, dividerHeight + shelfHeight) .sum() val availableSpace = spaceUsed + 1 Loading Loading @@ -195,7 +193,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() { val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0, previousView = null, stack = stackLayout, onLockscreen = true) assertThat(space).isEqualTo(5 + dividerHeight) assertThat(space).isEqualTo(5) } @Test Loading @@ -209,7 +207,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() { val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0, previousView = null, stack = stackLayout, onLockscreen = false) assertThat(space).isEqualTo(10 + dividerHeight) assertThat(space).isEqualTo(10) } private fun computeMaxKeyguardNotifications( Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculator.kt +16 −10 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ constructor( private var maxKeyguardNotifications by notNull<Int>() /** Minimum space between two notifications, see [calculateGapAndDividerHeight]. */ private var dividerHeight by notNull<Int>() private var dividerHeight by notNull<Float>() init { updateResources() Loading Loading @@ -142,9 +142,13 @@ constructor( if (i == children.lastIndex) { 0f // No shelf needed. } else { val firstViewInShelfIndex = i + 1 val spaceBeforeShelf = calculateGapAndDividerHeight( stack, previous = currentNotification, current = children[i + 1], i) stack, previous = currentNotification, current = children[firstViewInShelfIndex], currentIndex = firstViewInShelfIndex) spaceBeforeShelf + shelfIntrinsicHeight } Loading @@ -156,7 +160,8 @@ constructor( maxKeyguardNotifications = infiniteIfNegative(resources.getInteger(R.integer.keyguard_max_notification_count)) dividerHeight = max(1, resources.getDimensionPixelSize(R.dimen.notification_divider_height)) dividerHeight = max(1f, resources.getDimensionPixelSize(R.dimen.notification_divider_height).toFloat()) } private val NotificationStackScrollLayout.childrenSequence: Sequence<ExpandableView> Loading @@ -164,8 +169,8 @@ constructor( @VisibleForTesting fun onLockscreen(): Boolean { return statusBarStateController.state == KEYGUARD && lockscreenShadeTransitionController.fractionToShade == 0f return statusBarStateController.state == KEYGUARD && lockscreenShadeTransitionController.fractionToShade == 0f } @VisibleForTesting Loading Loading @@ -207,11 +212,12 @@ constructor( stack: NotificationStackScrollLayout, previous: ExpandableView?, current: ExpandableView?, visibleIndex: Int currentIndex: Int ): Float { var height = stack.calculateGapHeight(previous, current, visibleIndex) height += dividerHeight return height if (currentIndex == 0) { return 0f } return stack.calculateGapHeight(previous, current, currentIndex) + dividerHeight } private fun NotificationStackScrollLayout.showableChildren() = Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackSizeCalculatorTest.kt +5 −7 Original line number Diff line number Diff line Loading @@ -125,8 +125,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() { // Each row in separate section. setGapHeight(gapHeight) val spaceUsed = listOf( dividerHeight + rowHeight, listOf(rowHeight, dividerHeight + gapHeight + rowHeight, dividerHeight + gapHeight + shelfHeight) .sum() Loading @@ -149,8 +148,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() { val rowHeight = rowHeight val shelfHeight = shelfHeight val spaceUsed = listOf( dividerHeight + rowHeight, listOf(rowHeight, dividerHeight + shelfHeight) .sum() val availableSpace = spaceUsed + 1 Loading Loading @@ -195,7 +193,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() { val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0, previousView = null, stack = stackLayout, onLockscreen = true) assertThat(space).isEqualTo(5 + dividerHeight) assertThat(space).isEqualTo(5) } @Test Loading @@ -209,7 +207,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() { val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0, previousView = null, stack = stackLayout, onLockscreen = false) assertThat(space).isEqualTo(10 + dividerHeight) assertThat(space).isEqualTo(10) } private fun computeMaxKeyguardNotifications( Loading