Merge changes from topics "presubmit-am-121da4597331411b86c0a3f45eabcc4c", "presubmit-am-85bb9a360df04e4fa2dd6536bf36fa36" into tm-dev am: e5d0c2d25a

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

Change-Id: I064cb21a25b506fa6d37e42a7785f9c58a997157
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Lyn Han
2022-04-09 01:37:38 +00:00
committed by Automerger Merge Worker

View File

@@ -52,7 +52,7 @@ constructor(
private var maxKeyguardNotifications by notNull<Int>()
/**
* Minimum space between two notifications. There might be more space, see [calculateGapHeight].
* Minimum space between two notifications, see [calculateGapAndDividerHeight].
*/
private var dividerHeight by notNull<Int>()
@@ -84,16 +84,20 @@ constructor(
val onLockscreen = true
val showableRows = children.filter { it.isShowable(onLockscreen) }
val showableRowsCount = showableRows.count()
log { "\tshowableRowsCount=$showableRowsCount "}
showableRows.forEachIndexed { i, current ->
val spaceNeeded = current.spaceNeeded(count, previous, stack, onLockscreen)
val spaceAfter = remainingSpace - spaceNeeded
previous = current
log { "\ti=$i spaceNeeded=$spaceNeeded remainingSpace=$remainingSpace" }
log { "\ti=$i spaceNeeded=$spaceNeeded remainingSpace=$remainingSpace " +
"spaceAfter=$spaceAfter" }
if (remainingSpace - spaceNeeded >= 0 && count < maxKeyguardNotifications) {
count += 1
remainingSpace -= spaceNeeded
} else if (remainingSpace - spaceNeeded > -shelfHeight && i == showableRowsCount - 1) {
log { "Showing all notifications. Shelf is not be needed." }
log { "Show all notifications. Shelf not needed." }
// If this is the last one, and it fits using the space shelf would use, then we can
// display it, as the shelf will not be needed (as all notifications are shown).
return count + 1
@@ -139,8 +143,7 @@ constructor(
height += spaceNeeded
count += 1
} else {
val gapBeforeFirstViewInShelf = current.calculateGapHeight(stack, previous, count)
height += gapBeforeFirstViewInShelf
height += current.calculateGapAndDividerHeight(stack, previous, count)
height += shelfHeight
log { "returning height with shelf -> $height" }
return height
@@ -177,12 +180,7 @@ constructor(
} else {
intrinsicHeight.toFloat()
}
if (visibleIndex != 0) {
size += dividerHeight
}
val gapHeight = calculateGapHeight(stack, previousView, visibleIndex)
log { "\ti=$visibleIndex gapHeight=$gapHeight"}
size += gapHeight
size += calculateGapAndDividerHeight(stack, previousView, visibleIndex)
return size
}
@@ -202,11 +200,17 @@ constructor(
return true
}
private fun ExpandableView.calculateGapHeight(
private fun ExpandableView.calculateGapAndDividerHeight(
stack: NotificationStackScrollLayout,
previous: ExpandableView?,
visibleIndex: Int
) = stack.calculateGapHeight(previous, /* current= */ this, visibleIndex)
) : Float {
var height = stack.calculateGapHeight(previous, /* current= */ this, visibleIndex)
if (visibleIndex != 0) {
height += dividerHeight
}
return height
}
/**
* Can a view be shown on the lockscreen when calculating the number of allowed notifications to