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>()
/** Minimum space between two notifications, see [calculateGapAndDividerHeight]. */
private var dividerHeight by notNull<Int>()
private var dividerHeight by notNull<Float>()
init {
updateResources()
@@ -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
}
@@ -156,16 +160,17 @@ 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>
get() = children.map { it as ExpandableView }
@VisibleForTesting
fun onLockscreen() : Boolean {
return statusBarStateController.state == KEYGUARD
&& lockscreenShadeTransitionController.fractionToShade == 0f
fun onLockscreen(): Boolean {
return statusBarStateController.state == KEYGUARD &&
lockscreenShadeTransitionController.fractionToShade == 0f
}
@VisibleForTesting
@@ -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() =

View File

@@ -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()
@@ -149,9 +148,8 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
val rowHeight = rowHeight
val shelfHeight = shelfHeight
val spaceUsed =
listOf(
dividerHeight + rowHeight,
dividerHeight + shelfHeight)
listOf(rowHeight,
dividerHeight + shelfHeight)
.sum()
val availableSpace = spaceUsed + 1
val rows = listOf(createMockRow(rowHeight), createMockRow(rowHeight))
@@ -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
@@ -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(