diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/Roundable.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/Roundable.kt index dc9b41690d61f..a35617c88caff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/Roundable.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/Roundable.kt @@ -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]. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index c1173e4c802ce..9f50aef6de116 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -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(), diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java index 4d1451e3a6e28..8d48d738f0f2e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java @@ -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, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java index ee8db18a10031..9d531a165f1f1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java @@ -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); + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java index fd1944e7478dc..ca99e24fc105a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java @@ -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 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 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); + } }