summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/Notification.java10
-rw-r--r--core/java/com/android/internal/widget/NotificationExpandButton.java78
-rw-r--r--core/res/res/values/dimens.xml3
-rw-r--r--core/res/res/values/symbols.xml2
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImpl.kt11
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java3
8 files changed, 95 insertions, 26 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 4d46342b41af..52789f70f312 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -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);
@@ -6804,6 +6804,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));
}
@@ -6973,12 +6975,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());
diff --git a/core/java/com/android/internal/widget/NotificationExpandButton.java b/core/java/com/android/internal/widget/NotificationExpandButton.java
index b7537ed3f54b..80bc4fd89c8d 100644
--- a/core/java/com/android/internal/widget/NotificationExpandButton.java
+++ b/core/java/com/android/internal/widget/NotificationExpandButton.java
@@ -27,12 +27,12 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import android.view.RemotableViewMethod;
-import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.TextView;
@@ -49,12 +49,15 @@ public class NotificationExpandButton extends FrameLayout {
private Drawable mPillDrawable;
private TextView mNumberView;
private ImageView mIconView;
+ private LinearLayout mPillView;
private boolean mExpanded;
private int mNumber;
private int mDefaultPillColor;
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);
@@ -78,8 +81,8 @@ public class NotificationExpandButton extends FrameLayout {
protected void onFinishInflate() {
super.onFinishInflate();
- final View pillView = findViewById(R.id.expand_button_pill);
- final LayerDrawable layeredPill = (LayerDrawable) pillView.getBackground();
+ mPillView = findViewById(R.id.expand_button_pill);
+ final LayerDrawable layeredPill = (LayerDrawable) mPillView.getBackground();
mPillDrawable = layeredPill.findDrawableByLayerId(R.id.expand_button_pill_colorized_layer);
mNumberView = findViewById(R.id.expand_button_number);
mIconView = findViewById(R.id.expand_button_icon);
@@ -133,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;
@@ -152,6 +156,8 @@ public class NotificationExpandButton extends FrameLayout {
if (!notificationsRedesignTemplates()) {
// changing the expanded state can affect the number display
updateNumber();
+ } else {
+ updateColors();
}
}
@@ -166,27 +172,69 @@ public class NotificationExpandButton extends FrameLayout {
mNumberView.setVisibility(GONE);
}
- // changing number can affect the color
+ // changing number can affect the color and padding
updateColors();
+ updatePadding();
+ }
+
+ private void updatePadding() {
+ if (!notificationsRedesignTemplates()) {
+ return;
+ }
+
+ // Reduce the padding at the end when showing the number, since the arrow icon has more
+ // inherent spacing than the number does. This makes the content look more centered.
+ // Vertical padding remains unchanged.
+ int reducedPadding = getResources().getDimensionPixelSize(
+ R.dimen.notification_2025_expand_button_reduced_end_padding);
+ int normalPadding = getResources().getDimensionPixelSize(
+ R.dimen.notification_2025_expand_button_horizontal_icon_padding);
+ mPillView.setPaddingRelative(
+ /* start = */ normalPadding,
+ /* top = */ mPillView.getPaddingTop(),
+ /* end = */ shouldShowNumber() ? reducedPadding : normalPadding,
+ /* bottom = */ mPillView.getPaddingBottom()
+ );
+ }
+
+ /**
+ * 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 (shouldShowNumber()) {
- if (mHighlightPillColor != 0) {
+ if (notificationsRedesignTemplates()) {
+ if (shouldBeHighlighted()) {
mPillDrawable.setTintList(ColorStateList.valueOf(mHighlightPillColor));
- }
- mIconView.setColorFilter(mHighlightTextColor);
- if (mHighlightTextColor != 0) {
+ mIconView.setColorFilter(mHighlightTextColor);
mNumberView.setTextColor(mHighlightTextColor);
- }
- } else {
- if (mDefaultPillColor != 0) {
+ } else {
mPillDrawable.setTintList(ColorStateList.valueOf(mDefaultPillColor));
- }
- mIconView.setColorFilter(mDefaultTextColor);
- if (mDefaultTextColor != 0) {
+ mIconView.setColorFilter(mDefaultTextColor);
mNumberView.setTextColor(mDefaultTextColor);
}
+ } else {
+ if (shouldShowNumber()) {
+ if (mHighlightPillColor != 0) {
+ mPillDrawable.setTintList(ColorStateList.valueOf(mHighlightPillColor));
+ }
+ mIconView.setColorFilter(mHighlightTextColor);
+ if (mHighlightTextColor != 0) {
+ mNumberView.setTextColor(mHighlightTextColor);
+ }
+ } else {
+ if (mDefaultPillColor != 0) {
+ mPillDrawable.setTintList(ColorStateList.valueOf(mDefaultPillColor));
+ }
+ mIconView.setColorFilter(mDefaultTextColor);
+ if (mDefaultTextColor != 0) {
+ mNumberView.setTextColor(mDefaultTextColor);
+ }
+ }
}
}
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index a4735fe6c7af..2adb79118ed9 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -408,6 +408,9 @@
<!-- the padding of the expand icon in the notification header -->
<dimen name="notification_2025_expand_button_horizontal_icon_padding">6dp</dimen>
+ <!-- a smaller padding for the end of the expand button, for use when showing the number -->
+ <dimen name="notification_2025_expand_button_reduced_end_padding">4dp</dimen>
+
<!-- the size of the notification close button -->
<dimen name="notification_close_button_size">16dp</dimen>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 4d533ec94635..a18f923d625b 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3247,6 +3247,8 @@
<java-symbol type="dimen" name="notification_content_margin" />
<java-symbol type="dimen" name="notification_2025_margin" />
<java-symbol type="dimen" name="notification_2025_content_margin_top" />
+ <java-symbol type="dimen" name="notification_2025_expand_button_horizontal_icon_padding" />
+ <java-symbol type="dimen" name="notification_2025_expand_button_reduced_end_padding" />
<java-symbol type="dimen" name="notification_progress_margin_horizontal" />
<java-symbol type="dimen" name="notification_header_background_height" />
<java-symbol type="dimen" name="notification_header_touchable_height" />
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java
index 14bbd38ece2c..72a91bc12f8d 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java
@@ -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();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java
index 70e27a981b49..7c44eae6c0b8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java
@@ -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);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImpl.kt
index c619b17f1ad8..ae9b69c8f6bf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationRowContentBinderImpl.kt
@@ -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)
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
index 9fb7fad52bb6..f94fefe97749 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
@@ -560,7 +560,8 @@ public class NotificationChildrenContainer extends ViewGroup
builder = Notification.Builder.recoverBuilder(getContext(),
notification.getNotification());
}
- header = builder.makeLowPriorityContentView(true /* useRegularSubtext */);
+ header = builder.makeLowPriorityContentView(true /* useRegularSubtext */,
+ notificationsRedesignTemplates() /* highlightExpander */);
if (mMinimizedGroupHeader == null) {
mMinimizedGroupHeader = (NotificationHeaderView) header.apply(getContext(),
this);