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

Commit 11318d3b authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz Committed by Android (Google) Code Review
Browse files

Merge "[RONs] Restore large icon margin for expanded templates" into main

parents b2722740 dd614622
Loading
Loading
Loading
Loading
+26 −5
Original line number Diff line number Diff line
@@ -6216,14 +6216,19 @@ public class Notification implements Parcelable
            final float contentMarginDp = resources.getDimension(
                    R.dimen.notification_content_margin_end) / density;
            float spaceForExpanderDp;
            if (mN.isPromotedOngoing()) {
                spaceForExpanderDp = 0;
            } else {
                final int expanderSizeRes;
                if (notificationsRedesignTemplates()) {
                spaceForExpanderDp = resources.getDimension(
                        R.dimen.notification_2025_right_icon_expanded_margin_end) / density
                        - contentMarginDp;
                    expanderSizeRes = R.dimen.notification_2025_right_icon_expanded_margin_end;
                } else {
                    expanderSizeRes =  R.dimen.notification_header_expand_icon_size;
                }
                spaceForExpanderDp = resources.getDimension(
                        R.dimen.notification_header_expand_icon_size) / density - contentMarginDp;
                        expanderSizeRes) / density - contentMarginDp;
            }
            final float viewHeightDp = resources.getDimension(
                    R.dimen.notification_right_icon_size) / density;
            float viewWidthDp = viewHeightDp;  // icons are 1:1 by default
@@ -6286,6 +6291,22 @@ public class Notification implements Parcelable
                contentView.setImageViewIcon(R.id.right_icon, rightIcon);
                contentView.setIntTag(R.id.right_icon, R.id.tag_keep_when_showing_left_icon,
                        isPromotedPicture ? 1 : 0);
                if (Flags.uiRichOngoing() && !p.mHeaderless) {
                    final int largeIconMarginEnd;
                    if (mN.isPromotedOngoing()) {
                        largeIconMarginEnd = R.dimen.notification_content_margin;
                    } else {
                        if (notificationsRedesignTemplates()) {
                            largeIconMarginEnd =
                                    R.dimen.notification_2025_right_icon_expanded_margin_end;
                        } else {
                            largeIconMarginEnd = R.dimen.notification_header_expand_icon_size;
                        }
                    }
                    contentView.setViewLayoutMarginDimen(
                            R.id.right_icon, RemoteViews.MARGIN_END, largeIconMarginEnd);
                }
                processLargeLegacyIcon(rightIcon, contentView, p);
            } else {
                // The "reset" doesn't clear the drawable, so we do it here.  This clear is
+0 −48
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.graphics.drawable.Icon;
import android.service.notification.StatusBarNotification;
import android.util.ArraySet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
@@ -53,7 +52,6 @@ import com.android.systemui.statusbar.notification.TransformState;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.HybridNotificationView;
import com.android.systemui.statusbar.notification.shared.NotificationBundleUi;
import com.android.systemui.util.DimensionKt;

import java.util.function.Consumer;

@@ -190,55 +188,9 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
        mRemoteInputHistory = mView.findViewById(
                com.android.internal.R.id.notification_material_reply_container);

        adjustTitleAndRightIconForPromotedOngoing();
        updatePendingIntentCancellations();
    }

    private void adjustTitleAndRightIconForPromotedOngoing() {
        if (mRow.isPromotedOngoing() && mRightIcon != null) {
            final int horizontalMargin;
            if (notificationsRedesignTemplates()) {
                horizontalMargin = mView.getResources().getDimensionPixelSize(
                    com.android.internal.R.dimen.notification_2025_margin);
            } else {
                horizontalMargin = (int) DimensionKt.dpToPx(16, mView.getContext());
            }

            // position right icon to the right available space from expander.
            final ViewGroup.MarginLayoutParams rightIconLP =
                (ViewGroup.MarginLayoutParams) mRightIcon.getLayoutParams();
            rightIconLP.setMarginEnd(horizontalMargin);
            mRightIcon.setLayoutParams(rightIconLP);

            // if there is no title and topline view, there is nothing to adjust.
            if (mNotificationTopLine == null && mTitle == null) {
                return;
            }

            // align top line view to start of the right icon.
            final int iconSize = rightIconLP.width;
            final int marginEnd = 2 * horizontalMargin + iconSize;
            final boolean isTitleInTopLine;
            // set margin end for the top line view if it exists
            if (mNotificationTopLine != null) {
                mNotificationTopLine.setHeaderTextMarginEnd(marginEnd);
                isTitleInTopLine = mNotificationTopLine.isTitlePresent();
            } else {
                isTitleInTopLine = false;
            }

            // Margin is to be applied to the title only when it is in the body,
            // but not in the title.
            // title has too much margin on the right, so we need to reduce it
            if (!isTitleInTopLine && mTitle != null) {
                final ViewGroup.MarginLayoutParams titleLP =
                    (ViewGroup.MarginLayoutParams) mTitle.getLayoutParams();
                titleLP.setMarginEnd(marginEnd);
                mTitle.setLayoutParams(titleLP);
           }
        }
    }

    @Nullable
    protected final Icon getLargeIcon(Notification n) {
        Icon modernLargeIcon = n.getLargeIcon();