Merge "Remove divider height before first view in shade" into tm-dev am: 96aa1654b4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18379905

Change-Id: Ia549688b8b21d18736d375b4de7680ab5880f81e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Lyn Han
2022-06-01 17:57:08 +00:00
committed by Automerger Merge Worker
2 changed files with 21 additions and 17 deletions

View File

@@ -58,7 +58,7 @@ constructor(
private var maxKeyguardNotifications by notNull<Int>() private var maxKeyguardNotifications by notNull<Int>()
/** Minimum space between two notifications, see [calculateGapAndDividerHeight]. */ /** Minimum space between two notifications, see [calculateGapAndDividerHeight]. */
private var dividerHeight by notNull<Int>() private var dividerHeight by notNull<Float>()
init { init {
updateResources() updateResources()
@@ -142,9 +142,13 @@ constructor(
if (i == children.lastIndex) { if (i == children.lastIndex) {
0f // No shelf needed. 0f // No shelf needed.
} else { } else {
val firstViewInShelfIndex = i + 1
val spaceBeforeShelf = val spaceBeforeShelf =
calculateGapAndDividerHeight( calculateGapAndDividerHeight(
stack, previous = currentNotification, current = children[i + 1], i) stack,
previous = currentNotification,
current = children[firstViewInShelfIndex],
currentIndex = firstViewInShelfIndex)
spaceBeforeShelf + shelfIntrinsicHeight spaceBeforeShelf + shelfIntrinsicHeight
} }
@@ -156,16 +160,17 @@ constructor(
maxKeyguardNotifications = maxKeyguardNotifications =
infiniteIfNegative(resources.getInteger(R.integer.keyguard_max_notification_count)) 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> private val NotificationStackScrollLayout.childrenSequence: Sequence<ExpandableView>
get() = children.map { it as ExpandableView } get() = children.map { it as ExpandableView }
@VisibleForTesting @VisibleForTesting
fun onLockscreen() : Boolean { fun onLockscreen(): Boolean {
return statusBarStateController.state == KEYGUARD return statusBarStateController.state == KEYGUARD &&
&& lockscreenShadeTransitionController.fractionToShade == 0f lockscreenShadeTransitionController.fractionToShade == 0f
} }
@VisibleForTesting @VisibleForTesting
@@ -207,11 +212,12 @@ constructor(
stack: NotificationStackScrollLayout, stack: NotificationStackScrollLayout,
previous: ExpandableView?, previous: ExpandableView?,
current: ExpandableView?, current: ExpandableView?,
visibleIndex: Int currentIndex: Int
): Float { ): Float {
var height = stack.calculateGapHeight(previous, current, visibleIndex) if (currentIndex == 0) {
height += dividerHeight return 0f
return height }
return stack.calculateGapHeight(previous, current, currentIndex) + dividerHeight
} }
private fun NotificationStackScrollLayout.showableChildren() = private fun NotificationStackScrollLayout.showableChildren() =

View File

@@ -125,8 +125,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
// Each row in separate section. // Each row in separate section.
setGapHeight(gapHeight) setGapHeight(gapHeight)
val spaceUsed = val spaceUsed =
listOf( listOf(rowHeight,
dividerHeight + rowHeight,
dividerHeight + gapHeight + rowHeight, dividerHeight + gapHeight + rowHeight,
dividerHeight + gapHeight + shelfHeight) dividerHeight + gapHeight + shelfHeight)
.sum() .sum()
@@ -149,9 +148,8 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
val rowHeight = rowHeight val rowHeight = rowHeight
val shelfHeight = shelfHeight val shelfHeight = shelfHeight
val spaceUsed = val spaceUsed =
listOf( listOf(rowHeight,
dividerHeight + rowHeight, dividerHeight + shelfHeight)
dividerHeight + shelfHeight)
.sum() .sum()
val availableSpace = spaceUsed + 1 val availableSpace = spaceUsed + 1
val rows = listOf(createMockRow(rowHeight), createMockRow(rowHeight)) val rows = listOf(createMockRow(rowHeight), createMockRow(rowHeight))
@@ -195,7 +193,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0, val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0,
previousView = null, stack = stackLayout, onLockscreen = true) previousView = null, stack = stackLayout, onLockscreen = true)
assertThat(space).isEqualTo(5 + dividerHeight) assertThat(space).isEqualTo(5)
} }
@Test @Test
@@ -209,7 +207,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0, val space = sizeCalculator.spaceNeeded(expandableView, visibleIndex = 0,
previousView = null, stack = stackLayout, onLockscreen = false) previousView = null, stack = stackLayout, onLockscreen = false)
assertThat(space).isEqualTo(10 + dividerHeight) assertThat(space).isEqualTo(10)
} }
private fun computeMaxKeyguardNotifications( private fun computeMaxKeyguardNotifications(