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

Commit e0ee4f07 authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge changes I271ca252,I585d70c8 into main

* changes:
  Remove unused methods from ActivatableNotificationView
  Remove the NotificationsImprovedHunAnimation flag
parents b1b11e0d cce0bd95
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -155,13 +155,6 @@ flag {
    bug: "293824309"
}

flag {
    name: "notifications_improved_hun_animation"
    namespace: "systemui"
    description: "Adds a translateY animation, and other improvements to match the motion specs of the HUN Intro + Outro animations."
    bug: "243302608"
}

flag {
    name: "notification_content_alpha_optimization"
    namespace: "systemui"
+5 −58
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ package com.android.systemui.statusbar.notification.stack
import android.annotation.DimenRes
import android.content.pm.PackageManager
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import android.widget.FrameLayout
import androidx.test.filters.SmallTest
@@ -30,7 +29,6 @@ import com.android.systemui.statusbar.notification.footer.ui.view.FooterView.Foo
import com.android.systemui.statusbar.notification.headsup.AvalancheController
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.google.common.truth.Expect
import com.google.common.truth.Truth.assertThat
@@ -152,22 +150,6 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {
        resetViewStates_hunYTranslationIs(headsUpTop)
    }

    @Test
    @DisableSceneContainer
    fun resetViewStates_defaultHun_yTranslationIsInset() {
        whenever(notificationRow.isPinned).thenReturn(true)
        whenever(notificationRow.isHeadsUp).thenReturn(true)
        resetViewStates_hunYTranslationIs(stackScrollAlgorithm.mHeadsUpInset)
    }

    @Test
    @DisableSceneContainer
    fun resetViewStates_defaultHunWithStackMargin_changesHunYTranslation() {
        whenever(notificationRow.isPinned).thenReturn(true)
        whenever(notificationRow.isHeadsUp).thenReturn(true)
        resetViewStates_stackMargin_changesHunYTranslation()
    }

    @Test
    @DisableSceneContainer
    fun resetViewStates_defaultHunWhenShadeIsOpening_yTranslationIsInset() {
@@ -183,24 +165,7 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {

    @Test
    @DisableSceneContainer
    @DisableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_hunAnimatingAway_yTranslationIsInset() {
        whenever(notificationRow.isHeadsUpAnimatingAway).thenReturn(true)
        resetViewStates_hunYTranslationIs(stackScrollAlgorithm.mHeadsUpInset)
    }

    @Test
    @DisableSceneContainer
    @DisableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_hunAnimatingAway_StackMarginChangesHunYTranslation() {
        whenever(notificationRow.isHeadsUpAnimatingAway).thenReturn(true)
        resetViewStates_stackMargin_changesHunYTranslation()
    }

    @Test
    @DisableSceneContainer
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_defaultHun_newHeadsUpAnim_yTranslationIsInset() {
    fun resetViewStates_defaultHun_yTranslationIsInset() {
        whenever(notificationRow.isPinned).thenReturn(true)
        whenever(notificationRow.isHeadsUp).thenReturn(true)
        resetViewStates_hunYTranslationIs(stackScrollAlgorithm.mHeadsUpInset)
@@ -208,8 +173,7 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {

    @Test
    @DisableSceneContainer
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_defaultHunWithStackMargin_newHeadsUpAnim_changesHunYTranslation() {
    fun resetViewStates_defaultHunWithStackMargin_changesHunYTranslation() {
        whenever(notificationRow.isPinned).thenReturn(true)
        whenever(notificationRow.isHeadsUp).thenReturn(true)
        resetViewStates_stackMargin_changesHunYTranslation()
@@ -399,8 +363,7 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {

    @Test
    @DisableSceneContainer
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_defaultHun_showingQS_newHeadsUpAnim_hunTranslatedToMax() {
    fun resetViewStates_defaultHun_showingQS_hunTranslatedToMax() {
        // Given: the shade is open and scrolled to the bottom to show the QuickSettings
        val maxHunTranslation = 2000f
        ambientState.maxHeadsUpTranslation = maxHunTranslation
@@ -416,8 +379,7 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {

    @Test
    @DisableSceneContainer
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_hunAnimatingAway_showingQS_newHeadsUpAnim_hunTranslatedToBottomOfScreen() {
    fun resetViewStates_hunAnimatingAway_showingQS_hunTranslatedToBottomOfScreen() {
        // Given: the shade is open and scrolled to the bottom to show the QuickSettings
        val bottomOfScreen = 2600f
        val maxHunTranslation = 2000f
@@ -437,8 +399,7 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {
    }

    @Test
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_hunAnimatingAway_newHeadsUpAnim_hunTranslatedToTopOfScreen() {
    fun resetViewStates_hunAnimatingAway_hunTranslatedToTopOfScreen() {
        val topMargin = 100f
        ambientState.maxHeadsUpTranslation = 2000f
        ambientState.stackTopMargin = topMargin.toInt()
@@ -461,7 +422,6 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {

    @Test
    @DisableSceneContainer
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_hunAnimatingAwayWhileDozing_yTranslationIsInset() {
        whenever(notificationRow.isHeadsUpAnimatingAway).thenReturn(true)

@@ -472,7 +432,6 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {

    @Test
    @DisableSceneContainer
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_hunAnimatingAwayWhileDozing_hasStackMargin_changesHunYTranslation() {
        whenever(notificationRow.isHeadsUpAnimatingAway).thenReturn(true)

@@ -493,18 +452,6 @@ class StackScrollAlgorithmTest(flags: FlagsParameterization) : SysuiTestCase() {
        resetViewStates_hunsOverlapping_bottomHunClipped(topHun, bottomHun)
    }

    @Test
    @DisableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun resetViewStates_hunsOverlappingAndBottomHunAnimatingAway_bottomHunClipped() {
        val topHun = mockExpandableNotificationRow()
        val bottomHun = mockExpandableNotificationRow()
        whenever(topHun.isHeadsUp).thenReturn(true)
        whenever(topHun.isPinned).thenReturn(true)
        whenever(bottomHun.isHeadsUpAnimatingAway).thenReturn(true)

        resetViewStates_hunsOverlapping_bottomHunClipped(topHun, bottomHun)
    }

    @Test
    @EnableSceneContainer
    fun resetViewStates_emptyShadeView_isCenteredVertically_withSceneContainer() {
+4 −8
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.notification.stack

import android.platform.test.annotations.EnableFlags
import android.testing.TestableLooper.RunWithLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -24,7 +23,6 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.AnimatorTestRule
import com.android.systemui.res.R
import com.android.systemui.statusbar.notification.row.ExpandableView
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent
import com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_HEADS_UP_APPEAR
import com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_HEADS_UP_DISAPPEAR
@@ -60,11 +58,12 @@ class StackStateAnimatorTest : SysuiTestCase() {
    private val viewState: ExpandableViewState =
        ExpandableViewState().apply { height = VIEW_HEIGHT }
    private val runnableCaptor: ArgumentCaptor<Runnable> = argumentCaptor()

    @Before
    fun setUp() {
        overrideResource(
            R.dimen.go_to_full_shade_appearing_translation,
            FULL_SHADE_APPEAR_TRANSLATION
            FULL_SHADE_APPEAR_TRANSLATION,
        )
        overrideResource(R.dimen.heads_up_appear_y_above_screen, HEADS_UP_ABOVE_SCREEN)

@@ -74,7 +73,6 @@ class StackStateAnimatorTest : SysuiTestCase() {
    }

    @Test
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun startAnimationForEvents_headsUpFromTop_startsHeadsUpAppearAnim() {
        val topMargin = 50f
        val expectedStartY = -topMargin - stackStateAnimator.mHeadsUpAppearStartAboveScreen
@@ -90,12 +88,11 @@ class StackStateAnimatorTest : SysuiTestCase() {
                /* delay= */ 0L,
                /* duration= */ ANIMATION_DURATION_HEADS_UP_APPEAR.toLong(),
                /* isHeadsUpAppear= */ true,
                /* onEndRunnable= */ null
                /* onEndRunnable= */ null,
            )
    }

    @Test
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun startAnimationForEvents_headsUpFromBottom_startsHeadsUpAppearAnim() {
        val screenHeight = 2000f
        val expectedStartY = screenHeight + stackStateAnimator.mHeadsUpAppearStartAboveScreen
@@ -114,12 +111,11 @@ class StackStateAnimatorTest : SysuiTestCase() {
                /* delay= */ 0L,
                /* duration= */ ANIMATION_DURATION_HEADS_UP_APPEAR.toLong(),
                /* isHeadsUpAppear= */ true,
                /* onEndRunnable= */ null
                /* onEndRunnable= */ null,
            )
    }

    @Test
    @EnableFlags(NotificationsImprovedHunAnimation.FLAG_NAME)
    fun startAnimationForEvents_startsHeadsUpDisappearAnim() {
        val disappearDuration = ANIMATION_DURATION_HEADS_UP_DISAPPEAR.toLong()
        val event = AnimationEvent(view, AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR)
+8 −27
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ import android.util.FloatProperty
import android.view.View
import androidx.annotation.FloatRange
import com.android.systemui.res.R
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation
import com.android.systemui.statusbar.notification.stack.AnimationProperties
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import kotlin.math.abs
@@ -39,15 +38,11 @@ interface Roundable {

    /** Current top corner in pixel, based on [topRoundness] and [maxRadius] */
    val topCornerRadius: Float
        get() =
            if (NotificationsImprovedHunAnimation.isEnabled) roundableState.topCornerRadius
            else topRoundness * maxRadius
        get() = roundableState.topCornerRadius

    /** Current bottom corner in pixel, based on [bottomRoundness] and [maxRadius] */
    val bottomCornerRadius: Float
        get() =
            if (NotificationsImprovedHunAnimation.isEnabled) roundableState.bottomCornerRadius
            else bottomRoundness * maxRadius
        get() = roundableState.bottomCornerRadius

    /** Get and update the current radii */
    val updatedRadii: FloatArray
@@ -123,7 +118,7 @@ interface Roundable {
        return requestTopRoundness(
            value = value,
            sourceType = sourceType,
            animate = roundableState.targetView.isShown
            animate = roundableState.targetView.isShown,
        )
    }

@@ -190,7 +185,7 @@ interface Roundable {
        return requestBottomRoundness(
            value = value,
            sourceType = sourceType,
            animate = roundableState.targetView.isShown
            animate = roundableState.targetView.isShown,
        )
    }

@@ -289,11 +284,7 @@ interface Roundable {
     *
     * This method reuses the previous [radii] for performance reasons.
     */
    fun updateRadii(
        topCornerRadius: Float,
        bottomCornerRadius: Float,
        radii: FloatArray,
    ) {
    fun updateRadii(topCornerRadius: Float, bottomCornerRadius: Float, radii: FloatArray) {
        if (radii.size != 8) error("Unexpected radiiBuffer size ${radii.size}")

        if (radii[0] != topCornerRadius || radii[4] != bottomCornerRadius) {
@@ -312,11 +303,7 @@ interface Roundable {
 */
class RoundableState
@JvmOverloads
constructor(
    internal val targetView: View,
    private val roundable: Roundable,
    maxRadius: Float,
) {
constructor(internal val targetView: View, private val roundable: Roundable, maxRadius: Float) {
    internal var maxRadius = maxRadius
        private set

@@ -387,18 +374,12 @@ constructor(
    internal fun isBottomAnimating() = PropertyAnimator.isAnimating(targetView, bottomAnimatable)

    /** Set the current top roundness */
    internal fun setTopRoundness(
        value: Float,
        animated: Boolean,
    ) {
    internal fun setTopRoundness(value: Float, animated: Boolean) {
        PropertyAnimator.setProperty(targetView, topAnimatable, value, DURATION, animated)
    }

    /** Set the current bottom roundness */
    internal fun setBottomRoundness(
        value: Float,
        animated: Boolean,
    ) {
    internal fun setBottomRoundness(value: Float, animated: Boolean) {
        PropertyAnimator.setProperty(targetView, bottomAnimatable, value, DURATION, animated)
    }

+2 −39
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import com.android.systemui.statusbar.notification.FakeShadowView;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.shared.NotificationHeadsUpCycling;
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.util.DumpUtilsKt;
@@ -407,12 +406,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView

        mAppearAnimator = ValueAnimator.ofFloat(mAppearAnimationFraction,
                targetValue);
        if (NotificationsImprovedHunAnimation.isEnabled()
                || NotificationHeadsUpCycling.isEnabled()) {
        mAppearAnimator.setInterpolator(mCurrentAppearInterpolator);
        } else {
            mAppearAnimator.setInterpolator(Interpolators.LINEAR);
        }
        mAppearAnimator.setDuration(
                (long) (duration * Math.abs(mAppearAnimationFraction - targetValue)));
        mAppearAnimator.addUpdateListener(animation -> {
@@ -531,10 +525,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
     * @param clipSide Which side if view we want to clip from
     */
    private void updateAppearRect(ClipSide clipSide) {
        float interpolatedFraction =
                NotificationsImprovedHunAnimation.isEnabled()
                        || NotificationHeadsUpCycling.isEnabled() ? mAppearAnimationFraction
                        : mCurrentAppearInterpolator.getInterpolation(mAppearAnimationFraction);
        float interpolatedFraction = mAppearAnimationFraction;
        mAppearAnimationTranslation = (1.0f - interpolatedFraction) * mAnimationTranslationY;
        final int fullHeight = getActualHeight();
        float height = fullHeight * interpolatedFraction;
@@ -566,14 +557,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        updateAppearRect(ClipSide.BOTTOM);
    }

    private float getInterpolatedAppearAnimationFraction() {

        if (mAppearAnimationFraction >= 0) {
            return mCurrentAppearInterpolator.getInterpolation(mAppearAnimationFraction);
        }
        return 1.0f;
    }

    private void updateAppearAnimationAlpha() {
        updateAppearAnimationContentAlpha(
                mAppearAnimationFraction,
@@ -643,26 +626,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        super.applyRoundnessAndInvalidate();
    }

    @Override
    public float getTopCornerRadius() {
        if (NotificationsImprovedHunAnimation.isEnabled()) {
            return super.getTopCornerRadius();
        }

        float fraction = getInterpolatedAppearAnimationFraction();
        return MathUtils.lerp(0, super.getTopCornerRadius(), fraction);
    }

    @Override
    public float getBottomCornerRadius() {
        if (NotificationsImprovedHunAnimation.isEnabled()) {
            return super.getBottomCornerRadius();
        }

        float fraction = getInterpolatedAppearAnimationFraction();
        return MathUtils.lerp(0, super.getBottomCornerRadius(), fraction);
    }

    private void applyBackgroundRoundness(float topRadius, float bottomRadius) {
        mBackgroundNormal.setRadius(topRadius, bottomRadius);
    }
Loading