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

Commit a45cfd8f authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

[Notif redesign] Allow space for entire header in expanded groups

When a group is expanded, the header should be visible at its full
height. Adjust the dimensions used in NotificationChildrenContainer
accordingly to achieve that.

I also renamed some of these fields to make it more clear what they
actually represent:
- mNotificationHeaderMargin is now mCollapsedHeaderMargin
- mNotificationTopPadding is now mAdditionalExpandedHeaderMargin

Bug: 378660052
Test: expand groups both by tapping and dragging; screenshot tests tbd
Flag: android.app.notifications_redesign_templates
Change-Id: If3ef79484a98311da4ee5404f610142255cb5dde
parent b3f8bf0a
Loading
Loading
Loading
Loading
+40 −35
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.os.Trace;
import android.service.notification.StatusBarNotification;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.NotificationHeaderView;
import android.view.View;
@@ -93,9 +92,16 @@ public class NotificationChildrenContainer extends ViewGroup
    private int mChildPadding;
    private int mDividerHeight;
    private float mDividerAlpha;
    private int mNotificationHeaderMargin;

    private int mNotificationTopPadding;
    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;
    private boolean mChildrenExpanded;
    private ExpandableNotificationRow mContainingNotification;
@@ -105,7 +111,6 @@ public class NotificationChildrenContainer extends ViewGroup
    private boolean mUserLocked;
    private int mActualHeight;
    private boolean mNeverAppliedGroupState;
    private int mHeaderHeight;

    /**
     * Whether or not individual notifications that are part of this container will have shadows.
@@ -168,15 +173,18 @@ public class NotificationChildrenContainer extends ViewGroup
        mDividerHeight = res.getDimensionPixelOffset(
                R.dimen.notification_children_container_divider_height);
        mDividerAlpha = res.getFloat(R.dimen.notification_divider_alpha);
        mNotificationHeaderMargin = notificationsRedesignTemplates()
                ? Notification.Builder.getContentMarginTop(getContext(),
                    R.dimen.notification_2025_children_container_margin_top)
                : res.getDimensionPixelOffset(R.dimen.notification_children_container_margin_top);
        mNotificationTopPadding = res.getDimensionPixelOffset(
        if (notificationsRedesignTemplates()) {
            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;
        } else {
            mCollapsedHeaderMargin = res.getDimensionPixelOffset(
                    R.dimen.notification_children_container_margin_top);
            mAdditionalExpandedHeaderMargin = res.getDimensionPixelOffset(
                    R.dimen.notification_children_container_top_padding);
        mHeaderHeight = notificationsRedesignTemplates()
                ? res.getDimensionPixelSize(R.dimen.notification_2025_header_height)
                : mNotificationHeaderMargin + mNotificationTopPadding;
            mHeaderHeight = mCollapsedHeaderMargin + mAdditionalExpandedHeaderMargin;
        }
        mCollapsedBottomPadding = res.getDimensionPixelOffset(
                R.dimen.notification_children_collapsed_bottom_padding);
        mEnableShadowOnChildNotifications =
@@ -189,7 +197,7 @@ public class NotificationChildrenContainer extends ViewGroup
                res.getBoolean(R.bool.config_hideDividersDuringExpand);
        mTranslationForHeader = res.getDimensionPixelOffset(
                com.android.internal.R.dimen.notification_content_margin)
                - mNotificationHeaderMargin;
                - mCollapsedHeaderMargin;
        mHybridGroupManager.initDimens();
        mMinSingleLineHeight = getResources().getDimensionPixelSize(
                R.dimen.conversation_single_line_face_pile_size);
@@ -251,7 +259,7 @@ public class NotificationChildrenContainer extends ViewGroup
                    newHeightSpec);
        }
        int dividerHeightSpec = MeasureSpec.makeMeasureSpec(mDividerHeight, MeasureSpec.EXACTLY);
        int height = mNotificationHeaderMargin + mNotificationTopPadding;
        int height = mCollapsedHeaderMargin + mAdditionalExpandedHeaderMargin;
        int childCount =
                Math.min(mAttachedChildren.size(), NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED);
        int collapsedChildren = getMaxAllowedVisibleChildren(true /* likeCollapsed */);
@@ -705,7 +713,7 @@ public class NotificationChildrenContainer extends ViewGroup
                return mMinimizedGroupHeader.getHeight();
            }
        }
        int intrinsicHeight = mNotificationHeaderMargin + mCurrentHeaderTranslation;
        int intrinsicHeight = mCollapsedHeaderMargin + mCurrentHeaderTranslation;
        int visibleChildren = 0;
        int childCount = mAttachedChildren.size();
        boolean firstChild = true;
