Allow notification expansion to be toggleable.
Android Auto does not want notificaitons that have actions to be
expandable. Rather, they should always be in their expanded state. The
only exception to this are grouped notifications, which should be
collasped by default. They also can still be expanded.
Modify the code to allow this to be changed. In addition, modify some of
the animation so that the dividers so not flash when the notification
group is expanding.
There is also a change to bring the header of the notification to the
front so that the child notifications do not overlap it. This is because
in Auto, the app name and icon are not displayed in the header, but the
expand button is still there.
Test: booted on phone and Android Auto headunit.
Bug: 33210494
Change-Id: I0a121a0eaee6159ccea9961721abe92603484a17
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 072373b..63e0ef3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -165,6 +165,18 @@
private OnExpandClickListener mOnExpandClickListener;
private boolean mGroupExpansionChanging;
+ /**
+ * Whether or not a notification that is not part of a group of notifications can be manually
+ * expanded by the user.
+ */
+ private boolean mEnableNonGroupedNotificationExpand;
+
+ /**
+ * Whether or not to update the background of the header of the notification when its expanded.
+ * If {@code true}, the header background will disappear when expanded.
+ */
+ private boolean mShowGroupBackgroundWhenExpanded;
+
private OnClickListener mExpandClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
@@ -177,7 +189,7 @@
MetricsLogger.action(mContext, MetricsEvent.ACTION_NOTIFICATION_GROUP_EXPANDER,
nowExpanded);
onExpansionChanged(true /* userAction */, wasExpanded);
- } else {
+ } else if (mEnableNonGroupedNotificationExpand) {
if (v.isAccessibilityFocused()) {
mPrivateLayout.setFocusOnVisibilityChange();
}
@@ -1141,7 +1153,7 @@
}
public interface ExpansionLogger {
- public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
+ void logNotificationExpansion(String key, boolean userAction, boolean expanded);
}
public ExpandableNotificationRow(Context context, AttributeSet attrs) {
@@ -1164,11 +1176,16 @@
mMaxHeadsUpHeight = getFontScaledHeight(R.dimen.notification_max_heads_up_height);
mMaxHeadsUpHeightIncreased = getFontScaledHeight(
R.dimen.notification_max_heads_up_height_increased);
+
Resources res = getResources();
mIncreasedPaddingBetweenElements = res.getDimensionPixelSize(
R.dimen.notification_divider_height_increased);
mIconTransformContentShiftNoIcon = res.getDimensionPixelSize(
R.dimen.notification_icon_transform_content_shift);
+ mEnableNonGroupedNotificationExpand =
+ res.getBoolean(R.bool.config_enableNonGroupedNotificationExpand);
+ mShowGroupBackgroundWhenExpanded =
+ res.getBoolean(R.bool.config_showGroupNotificationBgWhenExpanded);
}
/**
@@ -1384,7 +1401,7 @@
if (mIsSummaryWithChildren && !mShowingPublic) {
return !mChildrenExpanded;
}
- return mExpandable;
+ return mEnableNonGroupedNotificationExpand && mExpandable;
}
public void setExpandable(boolean expandable) {
@@ -1974,7 +1991,8 @@
public void updateBackgroundForGroupState() {
if (mIsSummaryWithChildren) {
// Only when the group has finished expanding do we hide its background.
- mShowNoBackground = isGroupExpanded() && !isGroupExpansionChanging() && !isUserLocked();
+ mShowNoBackground = !mShowGroupBackgroundWhenExpanded && isGroupExpanded()
+ && !isGroupExpansionChanging() && !isUserLocked();
mChildrenContainer.updateHeaderForExpansion(mShowNoBackground);
List<ExpandableNotificationRow> children = mChildrenContainer.getNotificationChildren();
for (int i = 0; i < children.size(); i++) {
@@ -1983,10 +2001,10 @@
} else if (isChildInGroup()) {
final int childColor = getShowingLayout().getBackgroundColorForExpansionState();
// Only show a background if the group is expanded OR if it is expanding / collapsing
- // and has a custom background color
+ // and has a custom background color.
final boolean showBackground = isGroupExpanded()
|| ((mNotificationParent.isGroupExpansionChanging()
- || mNotificationParent.isUserLocked()) && childColor != 0);
+ || mNotificationParent.isUserLocked()) && childColor != 0);
mShowNoBackground = !showBackground;
} else {
// Only children or parents ever need no background.