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

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

[Notif redesign] Expander: highlight unopened groups

Highlight the expand button for groups that have never been expanded.

Note that we may also want to consider highlighting the pill when
there's an unseen notification in the group, but we can do that as a
follow-up.

There's also a KI where if a minimized group is expanded, then the shade is closed and re-opened, it gets re-inflated again with the highlighted button.

Bug: 378660052
Test: visual test, screenshot tests to come later
Flag: android.app.notifications_redesign_templates
Change-Id: Ib628f9546bf540020f71bc83bc8f4c413f30afe6
parent 81025667
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -6204,7 +6204,7 @@ public class Notification implements Parcelable
            int textColor = Colors.flattenAlpha(getPrimaryTextColor(p), pillColor);
            contentView.setInt(R.id.expand_button, "setDefaultTextColor", textColor);
            contentView.setInt(R.id.expand_button, "setDefaultPillColor", pillColor);
            // Use different highlighted colors for conversations' unread count
            // Use different highlighted colors for e.g. unopened groups
            if (p.mHighlightExpander) {
                pillColor = Colors.flattenAlpha(
                        getColors(p).getTertiaryFixedDimAccentColor(), bgColor);
@@ -6801,6 +6801,8 @@ public class Notification implements Parcelable
        public RemoteViews makeNotificationGroupHeader() {
            return makeNotificationHeader(mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_GROUP_HEADER)
                    // Highlight group expander until the group is first opened
                    .highlightExpander(Flags.notificationsRedesignTemplates())
                    .fillTextsFrom(this));
        }
