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

Commit e9a1ed9f authored by Yuri Lin's avatar Yuri Lin Committed by Android (Google) Code Review
Browse files

Merge "Wrap bundle header in a roundable so that it can round with adjacent swipes." into main

parents 8542dae2 9ece14c4
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
@@ -44,6 +44,7 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
@@ -64,6 +65,7 @@ import com.android.compose.animation.scene.SceneTransitionLayout
import com.android.compose.animation.scene.rememberMutableSceneTransitionLayoutState
import com.android.compose.animation.scene.transitions
import com.android.compose.ui.graphics.painter.rememberDrawablePainter
import com.android.systemui.res.R
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModel

object BundleHeader {
@@ -136,7 +138,13 @@ fun BundleHeader(viewModel: BundleHeaderViewModel, modifier: Modifier = Modifier
        onDispose { viewModel.composeScope = null }
    }

    Box(modifier) {
    // In most cases the height is expected to be equal to the header height dimension's value, but
    // it is set as the minimum here so that the header can resize if necessary for larger font
    // or display sizes.
    Box(
        modifier =
            modifier.heightIn(min = dimensionResource(R.dimen.notification_bundle_header_height))
    ) {
        Background(background = viewModel.backgroundDrawable, modifier = Modifier.matchParentSize())
        SceneTransitionLayout(
            state = state,
@@ -177,7 +185,7 @@ private fun ContentScope.BundleHeaderContent(
) {
    Row(
        verticalAlignment = Alignment.CenterVertically,
        modifier = modifier.height(48.dp).padding(vertical = 12.dp),
        modifier = modifier.padding(vertical = 12.dp),
    ) {
        BundleIcon(
            viewModel.bundleIcon,
+16 −26
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.statusbar.notification.SourceType;
import com.android.systemui.statusbar.notification.collection.BundleSpec;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
@@ -55,6 +56,7 @@ import java.util.List;
public class NotificationChildrenContainerTest extends SysuiTestCase {

    private ExpandableNotificationRow mGroup;
    private ExpandableNotificationRow mBundle;
    private NotificationChildrenContainer mChildrenContainer;

    private final KosmosJavaAdapter mKosmos = new KosmosJavaAdapter(this);
@@ -64,6 +66,7 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
        allowTestableLooperAsMainThread();
        mGroup = mKosmos.createRowGroup();
        mChildrenContainer = mGroup.getChildrenContainer();
        mBundle = mKosmos.createRowBundle(BundleSpec.Companion.getNEWS());
    }

    @Test
@@ -121,9 +124,12 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    public void testGetMaxAllowedVisibleChildren_bundle_likeCollapsed() {
        ComposeView headerView = new ComposeView(mContext);
        mChildrenContainer.setBundleHeaderView(headerView);
        mChildrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class));
        Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(true),
        // This will initialize the bundle's children container
        mBundle.setBundleHeaderView(headerView);

        NotificationChildrenContainer childrenContainer = mBundle.getChildrenContainer();
        childrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class));
        Assert.assertEquals(childrenContainer.getMaxAllowedVisibleChildren(true),
                NotificationChildrenContainer.NUMBER_OF_CHILDREN_BUNDLE_COLLAPSED);
    }

@@ -132,11 +138,13 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    public void testGetMaxAllowedVisibleChildren_bundle_expandedChildren() {
        ComposeView headerView = new ComposeView(mContext);
        mChildrenContainer.setBundleHeaderView(headerView);
        mChildrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class));
        mChildrenContainer.getContainingNotification().expandNotification();
        mChildrenContainer.setChildrenExpanded(true);
        Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(),
        mBundle.setBundleHeaderView(headerView);

        NotificationChildrenContainer childrenContainer = mBundle.getChildrenContainer();
        childrenContainer.setBundleHeaderViewModel(mock(BundleHeaderViewModel.class));
        childrenContainer.getContainingNotification().expandNotification();
        childrenContainer.setChildrenExpanded(true);
        Assert.assertEquals(childrenContainer.getMaxAllowedVisibleChildren(),
                NotificationChildrenContainer.NUMBER_OF_CHILDREN_BUNDLE_EXPANDED);
    }

@@ -301,24 +309,6 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
        Assert.assertEquals(1f, header.getTopRoundness(), 0.001f);
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    public void initBundleHeader_composeview_is_initialized_once() {
        View currentView = mChildrenContainer.getChildAt(mChildrenContainer.getChildCount() - 1);
        Assert.assertFalse(currentView instanceof ComposeView);

        ComposeView headerView = new ComposeView(mContext);
        mChildrenContainer.setBundleHeaderView(headerView);
        BundleHeaderViewModel viewModel = mKosmos.getBundleHeaderViewModel();
        mChildrenContainer.setBundleHeaderViewModel(viewModel);
        currentView = mChildrenContainer.getChildAt(mChildrenContainer.getChildCount() - 1);
        Assert.assertTrue(currentView instanceof ComposeView);

        mChildrenContainer.setBundleHeaderViewModel(viewModel);
        View finalView = mChildrenContainer.getChildAt(mChildrenContainer.getChildCount() - 1);
        Assert.assertEquals(currentView, finalView);
    }

    private NotificationHeaderView createHeaderView(boolean lowPriority) {
        Notification notification = mKosmos.buildNotificationEntry(NotificationEntryBuilder::done)
                .getSbn().getNotification();
+3 −0
Original line number Diff line number Diff line
@@ -407,6 +407,9 @@
    <!-- Extra space for guts bundle feedback button -->
    <dimen name="notification_guts_bundle_feedback_size">48dp</dimen>

    <!-- The height of notification bundle headers -->
    <dimen name="notification_bundle_header_height">48dp</dimen>

    <!-- Size of icon buttons in notification info. -->
    <!-- 24dp for the icon itself + 16dp * 2 for top and bottom padding -->
    <dimen name="notification_2025_guts_button_size">56dp</dimen>
+2 −0
Original line number Diff line number Diff line
@@ -395,6 +395,8 @@ constructor(internal val targetView: View, private val roundable: Roundable, max
        append("top: { value: $topRoundness, requests: $topRoundnessMap}")
        append(", ")
        append("bottom: { value: $bottomRoundness, requests: $bottomRoundnessMap}")
        append(", ")
        append("maxRadius: $maxRadius")
        append("}")
    }

+18 −0
Original line number Diff line number Diff line
@@ -2286,6 +2286,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        if (NotificationBundleUi.isEnabled()) {
            mEntryAdapter = entryAdapter;
            mIsBundle = entryAdapter instanceof BundleEntryAdapter;
            if (isBundle()) {
                // Initial dimensions for the roundable state are set upon construction, which means
                // we need to re-calculate at the point when we know whether this row is a bundle.
                updateMaxRadius();
            }
        } else {
            mEntry = (NotificationEntry) entry;
        }
@@ -4512,6 +4517,19 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return super.getCustomClipPath(child);
    }

    @Override
    float calculateMaxRadius() {
        float radius = super.calculateMaxRadius();
        if (isBundle()) {
            // Bundle headers may be small enough that the max radius used for the ENR would
            // clip more off the corner of the bundle header than the header height would allow.
            // In this case, limit the radius for rounding to half the bundle header height.
            return Math.min(radius, getContext().getResources().getDimension(
                    R.dimen.notification_bundle_header_height) / 2.0f);
        }
        return radius;
    }

    public boolean isMediaRow() {
        NotificationBundleUi.assertInLegacyMode();
        return getEntryLegacy().getSbn().getNotification().isMediaNotification();
Loading