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

Commit 74d43653 authored by Steve Elliott's avatar Steve Elliott
Browse files

Shorten bundle header when expanded

Flag: com.android.systemui.notification_bundle_ui
Fixes: 433947523
Test: manual - expand bundle
Change-Id: Ie740ae4f67eb7e0312fdeb9e5db6e70bfbdb0ac5
parent 4183867d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
@@ -213,6 +212,7 @@ private fun ContentScope.BundleHeaderContent(
    ) {
        BundleIcon(
            viewModel.bundleIcon,
            collapsed,
            modifier =
                Modifier.padding(horizontal = 16.dp)
                    // Has to be a shared element because we may have a semi-transparent background
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ private fun TopRow(viewModel: BundleHeaderGutsViewModel, modifier: Modifier = Mo
        verticalAlignment = Alignment.CenterVertically,
        modifier = modifier.padding(vertical = 16.dp),
    ) {
        BundleIcon(viewModel.bundleIcon, modifier = Modifier.padding(end = 16.dp))
        BundleIcon(viewModel.bundleIcon, collapsed = true, modifier = Modifier.padding(end = 16.dp))
        Text(
            text = stringResource(viewModel.titleText),
            style = MaterialTheme.typography.titleMediumEmphasized,
+10 −3
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ object NotificationRowPrimitives {
        val PillBackground = ElementKey("PillBackground", contentPicker = LowestZIndexContentPicker)
        val NotificationIconBackground = ElementKey("NotificationIconBackground")
        val Chevron = ElementKey("Chevron")
        val ExpandedNumber = ElementKey("ExpandedNumber")
    }

    object Values {
@@ -65,14 +66,19 @@ object NotificationRowPrimitives {

/** The Icon displayed at the start of any notification row. */
@Composable
fun BundleIcon(@DrawableRes drawable: Int?, modifier: Modifier = Modifier) {
fun BundleIcon(@DrawableRes drawable: Int?, collapsed: Boolean, modifier: Modifier = Modifier) {
    val iconBackground = notificationProtectionColor()
    Box(modifier = modifier.size(40.dp).background(color = iconBackground, shape = CircleShape)) {
    Box(
        modifier =
            modifier
                .size(if (collapsed) 40.dp else 24.dp)
                .background(color = iconBackground, shape = CircleShape)
    ) {
        if (drawable == null) return@Box
        Image(
            painter = painterResource(drawable),
            contentDescription = null,
            modifier = Modifier.padding(10.dp).fillMaxSize(),
            modifier = Modifier.fillMaxSize(.5f).align(Alignment.Center),
            contentScale = ContentScale.Fit,
            colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.primary),
        )
@@ -110,6 +116,7 @@ fun ContentScope.ExpansionControl(
                    text = numberToShow.toString(),
                    style = MaterialTheme.typography.labelSmallEmphasized,
                    color = textColor,
                    modifier = Modifier.element(NotificationRowPrimitives.Elements.ExpandedNumber),
                )
            }
            Chevron(collapsed = collapsed, modifier = Modifier.size(iconSizeDp), color = textColor)
+28 −15
Original line number Diff line number Diff line
@@ -109,10 +109,6 @@ public class NotificationChildrenContainer extends ViewGroup
    private int mHeaderHeight;
    /** Margin needed at the top in the collapsed group, to allow space for the header text. */
    private int mCollapsedHeaderMargin;
    /**
     * Spacing needed in addition to {@link this#mCollapsedHeaderMargin} when the group is expanded,
     * to accommodate the full header. It doesn't include the spacing needed for the first divider.
     */
    private int mAdditionalExpandedHeaderMargin;

    private float mCollapsedBottomPadding;
@@ -205,7 +201,7 @@ public class NotificationChildrenContainer extends ViewGroup
                    R.dimen.notification_children_container_margin_top);
            mAdditionalExpandedHeaderMargin = res.getDimensionPixelOffset(
                    R.dimen.notification_children_container_top_padding);
            mHeaderHeight = mCollapsedHeaderMargin + mAdditionalExpandedHeaderMargin;
            mHeaderHeight = mCollapsedHeaderMargin + getAdditionalExpandedHeaderMargin();
        }

        mCollapsedBottomPadding = res.getDimensionPixelOffset(
@@ -289,7 +285,7 @@ public class NotificationChildrenContainer extends ViewGroup
                    newHeightSpec);
        }
        int dividerHeightSpec = MeasureSpec.makeMeasureSpec(mDividerHeight, MeasureSpec.EXACTLY);
        int height = mCollapsedHeaderMargin + mAdditionalExpandedHeaderMargin;
        int height = mCollapsedHeaderMargin + getAdditionalExpandedHeaderMargin();
        int childCount =
                Math.min(mAttachedChildren.size(), getNumberOfChildrenWhenExpanded());
        int collapsedChildren = getMaxAllowedVisibleChildren(true /* likeCollapsed */);
@@ -322,7 +318,8 @@ public class NotificationChildrenContainer extends ViewGroup
            mMinimizedGroupHeader.measure(widthMeasureSpec, headerHeightSpec);
        }
        if (mBundleHeaderView != null) {
            mBundleHeaderView.measure(widthMeasureSpec, headerHeightSpec);
            mBundleHeaderView.measure(widthMeasureSpec,
                    MeasureSpec.makeMeasureSpec(mHeaderHeight, MeasureSpec.UNSPECIFIED));
        }

        setMeasuredDimension(width, height);
@@ -806,11 +803,11 @@ public class NotificationChildrenContainer extends ViewGroup
                if (mUserLocked) {
                    intrinsicHeight += NotificationUtils.interpolate(
                            0,
                            mAdditionalExpandedHeaderMargin + mDividerHeight,
                            getAdditionalExpandedHeaderMargin() + mDividerHeight,
                            expandFactor);
                } else {
                    intrinsicHeight += childrenExpanded
                            ? mAdditionalExpandedHeaderMargin + mDividerHeight
                            ? getAdditionalExpandedHeaderMargin() + mDividerHeight
                            : 0;
                }
                firstChild = false;
@@ -868,15 +865,15 @@ public class NotificationChildrenContainer extends ViewGroup
                } else {
                    yPosition += mChildrenExpanded ? mDividerHeight : mChildPadding;
                }
            } else {
            } else { // first child
                if (expandingToExpandedGroup) {
                    yPosition += NotificationUtils.interpolate(
                            0,
                            mAdditionalExpandedHeaderMargin + mDividerHeight,
                            getAdditionalExpandedHeaderMargin() + mDividerHeight,
                            expandFactor);
                } else {
                    yPosition += mChildrenExpanded
                            ? mAdditionalExpandedHeaderMargin + mDividerHeight
                            ? getAdditionalExpandedHeaderMargin() + mDividerHeight
                            : 0;
                }
                firstChild = false;
@@ -1462,7 +1459,7 @@ public class NotificationChildrenContainer extends ViewGroup
                    /* likeHighPriority */);
        }
        int maxContentHeight = mCollapsedHeaderMargin + mCurrentHeaderTranslation
                + mAdditionalExpandedHeaderMargin;
                + getAdditionalExpandedHeaderMargin();
        int visibleChildren = 0;
        int childCount = mAttachedChildren.size();
        for (int i = 0; i < childCount; i++) {
@@ -1526,7 +1523,7 @@ public class NotificationChildrenContainer extends ViewGroup

    private int getVisibleChildrenExpandHeight() {
        int intrinsicHeight = mCollapsedHeaderMargin + mCurrentHeaderTranslation
                + mAdditionalExpandedHeaderMargin + mDividerHeight;
                + getAdditionalExpandedHeaderMargin() + mDividerHeight;
        int visibleChildren = 0;
        int childCount = mAttachedChildren.size();
        int maxAllowedVisibleChildren = getMaxAllowedVisibleChildren(true /* forceCollapsed */);
@@ -1696,7 +1693,7 @@ public class NotificationChildrenContainer extends ViewGroup

    public int getPositionInLinearLayout(View childInGroup) {
        int position = mCollapsedHeaderMargin + mCurrentHeaderTranslation
                + mAdditionalExpandedHeaderMargin;
                + getAdditionalExpandedHeaderMargin();

        for (int i = 0; i < mAttachedChildren.size(); i++) {
            ExpandableNotificationRow child = mAttachedChildren.get(i);
@@ -1887,4 +1884,20 @@ public class NotificationChildrenContainer extends ViewGroup
            child.setOnKeyguard(onKeyguard);
        }
    }

    /**
     * Spacing needed in addition to {@link #mCollapsedHeaderMargin} when the group is expanded, to
     * accommodate the full header. It doesn't include the spacing needed for the first divider.
     */
    private int getAdditionalExpandedHeaderMargin() {
        if (isBundle()) {
            if (mBundleHeaderView != null) {
                return mBundleHeaderView.getMeasuredHeight() - mHeaderHeight;
            } else {
                return 0;
            }
        } else {
            return mAdditionalExpandedHeaderMargin;
        }
    }
}