@@ -729,11 +737,11 @@ public class NotificationChildrenContainer extends ViewGroup
                if (mUserLocked) {
                    intrinsicHeight += NotificationUtils.interpolate(
                            0,
                            mNotificationTopPadding + mDividerHeight,
                            mAdditionalExpandedHeaderMargin + mDividerHeight,
                            expandFactor);
                } else {
                    intrinsicHeight += childrenExpanded
                            ? mNotificationTopPadding + mDividerHeight
                            ? mAdditionalExpandedHeaderMargin + mDividerHeight
                            : 0;
                }
                firstChild = false;
@@ -758,7 +766,7 @@ public class NotificationChildrenContainer extends ViewGroup
     */
    public void updateState(ExpandableViewState parentState) {
        int childCount = mAttachedChildren.size();
        int yPosition = mNotificationHeaderMargin + mCurrentHeaderTranslation;
        int yPosition = mCollapsedHeaderMargin + mCurrentHeaderTranslation;
        boolean firstChild = true;
        int maxAllowedVisibleChildren = getMaxAllowedVisibleChildren();
        int lastVisibleIndex = maxAllowedVisibleChildren - 1;
@@ -786,10 +794,12 @@ public class NotificationChildrenContainer extends ViewGroup
                if (expandingToExpandedGroup) {
                    yPosition += NotificationUtils.interpolate(
                            0,
                            mNotificationTopPadding + mDividerHeight,
                            mAdditionalExpandedHeaderMargin + mDividerHeight,
                            expandFactor);
                } else {
                    yPosition += mChildrenExpanded ? mNotificationTopPadding + mDividerHeight : 0;
                    yPosition += mChildrenExpanded
                            ? mAdditionalExpandedHeaderMargin + mDividerHeight
                            : 0;
                }
                firstChild = false;
            }
@@ -852,7 +862,7 @@ public class NotificationChildrenContainer extends ViewGroup
                }
            } else {
                mGroupOverFlowState.setYTranslation(
                        mGroupOverFlowState.getYTranslation() + mNotificationHeaderMargin);
                        mGroupOverFlowState.getYTranslation() + mCollapsedHeaderMargin);
                mGroupOverFlowState.setAlpha(0.0f);
            }
        }
@@ -1301,8 +1311,8 @@ public class NotificationChildrenContainer extends ViewGroup
            return getMinHeight(NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED, true
                    /* likeHighPriority */);
        }
        int maxContentHeight = mNotificationHeaderMargin + mCurrentHeaderTranslation
                + mNotificationTopPadding;
        int maxContentHeight = mCollapsedHeaderMargin + mCurrentHeaderTranslation
                + mAdditionalExpandedHeaderMargin;
        int visibleChildren = 0;
        int childCount = mAttachedChildren.size();
        for (int i = 0; i < childCount; i++) {
@@ -1364,8 +1374,8 @@ public class NotificationChildrenContainer extends ViewGroup
    }

    private int getVisibleChildrenExpandHeight() {
        int intrinsicHeight = mNotificationHeaderMargin + mCurrentHeaderTranslation
                + mNotificationTopPadding + mDividerHeight;
        int intrinsicHeight = mCollapsedHeaderMargin + mCurrentHeaderTranslation
                + mAdditionalExpandedHeaderMargin + mDividerHeight;
        int visibleChildren = 0;
        int childCount = mAttachedChildren.size();
        int maxAllowedVisibleChildren = getMaxAllowedVisibleChildren(true /* forceCollapsed */);
@@ -1430,7 +1440,7 @@ public class NotificationChildrenContainer extends ViewGroup
            }
            return mMinimizedGroupHeader.getHeight();
        }
        int minExpandHeight = mNotificationHeaderMargin + headerTranslation;
        int minExpandHeight = mCollapsedHeaderMargin + headerTranslation;
        int visibleChildren = 0;
        boolean firstChild = true;
        int childCount = mAttachedChildren.size();
@@ -1518,18 +1528,13 @@ public class NotificationChildrenContainer extends ViewGroup
            // The overflow number is not used, so its color is irrelevant; skip this
            return;
        }
        int color = mContainingNotification.getNotificationColor();
        Resources.Theme theme = new ContextThemeWrapper(mContext,
                com.android.internal.R.style.Theme_DeviceDefault_DayNight).getTheme();

        color = mContext.getColor(com.android.internal.R.color.materialColorPrimary);

        int color = mContext.getColor(com.android.internal.R.color.materialColorPrimary);
        mHybridGroupManager.setOverflowNumberColor(mOverflowNumber, color);
    }

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

        for (int i = 0; i < mAttachedChildren.size(); i++) {
            ExpandableNotificationRow child = mAttachedChildren.get(i);