Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -148,6 +148,32 @@ public class NotificationChildrenContainerTest extends SysuiTestCase { NotificationChildrenContainer.NUMBER_OF_CHILDREN_BUNDLE_EXPANDED); NotificationChildrenContainer.NUMBER_OF_CHILDREN_BUNDLE_EXPANDED); } } @Test @EnableFlags(NotificationBundleUi.FLAG_NAME) public void testExpandedClipRect_bundle_expandedChildren_requiresExtraClipping() { ComposeView headerView = new ComposeView(mContext); mBundle.setBundleHeaderView(headerView); NotificationChildrenContainer childrenContainer = mBundle.getChildrenContainer(); childrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class)); childrenContainer.getContainingNotification().expandNotification(); childrenContainer.setChildrenExpanded(true); Assert.assertNotNull(childrenContainer.getExpandedClipRect(mGroup)); Assert.assertTrue(childrenContainer.childNeedsExpandedClipPath(mGroup)); } @Test @EnableFlags(NotificationBundleUi.FLAG_NAME) public void testExpandedClipRect_bundle_notExpandedChildren_doesNotRequireExtraClipping() { ComposeView headerView = new ComposeView(mContext); mBundle.setBundleHeaderView(headerView); NotificationChildrenContainer childrenContainer = mBundle.getChildrenContainer(); childrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class)); childrenContainer.getContainingNotification().expandNotification(); childrenContainer.setChildrenExpanded(false); Assert.assertFalse(childrenContainer.childNeedsExpandedClipPath(mGroup)); } @Test @Test public void testShowingAsLowPriority_lowPriority() { public void testShowingAsLowPriority_lowPriority() { Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java +37 −0 Original line number Original line Diff line number Diff line Loading @@ -25,9 +25,11 @@ import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.Path; import android.graphics.Path.Direction; import android.graphics.Path.Direction; import android.graphics.RectF; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable; import android.os.Trace; import android.os.Trace; import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification; import android.util.ArrayMap; import android.util.AttributeSet; import android.util.AttributeSet; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; Loading Loading @@ -159,6 +161,7 @@ public class NotificationChildrenContainer extends ViewGroup private int mMinSingleLineHeight; private int mMinSingleLineHeight; private NotificationChildrenContainerLogger mLogger; private NotificationChildrenContainerLogger mLogger; private ArrayMap<String, RectF> mExpandedClipRect = new ArrayMap<>(); public NotificationChildrenContainer(Context context) { public NotificationChildrenContainer(Context context) { this(context, null); this(context, null); Loading Loading @@ -860,6 +863,7 @@ public class NotificationChildrenContainer extends ViewGroup boolean childrenExpandedAndNotAnimating = mChildrenExpanded boolean childrenExpandedAndNotAnimating = mChildrenExpanded && !mContainingNotification.isGroupExpansionChanging(); && !mContainingNotification.isGroupExpansionChanging(); int launchTransitionCompensation = 0; int launchTransitionCompensation = 0; mExpandedClipRect.clear(); for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) { ExpandableNotificationRow child = mAttachedChildren.get(i); ExpandableNotificationRow child = mAttachedChildren.get(i); if (NotificationBundleUi.isEnabled()) { if (NotificationBundleUi.isEnabled()) { Loading Loading @@ -920,6 +924,13 @@ public class NotificationChildrenContainer extends ViewGroup childState.location = parentState.location; childState.location = parentState.location; childState.inShelf = parentState.inShelf; childState.inShelf = parentState.inShelf; yPosition += intrinsicHeight; yPosition += intrinsicHeight; // If this is a group summary and a child of a bundle, then the clip path needs to // be expanded otherwise the summary children will be clipped when translated if (childNeedsExpandedClipPath(child)) { RectF expandClipRect = getExpandedClipRect(child); mExpandedClipRect.put(child.getKey(), expandClipRect); } } } if (mOverflowNumber != null) { if (mOverflowNumber != null) { ExpandableNotificationRow overflowView = mAttachedChildren.get(Math.min( ExpandableNotificationRow overflowView = mAttachedChildren.get(Math.min( Loading Loading @@ -1146,6 +1157,23 @@ public class NotificationChildrenContainer extends ViewGroup } } } } @VisibleForTesting protected boolean childNeedsExpandedClipPath(ExpandableNotificationRow child) { return isBundle() && mChildrenExpanded && child.isSummaryWithChildren(); } @VisibleForTesting protected RectF getExpandedClipRect(ExpandableNotificationRow summaryRow) { RectF expandedRect; float maxAbsChildTranslation = getWidth() / 2.0f; expandedRect = new RectF(); expandedRect.left = -maxAbsChildTranslation; expandedRect.top = 0; expandedRect.bottom = mContainingNotification.getActualHeight(); expandedRect.right = summaryRow.getWidth() + maxAbsChildTranslation; return expandedRect; } @Override @Override protected boolean drawChild(@NonNull Canvas canvas, View child, long drawingTime) { protected boolean drawChild(@NonNull Canvas canvas, View child, long drawingTime) { boolean isCanvasChanged = false; boolean isCanvasChanged = false; Loading @@ -1153,8 +1181,10 @@ public class NotificationChildrenContainer extends ViewGroup Path clipPath = mChildClipPath; Path clipPath = mChildClipPath; if (clipPath != null) { if (clipPath != null) { final float translation; final float translation; RectF expandClipRect = null; if (child instanceof ExpandableNotificationRow notificationRow) { if (child instanceof ExpandableNotificationRow notificationRow) { translation = notificationRow.getTranslation(); translation = notificationRow.getTranslation(); expandClipRect = mExpandedClipRect.get(notificationRow.getKey()); } else { } else { translation = child.getTranslationX(); translation = child.getTranslationX(); } } Loading @@ -1166,6 +1196,13 @@ public class NotificationChildrenContainer extends ViewGroup canvas.clipPath(clipPath); canvas.clipPath(clipPath); clipPath.offset(-translation, 0f); clipPath.offset(-translation, 0f); } else { } else { if (expandClipRect != null) { // Expand clip path with a rect that has the same height as the parent // but is wider by width/2 so that grand-child translations are not clipped // Only applies to bundle headers clipPath = new Path(clipPath); clipPath.addRect(expandClipRect, Direction.CW); } canvas.clipPath(clipPath); canvas.clipPath(clipPath); } } } } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -148,6 +148,32 @@ public class NotificationChildrenContainerTest extends SysuiTestCase { NotificationChildrenContainer.NUMBER_OF_CHILDREN_BUNDLE_EXPANDED); NotificationChildrenContainer.NUMBER_OF_CHILDREN_BUNDLE_EXPANDED); } } @Test @EnableFlags(NotificationBundleUi.FLAG_NAME) public void testExpandedClipRect_bundle_expandedChildren_requiresExtraClipping() { ComposeView headerView = new ComposeView(mContext); mBundle.setBundleHeaderView(headerView); NotificationChildrenContainer childrenContainer = mBundle.getChildrenContainer(); childrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class)); childrenContainer.getContainingNotification().expandNotification(); childrenContainer.setChildrenExpanded(true); Assert.assertNotNull(childrenContainer.getExpandedClipRect(mGroup)); Assert.assertTrue(childrenContainer.childNeedsExpandedClipPath(mGroup)); } @Test @EnableFlags(NotificationBundleUi.FLAG_NAME) public void testExpandedClipRect_bundle_notExpandedChildren_doesNotRequireExtraClipping() { ComposeView headerView = new ComposeView(mContext); mBundle.setBundleHeaderView(headerView); NotificationChildrenContainer childrenContainer = mBundle.getChildrenContainer(); childrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class)); childrenContainer.getContainingNotification().expandNotification(); childrenContainer.setChildrenExpanded(false); Assert.assertFalse(childrenContainer.childNeedsExpandedClipPath(mGroup)); } @Test @Test public void testShowingAsLowPriority_lowPriority() { public void testShowingAsLowPriority_lowPriority() { Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java +37 −0 Original line number Original line Diff line number Diff line Loading @@ -25,9 +25,11 @@ import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.Path; import android.graphics.Path.Direction; import android.graphics.Path.Direction; import android.graphics.RectF; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable; import android.os.Trace; import android.os.Trace; import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification; import android.util.ArrayMap; import android.util.AttributeSet; import android.util.AttributeSet; import android.util.Log; import android.util.Log; import android.view.LayoutInflater; import android.view.LayoutInflater; Loading Loading @@ -159,6 +161,7 @@ public class NotificationChildrenContainer extends ViewGroup private int mMinSingleLineHeight; private int mMinSingleLineHeight; private NotificationChildrenContainerLogger mLogger; private NotificationChildrenContainerLogger mLogger; private ArrayMap<String, RectF> mExpandedClipRect = new ArrayMap<>(); public NotificationChildrenContainer(Context context) { public NotificationChildrenContainer(Context context) { this(context, null); this(context, null); Loading Loading @@ -860,6 +863,7 @@ public class NotificationChildrenContainer extends ViewGroup boolean childrenExpandedAndNotAnimating = mChildrenExpanded boolean childrenExpandedAndNotAnimating = mChildrenExpanded && !mContainingNotification.isGroupExpansionChanging(); && !mContainingNotification.isGroupExpansionChanging(); int launchTransitionCompensation = 0; int launchTransitionCompensation = 0; mExpandedClipRect.clear(); for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) { ExpandableNotificationRow child = mAttachedChildren.get(i); ExpandableNotificationRow child = mAttachedChildren.get(i); if (NotificationBundleUi.isEnabled()) { if (NotificationBundleUi.isEnabled()) { Loading Loading @@ -920,6 +924,13 @@ public class NotificationChildrenContainer extends ViewGroup childState.location = parentState.location; childState.location = parentState.location; childState.inShelf = parentState.inShelf; childState.inShelf = parentState.inShelf; yPosition += intrinsicHeight; yPosition += intrinsicHeight; // If this is a group summary and a child of a bundle, then the clip path needs to // be expanded otherwise the summary children will be clipped when translated if (childNeedsExpandedClipPath(child)) { RectF expandClipRect = getExpandedClipRect(child); mExpandedClipRect.put(child.getKey(), expandClipRect); } } } if (mOverflowNumber != null) { if (mOverflowNumber != null) { ExpandableNotificationRow overflowView = mAttachedChildren.get(Math.min( ExpandableNotificationRow overflowView = mAttachedChildren.get(Math.min( Loading Loading @@ -1146,6 +1157,23 @@ public class NotificationChildrenContainer extends ViewGroup } } } } @VisibleForTesting protected boolean childNeedsExpandedClipPath(ExpandableNotificationRow child) { return isBundle() && mChildrenExpanded && child.isSummaryWithChildren(); } @VisibleForTesting protected RectF getExpandedClipRect(ExpandableNotificationRow summaryRow) { RectF expandedRect; float maxAbsChildTranslation = getWidth() / 2.0f; expandedRect = new RectF(); expandedRect.left = -maxAbsChildTranslation; expandedRect.top = 0; expandedRect.bottom = mContainingNotification.getActualHeight(); expandedRect.right = summaryRow.getWidth() + maxAbsChildTranslation; return expandedRect; } @Override @Override protected boolean drawChild(@NonNull Canvas canvas, View child, long drawingTime) { protected boolean drawChild(@NonNull Canvas canvas, View child, long drawingTime) { boolean isCanvasChanged = false; boolean isCanvasChanged = false; Loading @@ -1153,8 +1181,10 @@ public class NotificationChildrenContainer extends ViewGroup Path clipPath = mChildClipPath; Path clipPath = mChildClipPath; if (clipPath != null) { if (clipPath != null) { final float translation; final float translation; RectF expandClipRect = null; if (child instanceof ExpandableNotificationRow notificationRow) { if (child instanceof ExpandableNotificationRow notificationRow) { translation = notificationRow.getTranslation(); translation = notificationRow.getTranslation(); expandClipRect = mExpandedClipRect.get(notificationRow.getKey()); } else { } else { translation = child.getTranslationX(); translation = child.getTranslationX(); } } Loading @@ -1166,6 +1196,13 @@ public class NotificationChildrenContainer extends ViewGroup canvas.clipPath(clipPath); canvas.clipPath(clipPath); clipPath.offset(-translation, 0f); clipPath.offset(-translation, 0f); } else { } else { if (expandClipRect != null) { // Expand clip path with a rect that has the same height as the parent // but is wider by width/2 so that grand-child translations are not clipped // Only applies to bundle headers clipPath = new Path(clipPath); clipPath.addRect(expandClipRect, Direction.CW); } canvas.clipPath(clipPath); canvas.clipPath(clipPath); } } } } Loading