Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c21f5c58 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed an issue where offsets of animations could get stuck

This would lead to overlapping children.
When group notificaitons are added to their parents, all
running animations are cancelled. Since we're now animating
offsets and never again set such offsets unless we animate,
We could get stuck with such an offset, continuously added
to the regular translation.
We now always reset the offset to 0 when ending it as that
seems to be the safest thing to do

Fixes: 402273107
Flag: com.android.systemui.physical_notification_movement
Test: atest SystemUiTests
Change-Id: Ie2494395549a9329252331a4fa167381550d90a7
parent c9ac36a5
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -206,6 +206,21 @@ class PhysicsPropertyAnimatorTest : SysuiTestCase() {
        Mockito.verify(finishListener!!).onAnimationEnd(any(), any(), any(), any())
    }

    @Test
    fun testCancelAnimationResetsOffset() {
        PhysicsPropertyAnimator.setProperty(
            view,
            property,
            200f,
            animationProperties,
            true,
            finishListener,
        )
        val propertyData = ViewState.getChildTag(view, property.tag) as PropertyData
        propertyData.animator?.cancel()
        Assert.assertTrue(propertyData.offset == 0f)
    }

    @Test
    fun testUsingListenerProperties() {
        val finishListener2 = Mockito.mock(DynamicAnimation.OnAnimationEndListener::class.java)
+4 −0
Original line number Diff line number Diff line
@@ -157,6 +157,10 @@ private fun startAnimation(
        animator.addEndListener { _, _, _, _ ->
            propertyData.animator = null
            propertyData.doubleOvershootAvoidingListener = null
            // Let's make sure we never get stuck with an offset even when canceling
            // We never actually cancel running animations but keep it around, so this only
            // triggers if things really should end.
            propertyData.offset = 0f
        }
    }
    if (animatableProperty.avoidDoubleOvershoot