Bug 1940764 - Correctly place the download complete dialog when the snap animation ends r=android-reviewers,harrisono

Differential Revision: https://phabricator.services.mozilla.com/D233671
This commit is contained in:
Mugurell
2025-01-29 07:39:50 +00:00
parent 8bf826d432
commit bf5095cdbf
2 changed files with 8 additions and 6 deletions

View File

@@ -188,17 +188,13 @@ class DynamicDownloadDialogBehavior<V : View>(
object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
// Ensure the right translationY if the anchor changes during the animation
dynamicDownload.translationY = -anchorHeight.toFloat()
child.translationY = computeTranslation(direction)
}
},
)
setFloatValues(
child.translationY,
if (direction == SnapDirection.UP) {
-anchorHeight.toFloat()
} else {
child.height.toFloat() + anchorHeight
},
computeTranslation(direction),
)
start()
}
@@ -213,4 +209,9 @@ class DynamicDownloadDialogBehavior<V : View>(
possibleAnchors
.intersect(root.children.filter { it.isVisible && it.height > 0 }.map { it.id }.toSet()).firstOrNull()
?.let { root.findViewById<View>(it) }
private fun computeTranslation(scrollDirection: SnapDirection) = when (scrollDirection) {
SnapDirection.UP -> -anchorHeight.toFloat()
SnapDirection.DOWN -> dynamicDownload.height.toFloat() + anchorHeight
}
}

View File

@@ -128,6 +128,7 @@ class DynamicDownloadDialogBehaviorTest {
behavior.anchor = mockk<View> {
every { height } returns 10
}
every { downloadDialog.height } returns 20
val animator: ValueAnimator = mockk(relaxed = true)
behavior.snapAnimator = animator