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

Commit 078be9e9 authored by Yining Liu's avatar Yining Liu Committed by Android (Google) Code Review
Browse files

Merge "Fix the notification content view alpha regression" into main

parents 0d84770d e93d18f8
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -2950,24 +2950,21 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) {
            return;
        }
        float oldAlpha = getContentView().getAlpha();

        if (!animated) {
            if (!NotificationContentAlphaOptimization.isEnabled()
                    || mShowingPublic != oldShowingPublic) {
                // Don't reset the alpha or cancel the animation if the showing layout doesn't
                // change
                mPublicLayout.animate().cancel();
                mPrivateLayout.animate().cancel();
                if (mChildrenContainer != null) {
                    mChildrenContainer.animate().cancel();
                }
                resetAllContentAlphas();
            }
            mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
            updateChildrenVisibility();
            if (NotificationContentAlphaOptimization.isEnabled()) {
                // We want to set the old alpha to the now-showing layout to avoid breaking an
                // on-going animation
                if (oldAlpha != 1f) {
                    setAlphaAndLayerType(mShowingPublic ? mPublicLayout : mPrivateLayout, oldAlpha);
                }
            }
        } else {
            animateShowingPublic(delay, duration, mShowingPublic);
        }
+4 −4
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {

    @Test
    @EnableFlags(NotificationContentAlphaOptimization.FLAG_NAME)
    public void setHideSensitive_changeContent_shouldNotDisturbAnimation() throws Exception {
    public void setHideSensitive_changeContent_shouldResetAlpha() throws Exception {

        // Given: A sensitive row that has public version but is not hiding sensitive,
        // and is during an animation that sets its alpha value to be 0.5f
@@ -351,12 +351,12 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {

        // Then: The alpha value of private layout should be reset to 1, private layout be
        // INVISIBLE;
        // The alpha value of public layout should be 0.5 to preserve the animation state, public
        // layout should be VISIBLE
        // The alpha value of public layout should be reset to 1 to avoid remaining transparent,
        // public layout should be VISIBLE
        assertEquals(View.INVISIBLE, row.getPrivateLayout().getVisibility());
        assertEquals(1f, row.getPrivateLayout().getAlpha(), 0);
        assertEquals(View.VISIBLE, row.getPublicLayout().getVisibility());
        assertEquals(0.5f, row.getPublicLayout().getAlpha(), 0);
        assertEquals(1f, row.getPublicLayout().getAlpha(), 0);
    }

    @Test