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

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

[Notif redesign] Align messaging content under app icon

For most templates, the content needs to come directly under the top
line text in the expanded view, so we calculate a special margin to
align things correctly. For messaging notifications however, since they
display the avatar on the left side below the app icon, we need to leave
enough space between the header with the icon and the actual content to
avoid the icons overlapping.

Bug: 378660052
Test: visual test, screenshot tests to come later
Flag: android.app.notifications_redesign_templates
Change-Id: Iae9bfcd4de08014660bbb91c6ca7e28866c842e5
parent 1f32e86b
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -5995,8 +5995,10 @@ public class Notification implements Parcelable
            setHeaderlessVerticalMargins(contentView, p, hasSecondLine);
            setHeaderlessVerticalMargins(contentView, p, hasSecondLine);
            // Update margins to leave space for the top line (but not for headerless views like
            // Update margins to leave space for the top line (but not for headerless views like
            // HUNS, which use a different layout that already accounts for that).
            // HUNS, which use a different layout that already accounts for that). Templates that
            if (Flags.notificationsRedesignTemplates() && !p.mHeaderless) {
            // have content that will be displayed under the small icon also use a different margin.
            if (Flags.notificationsRedesignTemplates()
                    && !p.mHeaderless && !p.mHasContentInLeftMargin) {
                int margin = getContentMarginTop(mContext,
                int margin = getContentMarginTop(mContext,
                        R.dimen.notification_2025_content_margin_top);
                        R.dimen.notification_2025_content_margin_top);
                contentView.setViewLayoutMargin(R.id.notification_main_column,
                contentView.setViewLayoutMargin(R.id.notification_main_column,
@@ -9498,7 +9500,8 @@ public class Notification implements Parcelable
                    .text(null)
                    .text(null)
                    .hideLeftIcon(isOneToOne)
                    .hideLeftIcon(isOneToOne)
                    .hideRightIcon(hideRightIcons || isOneToOne)
                    .hideRightIcon(hideRightIcons || isOneToOne)
                    .headerTextSecondary(isHeaderless ? null : conversationTitle);
                    .headerTextSecondary(isHeaderless ? null : conversationTitle)
                    .hasContentInLeftMargin(true);
            RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(
            RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(
                    isConversationLayout
                    isConversationLayout
                            ? mBuilder.getConversationLayoutResource()
                            ? mBuilder.getConversationLayoutResource()
@@ -14669,6 +14672,7 @@ public class Notification implements Parcelable
        Icon mPromotedPicture;
        Icon mPromotedPicture;
        boolean mCallStyleActions;
        boolean mCallStyleActions;
        boolean mAllowTextWithProgress;
        boolean mAllowTextWithProgress;
        boolean mHasContentInLeftMargin;
        int mTitleViewId;
        int mTitleViewId;
        int mTextViewId;
        int mTextViewId;
        @Nullable CharSequence mTitle;
        @Nullable CharSequence mTitle;
@@ -14694,6 +14698,7 @@ public class Notification implements Parcelable
            mPromotedPicture = null;
            mPromotedPicture = null;
            mCallStyleActions = false;
            mCallStyleActions = false;
            mAllowTextWithProgress = false;
            mAllowTextWithProgress = false;
            mHasContentInLeftMargin = false;
            mTitleViewId = R.id.title;
            mTitleViewId = R.id.title;
            mTextViewId = R.id.text;
            mTextViewId = R.id.text;
            mTitle = null;
            mTitle = null;
@@ -14760,6 +14765,11 @@ public class Notification implements Parcelable
            return this;
            return this;
        }
        }
        public StandardTemplateParams hasContentInLeftMargin(boolean hasContentInLeftMargin) {
            mHasContentInLeftMargin = hasContentInLeftMargin;
            return this;
        }
        final StandardTemplateParams hideSnoozeButton(boolean hideSnoozeButton) {
        final StandardTemplateParams hideSnoozeButton(boolean hideSnoozeButton) {
            this.mHideSnoozeButton = hideSnoozeButton;
            this.mHideSnoozeButton = hideSnoozeButton;
            return this;
            return this;
+1 −2
Original line number Original line Diff line number Diff line
@@ -36,14 +36,13 @@
            android:clipChildren="false"
            android:clipChildren="false"
            android:orientation="vertical">
            android:orientation="vertical">


        <!-- Note: the top margin is being set in code based on the estimated space needed for
        the header text. -->
        <com.android.internal.widget.RemeasuringLinearLayout
        <com.android.internal.widget.RemeasuringLinearLayout
            android:id="@+id/notification_main_column"
            android:id="@+id/notification_main_column"
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:layout_gravity="top"
            android:layout_weight="1"
            android:layout_weight="1"
            android:layout_marginTop="@dimen/notification_2025_header_height"
            android:layout_marginEnd="@dimen/notification_content_margin_end"
            android:layout_marginEnd="@dimen/notification_content_margin_end"
            android:orientation="vertical"
            android:orientation="vertical"
            android:clipChildren="false"
            android:clipChildren="false"