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

Commit 7c713f0d authored by Omar Miatello's avatar Omar Miatello Committed by Automerger Merge Worker
Browse files

Merge "Fix for delayed rounding animation on notification" into tm-qpr-dev am: f10f6630

parents 50384c51 f10f6630
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -251,6 +251,21 @@ interface Roundable {
        )
    }

    /**
     * Request the roundness 0f for a [SourceType].
     *
     * The top/bottom roundness of a [Roundable] can be defined by different [sourceType]. In case
     * more origins require different roundness, for the same property, the maximum value will
     * always be chosen.
     *
     * @param sourceType the source from which the request for roundness comes.
     * @param animate true if it should animate to that value.
     */
    @JvmDefault
    fun requestRoundnessReset(sourceType: SourceType, animate: Boolean) {
        requestRoundness(top = 0f, bottom = 0f, sourceType = sourceType, animate = animate)
    }

    /**
     * Request the roundness 0f for a [SourceType]. Animate the roundness if the view is shown.
     *
@@ -262,7 +277,7 @@ interface Roundable {
     */
    @JvmDefault
    fun requestRoundnessReset(sourceType: SourceType) {
        requestRoundness(top = 0f, bottom = 0f, sourceType = sourceType)
        requestRoundnessReset(sourceType = sourceType, animate = roundableState.targetView.isShown)
    }

    /** Apply the roundness changes, usually means invalidate the [RoundableState.targetView]. */
+2 −1
Original line number Diff line number Diff line
@@ -3487,7 +3487,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
                mChildrenContainer.requestRoundness(
                        /* top = */ getTopRoundness(),
                        /* bottom = */ getBottomRoundness(),
                        FROM_PARENT);
                        /* sourceType = */ FROM_PARENT,
                        /* animate = */ false);
            } else {
                mChildrenContainer.requestBottomRoundness(
                        getBottomRoundness(),
+3 −2
Original line number Diff line number Diff line
@@ -367,7 +367,7 @@ public class NotificationChildrenContainer extends ViewGroup
        }

        if (mUseRoundnessSourceTypes) {
            row.requestRoundnessReset(FROM_PARENT);
            row.requestRoundnessReset(FROM_PARENT, /* animate = */ false);
            applyRoundnessAndInvalidate();
        }
    }
@@ -1440,7 +1440,8 @@ public class NotificationChildrenContainer extends ViewGroup
                child.requestRoundness(
                        /* top = */ 0f,
                        /* bottom = */ last ? getBottomRoundness() : 0f,
                        FROM_PARENT);
                        /* sourceType = */ FROM_PARENT,
                        /* animate = */ false);
            } else {
                child.requestRoundness(
                        /* top = */ 0f,
+25 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.AboveShelfChangedListener;
import com.android.systemui.statusbar.notification.FeedbackIcon;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableView.OnHeightChangedListener;
import com.android.systemui.statusbar.notification.stack.NotificationChildrenContainer;
@@ -534,4 +535,28 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
                /*oldParent=*/ any()
        );
    }

    @Test
    public void applyRoundnessAndInv_should_be_immediately_applied_on_childrenContainer_legacy() {
        mGroupRow.useRoundnessSourceTypes(false);
        Assert.assertEquals(0f, mGroupRow.getBottomRoundness(), 0.001f);
        Assert.assertEquals(0f, mGroupRow.getChildrenContainer().getBottomRoundness(), 0.001f);

        mGroupRow.requestBottomRoundness(1f, SourceType.from(""), false);

        Assert.assertEquals(1f, mGroupRow.getBottomRoundness(), 0.001f);
        Assert.assertEquals(1f, mGroupRow.getChildrenContainer().getBottomRoundness(), 0.001f);
    }

    @Test
    public void applyRoundnessAndInvalidate_should_be_immediately_applied_on_childrenContainer() {
        mGroupRow.useRoundnessSourceTypes(true);
        Assert.assertEquals(0f, mGroupRow.getBottomRoundness(), 0.001f);
        Assert.assertEquals(0f, mGroupRow.getChildrenContainer().getBottomRoundness(), 0.001f);

        mGroupRow.requestBottomRoundness(1f, SourceType.from(""), false);

        Assert.assertEquals(1f, mGroupRow.getBottomRoundness(), 0.001f);
        Assert.assertEquals(1f, mGroupRow.getChildrenContainer().getBottomRoundness(), 0.001f);
    }
}
+31 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.notification.LegacySourceType;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;

@@ -34,6 +35,8 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.List;

@SmallTest
@RunWith(AndroidTestingRunner.class)
@RunWithLooper
@@ -185,4 +188,32 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
        Assert.assertEquals(1f, row2.getTopRoundness(), /* delta = */ 0f);
        Assert.assertEquals(1f, row2.getBottomRoundness(), /* delta = */ 0f);
    }

    @Test
    public void applyRoundnessAndInvalidate_should_be_immediately_applied_on_last_child_legacy() {
        mChildrenContainer.useRoundnessSourceTypes(false);
        List<ExpandableNotificationRow> children = mChildrenContainer.getAttachedChildren();
        ExpandableNotificationRow notificationRow = children.get(children.size() - 1);
        Assert.assertEquals(0f, mChildrenContainer.getBottomRoundness(), 0.001f);
        Assert.assertEquals(0f, notificationRow.getBottomRoundness(), 0.001f);

        mChildrenContainer.requestBottomRoundness(1f, SourceType.from(""), false);

        Assert.assertEquals(1f, mChildrenContainer.getBottomRoundness(), 0.001f);
        Assert.assertEquals(1f, notificationRow.getBottomRoundness(), 0.001f);
    }

    @Test
    public void applyRoundnessAndInvalidate_should_be_immediately_applied_on_last_child() {
        mChildrenContainer.useRoundnessSourceTypes(true);
        List<ExpandableNotificationRow> children = mChildrenContainer.getAttachedChildren();
        ExpandableNotificationRow notificationRow = children.get(children.size() - 1);
        Assert.assertEquals(0f, mChildrenContainer.getBottomRoundness(), 0.001f);
        Assert.assertEquals(0f, notificationRow.getBottomRoundness(), 0.001f);

        mChildrenContainer.requestBottomRoundness(1f, SourceType.from(""), false);

        Assert.assertEquals(1f, mChildrenContainer.getBottomRoundness(), 0.001f);
        Assert.assertEquals(1f, notificationRow.getBottomRoundness(), 0.001f);
    }
}