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

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

[Notif redesign] Remove action_list_margin_target

This special ID for adding an extra margin for actions is no longer
needed. The special margin we added for smart replies is also not
needed anymore.

Instead, we're keeping the actions_container visible to act like a
margin for the notification when there are no actions.

Bug: 378660052
Test: manual + screenshot tests
Flag: android.app.notifications_redesign_templates
Change-Id: If434b7cde20102ad0740681aaf94450324dd801e
parent 0f3b1103
Loading
Loading
Loading
Loading
+37 −37
Original line number Diff line number Diff line
@@ -6470,10 +6470,12 @@ public class Notification implements Parcelable
            contentView.setViewVisibility(R.id.notification_material_reply_text_3, View.GONE);
            contentView.setTextViewText(R.id.notification_material_reply_text_3, null);
            if (!notificationsRedesignTemplates()) {
                // This may get erased by bindSnoozeAction, or if we're showing the bubble icon
                contentView.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target,
                        RemoteViews.MARGIN_BOTTOM, R.dimen.notification_content_margin);
            }
        }
        private boolean bindSnoozeAction(RemoteViews contentView, StandardTemplateParams p) {
            boolean hideSnoozeButton = mN.isFgsOrUij()
@@ -6489,7 +6491,7 @@ public class Notification implements Parcelable
            final boolean snoozeEnabled = !hideSnoozeButton
                    && mContext.getContentResolver() != null
                    && isSnoozeSettingEnabled();
            if (snoozeEnabled) {
            if (!notificationsRedesignTemplates() && snoozeEnabled) {
                contentView.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target,
                        RemoteViews.MARGIN_BOTTOM, 0);
            }
@@ -6569,44 +6571,18 @@ public class Notification implements Parcelable
            }
            boolean validRemoteInput = false;
            // With the new design, the actions_container should always be visible to act as padding
            // when there are no actions. We're making its child GONE instead.
            int actionsContainerForVisibilityChange = notificationsRedesignTemplates()
                    ? R.id.actions_container_layout : R.id.actions_container;
            if (numActions > 0 && !p.mHideActions) {
                contentView.setViewVisibility(R.id.actions_container, View.VISIBLE);
                contentView.setViewVisibility(actionsContainerForVisibilityChange, View.VISIBLE);
                contentView.setViewVisibility(R.id.actions, View.VISIBLE);
                contentView.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target,
                        RemoteViews.MARGIN_BOTTOM, 0);
                if (notificationsRedesignTemplates()) {
                    // No need for additional space under smart replies/smart actions.
                    contentView.setViewLayoutMarginDimen(R.id.smart_reply_container,
                            RemoteViews.MARGIN_BOTTOM, 0);
                    if (emphasizedMode) {
                        // Emphasized actions look similar to smart replies, so let's use the same
                        // margins.
                        contentView.setViewLayoutMarginDimen(R.id.actions_container,
                                RemoteViews.MARGIN_TOP,
                                R.dimen.notification_2025_smart_reply_container_margin);
                        contentView.setViewLayoutMarginDimen(R.id.actions_container,
                                RemoteViews.MARGIN_BOTTOM,
                                R.dimen.notification_2025_smart_reply_container_margin);
                    } else {
                        contentView.setViewLayoutMarginDimen(R.id.actions_container,
                                RemoteViews.MARGIN_TOP, 0);
                        contentView.setViewLayoutMarginDimen(R.id.actions_container,
                                RemoteViews.MARGIN_BOTTOM,
                                R.dimen.notification_2025_action_list_margin_bottom);
                    }
                }
                updateMarginsForActions(contentView, emphasizedMode);
                validRemoteInput = populateActionsContainer(contentView, p, nonContextualActions,
                        numActions, emphasizedMode);
            } else {
                contentView.setViewVisibility(R.id.actions_container, View.GONE);
                if (notificationsRedesignTemplates() && !snoozeEnabled) {
                    // Make sure smart replies & smart actions have enough space at the bottom
                    // (if present) when there are no actions. This should be set to 0 if we're
                    // showing the snooze or bubble buttons.
                    contentView.setViewLayoutMarginDimen(R.id.smart_reply_container,
                            RemoteViews.MARGIN_BOTTOM,
                            R.dimen.notification_2025_smart_reply_container_margin);
                }
                contentView.setViewVisibility(actionsContainerForVisibilityChange, View.GONE);
            }
            RemoteInputHistoryItem[] replyText = getParcelableArrayFromBundle(
@@ -6652,6 +6628,30 @@ public class Notification implements Parcelable
            return contentView;
        }
        private void updateMarginsForActions(RemoteViews contentView, boolean emphasizedMode) {
            if (notificationsRedesignTemplates()) {
                if (emphasizedMode) {
                    // Emphasized actions look similar to smart replies, so let's use the same
                    // margins.
                    contentView.setViewLayoutMarginDimen(R.id.actions_container,
                            RemoteViews.MARGIN_TOP,
                            R.dimen.notification_2025_smart_reply_container_margin);
                    contentView.setViewLayoutMarginDimen(R.id.actions_container,
                            RemoteViews.MARGIN_BOTTOM,
                            R.dimen.notification_2025_smart_reply_container_margin);
                } else {
                    contentView.setViewLayoutMarginDimen(R.id.actions_container,
                            RemoteViews.MARGIN_TOP, 0);
                    contentView.setViewLayoutMarginDimen(R.id.actions_container,
                            RemoteViews.MARGIN_BOTTOM,
                            R.dimen.notification_2025_action_list_margin_bottom);
                }
            } else {
                contentView.setViewLayoutMarginDimen(R.id.notification_action_list_margin_target,
                        RemoteViews.MARGIN_BOTTOM, 0);
            }
        }
        private boolean populateActionsContainer(RemoteViews contentView, StandardTemplateParams p,
                List<Action> nonContextualActions, int numActions, boolean emphasizedMode) {
            boolean validRemoteInput = false;
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:layout_marginBottom="@dimen/notification_2025_action_list_margin_bottom"
    android:minHeight="@dimen/notification_2025_action_list_min_height"
    >

    <LinearLayout
+0 −1
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@
            android:id="@+id/notification_headerless_view_column"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:layout_marginVertical="@dimen/notification_2025_reduced_margin"
            android:orientation="vertical"
+0 −2
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@
                    android:id="@+id/notification_headerless_view_column"
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_weight="1"
                    android:layout_marginBottom="@dimen/notification_2025_margin"
                    android:layout_marginTop="@dimen/notification_2025_margin"
@@ -174,7 +173,6 @@
        </FrameLayout>

        <LinearLayout
            android:id="@+id/notification_action_list_margin_target"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="-20dp"
+5 −13
Original line number Diff line number Diff line
@@ -78,17 +78,10 @@
                android:clipChildren="false"
                >

                <!--
                  NOTE: because messaging will always have 2 lines, this LinearLayout should NOT
                  have the id/notification_headerless_view_column, as that is used for modifying
                   vertical margins to accommodate the single-line state that base supports
                  -->
                <LinearLayout
                    android:layout_width="0px"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
                    android:layout_weight="1"
                    android:layout_marginBottom="@dimen/notification_2025_margin"
                    android:layout_marginTop="@dimen/notification_2025_margin"
                    android:layout_marginStart="@dimen/notification_2025_content_margin_start"
                    android:clipChildren="false"
@@ -150,7 +143,6 @@
                    android:layout_height="@dimen/notification_right_icon_size"
                    android:layout_gravity="center_vertical|end"
                    android:layout_marginTop="@dimen/notification_2025_margin"
                    android:layout_marginBottom="@dimen/notification_2025_margin"
                    android:layout_marginStart="@dimen/notification_2025_right_icon_content_margin"
                    android:forceHasOverlappingRendering="false"
                    android:spacing="0dp"
@@ -197,7 +189,6 @@
        </FrameLayout>

        <LinearLayout
            android:id="@+id/notification_action_list_margin_target"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="-20dp"
@@ -211,5 +202,6 @@
                android:layout_marginEnd="@dimen/notification_content_margin_end" />
            <include layout="@layout/notification_2025_action_list" />
        </LinearLayout>

    </LinearLayout>
</com.android.internal.widget.ConversationLayout>
Loading