Rename notification padding to divider height

Bug: 227107113
Test: NotificationStackSizeCalculatorTest
Change-Id: I6246da9af9b9d565f07a48655f68add011d1f488
This commit is contained in:
Lyn Han
2022-04-05 13:40:22 -04:00
parent a6713ec97e
commit d73fe9b586
2 changed files with 9 additions and 9 deletions

View File

@@ -54,7 +54,7 @@ constructor(
/** /**
* Minimum space between two notifications. There might be more space, see [calculateGapHeight]. * Minimum space between two notifications. There might be more space, see [calculateGapHeight].
*/ */
private var notificationPadding by notNull<Int>() private var dividerHeight by notNull<Int>()
init { init {
updateResources() updateResources()
@@ -155,7 +155,7 @@ constructor(
maxKeyguardNotifications = maxKeyguardNotifications =
infiniteIfNegative(resources.getInteger(R.integer.keyguard_max_notification_count)) infiniteIfNegative(resources.getInteger(R.integer.keyguard_max_notification_count))
notificationPadding = dividerHeight =
max(1, resources.getDimensionPixelSize(R.dimen.notification_divider_height)) max(1, resources.getDimensionPixelSize(R.dimen.notification_divider_height))
} }
@@ -178,7 +178,7 @@ constructor(
intrinsicHeight.toFloat() intrinsicHeight.toFloat()
} }
if (visibleIndex != 0) { if (visibleIndex != 0) {
size += notificationPadding size += dividerHeight
} }
val gapHeight = calculateGapHeight(stack, previousView, visibleIndex) val gapHeight = calculateGapHeight(stack, previousView, visibleIndex)
log { "\ti=$visibleIndex gapHeight=$gapHeight"} log { "\ti=$visibleIndex gapHeight=$gapHeight"}

View File

@@ -57,7 +57,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
.thenReturn(GAP_HEIGHT) .thenReturn(GAP_HEIGHT)
with(testableResources) { with(testableResources) {
addOverride(R.integer.keyguard_max_notification_count, -1) addOverride(R.integer.keyguard_max_notification_count, -1)
addOverride(R.dimen.notification_divider_height, NOTIFICATION_PADDING.toInt()) addOverride(R.dimen.notification_divider_height, DIVIDER_HEIGHT.toInt())
} }
sizeCalculator = sizeCalculator =
@@ -109,7 +109,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
fun computeMaxKeyguardNotifications_spaceForOne_shelfUsableForLastNotification_returnsTwo() { fun computeMaxKeyguardNotifications_spaceForOne_shelfUsableForLastNotification_returnsTwo() {
val rowHeight = ROW_HEIGHT val rowHeight = ROW_HEIGHT
val totalSpaceForEachRow = GAP_HEIGHT + rowHeight val totalSpaceForEachRow = GAP_HEIGHT + rowHeight
val shelfHeight = totalSpaceForEachRow + NOTIFICATION_PADDING val shelfHeight = totalSpaceForEachRow + DIVIDER_HEIGHT
val spaceForOne = totalSpaceForEachRow val spaceForOne = totalSpaceForEachRow
val rows = val rows =
listOf( listOf(
@@ -127,7 +127,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
fun computeMaxKeyguardNotifications_spaceForTwo_returnsTwo() { fun computeMaxKeyguardNotifications_spaceForTwo_returnsTwo() {
val rowHeight = ROW_HEIGHT val rowHeight = ROW_HEIGHT
val totalSpaceForEachRow = GAP_HEIGHT + rowHeight val totalSpaceForEachRow = GAP_HEIGHT + rowHeight
val spaceForTwo = totalSpaceForEachRow * 2 + NOTIFICATION_PADDING val spaceForTwo = totalSpaceForEachRow * 2 + DIVIDER_HEIGHT
val rows = val rows =
listOf( listOf(
createMockRow(rowHeight), createMockRow(rowHeight),
@@ -143,7 +143,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
fun computeHeight_returnsAtMostSpaceAvailable_withGapBeforeShelf() { fun computeHeight_returnsAtMostSpaceAvailable_withGapBeforeShelf() {
val rowHeight = ROW_HEIGHT val rowHeight = ROW_HEIGHT
val shelfHeight = SHELF_HEIGHT val shelfHeight = SHELF_HEIGHT
val totalSpaceForEachRow = GAP_HEIGHT + rowHeight + NOTIFICATION_PADDING val totalSpaceForEachRow = GAP_HEIGHT + rowHeight + DIVIDER_HEIGHT
val availableSpace = totalSpaceForEachRow * 2 val availableSpace = totalSpaceForEachRow * 2
// All rows in separate sections (default setup). // All rows in separate sections (default setup).
@@ -164,7 +164,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
fun computeHeight_returnsAtMostSpaceAvailable_noGapBeforeShelf() { fun computeHeight_returnsAtMostSpaceAvailable_noGapBeforeShelf() {
val rowHeight = ROW_HEIGHT val rowHeight = ROW_HEIGHT
val shelfHeight = SHELF_HEIGHT val shelfHeight = SHELF_HEIGHT
val totalSpaceForEachRow = GAP_HEIGHT + rowHeight + NOTIFICATION_PADDING val totalSpaceForEachRow = GAP_HEIGHT + rowHeight + DIVIDER_HEIGHT
val availableSpace = totalSpaceForEachRow * 1 val availableSpace = totalSpaceForEachRow * 1
// Both rows are in the same section. // Both rows are in the same section.
@@ -223,7 +223,7 @@ class NotificationStackSizeCalculatorTest : SysuiTestCase() {
/** Default dimensions for tests that don't overwrite them. */ /** Default dimensions for tests that don't overwrite them. */
companion object { companion object {
const val GAP_HEIGHT = 12f const val GAP_HEIGHT = 12f
const val NOTIFICATION_PADDING = 3f const val DIVIDER_HEIGHT = 3f
const val SHELF_HEIGHT = 14f const val SHELF_HEIGHT = 14f
const val ROW_HEIGHT = SHELF_HEIGHT * 3 const val ROW_HEIGHT = SHELF_HEIGHT * 3
} }