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

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

Merge "Make bundle headers small all the time (whether expanded or collapsed)." into main

parents 15148029 d1e15689
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -172,13 +172,14 @@ private fun ContentScope.BundleHeaderContent(
) {
    Row(
        verticalAlignment = Alignment.CenterVertically,
        modifier = modifier.padding(vertical = 16.dp),
        modifier = modifier.padding(vertical = 12.dp),
    ) {
        BundleIcon(
            viewModel.bundleIcon,
            collapsed,
            large = false, // BundleHeader is always small
            modifier =
                Modifier.padding(horizontal = 16.dp)
                Modifier.padding(start = 16.dp, end = 8.dp)
                    .align(Alignment.CenterVertically)
                    // Has to be a shared element because we may have a semi-transparent background
                    .element(NotificationRowPrimitives.Elements.NotificationIconBackground),
        )
@@ -217,7 +218,7 @@ private fun ContentScope.BundlePreviewIcons(
    modifier: Modifier = Modifier,
) {
    check(previewDrawables.isNotEmpty())
    val iconSize = 32.dp
    val iconSize = 24.dp

    // The design stroke width is 2.5dp but there is a ~4% padding inside app icons; ~1.25dp here.
    val borderWidth = 1.25.dp
+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, collapsed = true, modifier = Modifier.padding(end = 16.dp))
        BundleIcon(viewModel.bundleIcon, large = true, modifier = Modifier.padding(end = 16.dp))
        Text(
            text = stringResource(viewModel.titleText),
            style = MaterialTheme.typography.titleMediumEmphasized,
+12 −5
Original line number Diff line number Diff line
@@ -66,19 +66,26 @@ object NotificationRowPrimitives {

/** The Icon displayed at the start of any notification row. */
@Composable
fun BundleIcon(@DrawableRes drawable: Int?, collapsed: Boolean, modifier: Modifier = Modifier) {
fun BundleIcon(@DrawableRes drawable: Int?, large: Boolean, modifier: Modifier = Modifier) {
    val iconBackground = notificationProtectionColor()
    Box(
        modifier =
            modifier
                .size(if (collapsed) 40.dp else 24.dp)
                .background(color = iconBackground, shape = CircleShape)
            if (large) {
                modifier.size(40.dp).background(color = iconBackground, shape = CircleShape)
            } else {
                modifier.size(20.dp)
            }
    ) {
        if (drawable == null) return@Box
        Image(
            painter = painterResource(drawable),
            contentDescription = null,
            modifier = Modifier.fillMaxSize(.5f).align(Alignment.Center),
            modifier =
                if (large) {
                    Modifier.fillMaxSize(.5f).align(Alignment.Center)
                } else {
                    Modifier.padding(2.dp)
                },
            contentScale = ContentScale.Fit,
            colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.primary),
        )
+29 −35
Original line number Diff line number Diff line
@@ -107,7 +107,6 @@ public class NotificationChildrenContainer extends ViewGroup
    private float mDividerAlpha;

    private int mHeaderHeight;
    /** Margin needed at the top in the collapsed group, to allow space for the header text. */
    private int mCollapsedHeaderMargin;
    private int mAdditionalExpandedHeaderMargin;

@@ -195,13 +194,13 @@ public class NotificationChildrenContainer extends ViewGroup
            mHeaderHeight = res.getDimensionPixelSize(R.dimen.notification_2025_header_height);
            mCollapsedHeaderMargin = Notification.Builder.getContentMarginTop(getContext(),
                    R.dimen.notification_2025_children_container_margin_top);
            mAdditionalExpandedHeaderMargin = mHeaderHeight - mCollapsedHeaderMargin;
            mAdditionalExpandedHeaderMargin = getHeaderHeight() - getCollapsedHeaderMargin();
        } else {
            mCollapsedHeaderMargin = res.getDimensionPixelOffset(
                    R.dimen.notification_children_container_margin_top);
            mAdditionalExpandedHeaderMargin = res.getDimensionPixelOffset(
                    R.dimen.notification_children_container_top_padding);
            mHeaderHeight = mCollapsedHeaderMargin + getAdditionalExpandedHeaderMargin();
            mHeaderHeight = getCollapsedHeaderMargin() + getAdditionalExpandedHeaderMargin();
        }

        mCollapsedBottomPadding = res.getDimensionPixelOffset(
@@ -216,7 +215,7 @@ public class NotificationChildrenContainer extends ViewGroup
                res.getBoolean(R.bool.config_hideDividersDuringExpand);
        mTranslationForHeader = res.getDimensionPixelOffset(
                com.android.internal.R.dimen.notification_content_margin)
                - mCollapsedHeaderMargin;
                - getCollapsedHeaderMargin();
        mHybridGroupManager.initDimens();
        mMinSingleLineHeight = getResources().getDimensionPixelSize(
                R.dimen.conversation_single_line_face_pile_size);
@@ -285,7 +284,7 @@ public class NotificationChildrenContainer extends ViewGroup
                    newHeightSpec);
        }
        int dividerHeightSpec = MeasureSpec.makeMeasureSpec(mDividerHeight, MeasureSpec.EXACTLY);
        int height = mCollapsedHeaderMargin + getAdditionalExpandedHeaderMargin();
        int height = getCollapsedHeaderMargin() + getAdditionalExpandedHeaderMargin();
        int childCount =
                Math.min(mAttachedChildren.size(), getNumberOfChildrenWhenExpanded());
        int collapsedChildren = getMaxAllowedVisibleChildren(true /* likeCollapsed */);
@@ -310,7 +309,7 @@ public class NotificationChildrenContainer extends ViewGroup
            height = Math.min(height, size);
        }

        int headerHeightSpec = MeasureSpec.makeMeasureSpec(mHeaderHeight, MeasureSpec.EXACTLY);
        int headerHeightSpec = MeasureSpec.makeMeasureSpec(getHeaderHeight(), MeasureSpec.EXACTLY);
        if (mGroupHeader != null) {
            mGroupHeader.measure(widthMeasureSpec, headerHeightSpec);
        }
@@ -319,7 +318,7 @@ public class NotificationChildrenContainer extends ViewGroup
        }
        if (mBundleHeaderView != null) {
            mBundleHeaderView.measure(widthMeasureSpec,
                    MeasureSpec.makeMeasureSpec(mHeaderHeight, MeasureSpec.UNSPECIFIED));
                    MeasureSpec.makeMeasureSpec(getHeaderHeight(), MeasureSpec.UNSPECIFIED));
        }

        setMeasuredDimension(width, height);
@@ -529,7 +528,7 @@ public class NotificationChildrenContainer extends ViewGroup
    private void initBundleDimens() {
        Resources res = getResources();
        NotificationBundleUi.unsafeAssertInNewMode();
        mCollapsedHeaderMargin = mHeaderHeight;
        mCollapsedHeaderMargin = getHeaderHeight();
        mAdditionalExpandedHeaderMargin = 0;
        mCollapsedBottomPadding = 0;
        mDividerHeight = res.getDimensionPixelOffset(
@@ -612,13 +611,7 @@ public class NotificationChildrenContainer extends ViewGroup
    }

    public float getChildRenderingStartPosition() {
        // NOTE: if the non-bundle header is ever changed to have different expanded/collapsed
        // heights, we may want to remove this isBundle() check.
        if (isBundle() && mChildrenExpanded) {
            return mHeaderHeight + getAdditionalExpandedHeaderMargin() + mDividerHeight;
        } else {
            return mHeaderHeight + mDividerHeight;
        }
        return getHeaderHeight() + mDividerHeight;
    }

    /**
@@ -780,12 +773,12 @@ public class NotificationChildrenContainer extends ViewGroup
    private int getIntrinsicHeight(float maxAllowedVisibleChildren) {
        if (showingAsLowPriority()) {
            if (AsyncGroupHeaderViewInflation.isEnabled()) {
                return mHeaderHeight;
                return getHeaderHeight();
            } else {
                return mMinimizedGroupHeader.getHeight();
            }
        }
        int intrinsicHeight = mCollapsedHeaderMargin + mCurrentHeaderTranslation;
        int intrinsicHeight = getCollapsedHeaderMargin() + mCurrentHeaderTranslation;
        int visibleChildren = 0;
        int childCount = mAttachedChildren.size();
        boolean firstChild = true;
@@ -831,7 +824,7 @@ public class NotificationChildrenContainer extends ViewGroup

        if (Flags.notificationChildrenContainerMinHeight()) {
            // The height should at the very minimum be able to accommodate the header.
            return Math.max(mHeaderHeight, intrinsicHeight);
            return Math.max(getHeaderHeight(), intrinsicHeight);
        } else {
            return intrinsicHeight;
        }
@@ -844,7 +837,7 @@ public class NotificationChildrenContainer extends ViewGroup
     */
    public void updateState(ExpandableViewState parentState) {
        int childCount = mAttachedChildren.size();
        int yPosition = mCollapsedHeaderMargin + mCurrentHeaderTranslation;
        int yPosition = getCollapsedHeaderMargin() + mCurrentHeaderTranslation;
        boolean firstChild = true;
        int maxAllowedVisibleChildren = getMaxAllowedVisibleChildren();
        int lastVisibleIndex = maxAllowedVisibleChildren - 1;
@@ -943,7 +936,7 @@ public class NotificationChildrenContainer extends ViewGroup
                }
            } else {
                mGroupOverFlowState.setYTranslation(
                        mGroupOverFlowState.getYTranslation() + mCollapsedHeaderMargin);
                        mGroupOverFlowState.getYTranslation() + getCollapsedHeaderMargin());
                mGroupOverFlowState.setAlpha(0.0f);
            }
        }
