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

Commit 8b43a111 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

[RONs] Move right icon to right available space

The expander is not shown for RONs. This CL positions right icon to the right available space from expander by respecting its horizontal paddings.

Bug: 393369727
Test: Post a RON with long header content and large icon and see large icon is shown on the right available space.
Flag: com.android.systemui.ui_rich_ongoing_force_expanded
Change-Id: I37279967d0719d004a2e0ba1e409d49b8aa4935b
parent dbd9fa2f
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -998,6 +998,10 @@ public class NotificationContentInflater implements NotificationRowContentBinder
            entry.setPromotedNotificationContentModel(result.mPromotedContent);
        }

        if (PromotedNotificationUiForceExpanded.isEnabled()) {
            row.setPromotedOngoing(entry.isOngoingPromoted());
        }

        boolean setRepliesAndActions = true;
        if ((reInflateFlags & FLAG_CONTENT_VIEW_CONTRACTED) != 0) {
            if (result.inflatedContentView != null) {
@@ -1130,9 +1134,6 @@ public class NotificationContentInflater implements NotificationRowContentBinder

        entry.setHeadsUpStatusBarText(result.headsUpStatusBarText);
        entry.setHeadsUpStatusBarTextPublic(result.headsUpStatusBarTextPublic);
        if (PromotedNotificationUiForceExpanded.isEnabled()) {
            row.setPromotedOngoing(entry.isOngoingPromoted());
        }

        Trace.endAsyncSection(APPLY_TRACE_METHOD, System.identityHashCode(row));
        if (endListener != null) {
+37 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ 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;
@@ -42,6 +43,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ContrastColorUtil;
import com.android.internal.widget.NotificationActionListLayout;
import com.android.systemui.Dependency;
import com.android.systemui.Flags;
import com.android.systemui.UiOffloadThread;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.CrossFadeHelper;
@@ -51,6 +53,7 @@ import com.android.systemui.statusbar.notification.ImageTransformState;
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.util.DimensionKt;

import java.util.function.Consumer;

@@ -186,9 +189,43 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
        mActions = mView.findViewById(com.android.internal.R.id.actions);
        mRemoteInputHistory = mView.findViewById(
                com.android.internal.R.id.notification_material_reply_container);

        adjustTitleAndRightIconForPromotedOngoing();
        updatePendingIntentCancellations();
    }

    private void adjustTitleAndRightIconForPromotedOngoing() {
        if (Flags.uiRichOngoingForceExpanded() && 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);

            // align top line view to start of the right icon.
            final int iconSize = mView.getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.notification_right_icon_size);
            final int marginEnd = 2 * horizontalMargin + iconSize;
            mNotificationTopLine.setHeaderTextMarginEnd(marginEnd);

            // title has too much margin on the right, so we need to reduce it
            if (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();