@@ -6970,12 +6972,14 @@ public class Notification implements Parcelable
         * @param useRegularSubtext uses the normal subtext set if there is one available. Otherwise
         *                          a new subtext is created consisting of the content of the
         *                          notification.
         * @param highlightExpander whether the expander should use the highlighted colors
         * @hide
         */
        public RemoteViews makeLowPriorityContentView(boolean useRegularSubtext) {
        public RemoteViews makeLowPriorityContentView(boolean useRegularSubtext,
                boolean highlightExpander) {
            StandardTemplateParams p = mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_MINIMIZED)
                    .highlightExpander(false)
                    .highlightExpander(highlightExpander)
                    .fillTextsFrom(this);
            if (!useRegularSubtext || TextUtils.isEmpty(p.mSubText)) {
                p.summaryText(createSummaryText());
+37 −11
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ public class NotificationExpandButton extends FrameLayout {
    private int mDefaultTextColor;
    private int mHighlightPillColor;
    private int mHighlightTextColor;
    // Track whether this ever had mExpanded = true, so that we don't highlight it anymore.
    private boolean mWasExpanded = false;

    public NotificationExpandButton(Context context) {
        this(context, null, 0, 0);
@@ -134,6 +136,7 @@ public class NotificationExpandButton extends FrameLayout {
        int contentDescriptionId;
        if (mExpanded) {
            if (notificationsRedesignTemplates()) {
                mWasExpanded = true;
                drawableId = R.drawable.ic_notification_2025_collapse;
            } else {
                drawableId = R.drawable.ic_collapse_notification;
@@ -153,6 +156,8 @@ public class NotificationExpandButton extends FrameLayout {
        if (!notificationsRedesignTemplates()) {
            // changing the expanded state can affect the number display
            updateNumber();
        } else {
            updateColors();
        }
    }

@@ -192,7 +197,27 @@ public class NotificationExpandButton extends FrameLayout {
        );
    }

    /**
     * Use highlight colors for the expander for groups (when the number is showing) that haven't
     * been opened before, as long as the colors are available.
     */
    private boolean shouldBeHighlighted() {
        return !mWasExpanded && shouldShowNumber()
                && mHighlightPillColor != 0 && mHighlightTextColor != 0;
    }

    private void updateColors() {
        if (notificationsRedesignTemplates()) {
            if (shouldBeHighlighted()) {
                mPillDrawable.setTintList(ColorStateList.valueOf(mHighlightPillColor));
                mIconView.setColorFilter(mHighlightTextColor);
                mNumberView.setTextColor(mHighlightTextColor);
            } else {
                mPillDrawable.setTintList(ColorStateList.valueOf(mDefaultPillColor));
                mIconView.setColorFilter(mDefaultTextColor);
                mNumberView.setTextColor(mDefaultTextColor);
            }
        } else {
            if (shouldShowNumber()) {
                if (mHighlightPillColor != 0) {
                    mPillDrawable.setTintList(ColorStateList.valueOf(mHighlightPillColor));
@@ -211,6 +236,7 @@ public class NotificationExpandButton extends FrameLayout {
                }
            }
        }
    }

    private boolean shouldShowNumber() {
        if (notificationsRedesignTemplates()) {
+1 −1
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
                notification);
        RemoteViews headerRemoteViews;
        if (lowPriority) {
            headerRemoteViews = builder.makeLowPriorityContentView(true);
            headerRemoteViews = builder.makeLowPriorityContentView(true, false);
        } else {
            headerRemoteViews = builder.makeNotificationGroupHeader();
        }
+8 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar.notification.row;

import static android.app.Flags.notificationsRedesignTemplates;

import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
import static com.android.systemui.statusbar.NotificationLockscreenUserManager.REDACTION_TYPE_SENSITIVE_CONTENT;
import static com.android.systemui.statusbar.notification.row.NotificationContentView.VISIBLE_TYPE_CONTRACTED;
@@ -479,15 +481,16 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                    logger.logAsyncTaskProgress(entryForLogging,
                            "creating low-priority group summary remote view");
                    result.mNewMinimizedGroupHeaderView =
                            builder.makeLowPriorityContentView(true /* useRegularSubtext */);
                            builder.makeLowPriorityContentView(/* useRegularSubtext = */ true,
                                    /* highlightExpander = */ notificationsRedesignTemplates());
                }
            }
            setNotifsViewsInflaterFactory(result, row, notifLayoutInflaterFactoryProvider);
            result.packageContext = packageContext;
            result.headsUpStatusBarText = builder.getHeadsUpStatusBarText(
                    false /* showingPublic */);
                    /* showingPublic = */ false);
            result.headsUpStatusBarTextPublic = builder.getHeadsUpStatusBarText(
                    true /* showingPublic */);
                    /* showingPublic = */ true);

            return result;
        });
@@ -1136,7 +1139,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder
    private static RemoteViews createContentView(Notification.Builder builder,
            boolean isMinimized, boolean useLarge) {
        if (isMinimized) {
            return builder.makeLowPriorityContentView(false /* useRegularSubtext */);
            return builder.makeLowPriorityContentView(/* useRegularSubtext = */ false,
                    /* highlightExpander = */ false);
        }
        return builder.createContentView(useLarge);
    }
+9 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.notification.row

import android.annotation.SuppressLint
import android.app.Flags.notificationsRedesignTemplates
import android.app.Notification
import android.app.Notification.MessagingStyle
import android.content.Context
@@ -887,7 +888,10 @@ constructor(
                            entryForLogging,
                            "creating low-priority group summary remote view",
                        )
                        builder.makeLowPriorityContentView(true /* useRegularSubtext */)
                        builder.makeLowPriorityContentView(
                            /* useRegularSubtext = */ true,
                            /* highlightExpander = */ notificationsRedesignTemplates(),
                        )
                    } else null
                NewRemoteViews(
                        contracted = contracted,
@@ -1657,7 +1661,10 @@ constructor(
            useLarge: Boolean,
        ): RemoteViews {
            return if (isMinimized) {
                builder.makeLowPriorityContentView(false /* useRegularSubtext */)
                builder.makeLowPriorityContentView(
                    /* useRegularSubtext = */ false,
                    /* highlightExpander = */ false,
                )
            } else builder.createContentView(useLarge)
        }

Loading