@@ -1471,7 +1464,7 @@ public class NotificationChildrenContainer extends ViewGroup
            return getMinHeight(NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED, true
                    /* likeHighPriority */);
        }
        int maxContentHeight = mCollapsedHeaderMargin + mCurrentHeaderTranslation
        int maxContentHeight = getCollapsedHeaderMargin() + mCurrentHeaderTranslation
                + getAdditionalExpandedHeaderMargin();
        int visibleChildren = 0;
        int childCount = mAttachedChildren.size();
@@ -1535,7 +1528,7 @@ public class NotificationChildrenContainer extends ViewGroup
    }

    private int getVisibleChildrenExpandHeight() {
        int intrinsicHeight = mCollapsedHeaderMargin + mCurrentHeaderTranslation
        int intrinsicHeight = getCollapsedHeaderMargin() + mCurrentHeaderTranslation
                + getAdditionalExpandedHeaderMargin() + mDividerHeight;
        int visibleChildren = 0;
        int childCount = mAttachedChildren.size();
@@ -1593,7 +1586,7 @@ public class NotificationChildrenContainer extends ViewGroup
            int headerTranslation) {
        if (!likeHighPriority && showingAsLowPriority()) {
            if (AsyncGroupHeaderViewInflation.isEnabled()) {
                return mHeaderHeight;
                return getHeaderHeight();
            }
            if (mMinimizedGroupHeader == null) {
                Log.e(TAG, "getMinHeight: low priority header is null", new Exception());
@@ -1601,7 +1594,7 @@ public class NotificationChildrenContainer extends ViewGroup
            }
            return mMinimizedGroupHeader.getHeight();
        }
        int minExpandHeight = mCollapsedHeaderMargin + headerTranslation;
        int minExpandHeight = getCollapsedHeaderMargin() + headerTranslation;
        int visibleChildren = 0;
        boolean firstChild = true;
        int childCount = mAttachedChildren.size();
@@ -1636,7 +1629,7 @@ public class NotificationChildrenContainer extends ViewGroup

        if (Flags.notificationChildrenContainerMinHeight()) {
            // The height should at the very minimum be able to accommodate the header.
            return Math.max(minExpandHeight, mHeaderHeight);
            return Math.max(minExpandHeight, getHeaderHeight());
        } else {
            return minExpandHeight;
        }
@@ -1705,7 +1698,7 @@ public class NotificationChildrenContainer extends ViewGroup
    }

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

        for (int i = 0; i < mAttachedChildren.size(); i++) {
@@ -1903,14 +1896,15 @@ public class NotificationChildrenContainer extends ViewGroup
     * 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;
    }

    private int getHeaderHeight() {
        return isBundle() ? mBundleHeaderView.getMeasuredHeight() : mHeaderHeight;
    }

    /** Margin needed at the top in the collapsed group, to allow space for the header text. */
    private int getCollapsedHeaderMargin() {
        return isBundle() ? getHeaderHeight() : mCollapsedHeaderMargin;
    }
}