Slight refactoring of notification groups
For the preparation of the bigger UI rewamp.
Bug: 24866646
Change-Id: Id5760ba6e5bae88c052bdd30ae47d9671a2a19c2
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 33f21ff..27401ab 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -97,6 +97,7 @@
private NotificationGroupManager mGroupManager;
private View mExpandButtonContainer;
private boolean mChildrenExpanded;
+ private boolean mIsSummaryWithChildren;
private NotificationChildrenContainer mChildrenContainer;
private ValueAnimator mChildExpandAnimator;
private float mChildrenExpandProgress;
@@ -115,6 +116,7 @@
private FalsingManager mFalsingManager;
private boolean mJustClicked;
+ private boolean mChildInGroup;
public NotificationContentView getPrivateLayout() {
return mPrivateLayout;
@@ -175,6 +177,7 @@
mStatusBarNotification = statusBarNotification;
updateVetoButton();
updateExpandButton();
+ onChildrenCountChanged();
}
public StatusBarNotification getStatusBarNotification() {
@@ -213,12 +216,33 @@
mChildrenContainerStub.inflate();
}
mChildrenContainer.addNotification(row, childIndex);
+ onChildrenCountChanged();
+ row.setIsChildInGroup(true, this);
}
public void removeChildNotification(ExpandableNotificationRow row) {
if (mChildrenContainer != null) {
mChildrenContainer.removeNotification(row);
}
+ onChildrenCountChanged();
+ row.setIsChildInGroup(false, null);
+ }
+
+ public boolean isChildInGroup() {
+ return mChildInGroup;
+ }
+
+ /**
+ * @param isChildInGroup Is this notification now in a group
+ * @param parent the new parent notification
+ */
+ public void setIsChildInGroup(boolean isChildInGroup, ExpandableNotificationRow parent) {
+ mChildInGroup = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS && isChildInGroup;
+ }
+
+ @Override
+ public boolean isSummaryWithChildren() {
+ return mIsSummaryWithChildren;
}
@Override
@@ -663,6 +687,15 @@
return BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS && !mIsHeadsUp;
}
+ private void onChildrenCountChanged() {
+ mIsSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS
+ && mGroupManager.hasGroupChildren(mStatusBarNotification);
+ if (mIsSummaryWithChildren && mChildrenContainer == null) {
+ mChildrenContainerStub.inflate();
+ }
+ updateChildrenVisibility(true);
+ }
+
/**
* Check whether the view state is currently expanded. This is given by the system in {@link
* #setSystemExpanded(boolean)} and can be overridden by user expansion or
@@ -696,15 +729,6 @@
mWasReset = false;
}
- @Override
- protected boolean isChildInvisible(View child) {
-
- // We don't want to layout the ChildrenContainer if this is a heads-up view, otherwise the
- // view will get too high and the shadows will be off.
- boolean isInvisibleChildContainer = child == mChildrenContainer && mIsHeadsUp;
- return super.isChildInvisible(child) || isInvisibleChildContainer;
- }
-
private void updateMaxHeights() {
int intrinsicBefore = getIntrinsicHeight();
View expandedChild = mPrivateLayout.getExpandedChild();
@@ -747,7 +771,8 @@
mPublicLayout.setAlpha(1f);
mPrivateLayout.setAlpha(1f);
mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
- mPrivateLayout.setVisibility(mShowingPublic ? View.INVISIBLE : View.VISIBLE);
+ mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren ? View.VISIBLE
+ : View.INVISIBLE);
} else {
animateShowingPublic(delay, duration);
}
@@ -945,6 +970,11 @@
}
@Override
+ protected boolean shouldLimitViewHeight() {
+ return !mIsSummaryWithChildren;
+ }
+
+ @Override
public void setClipTopAmount(int clipTopAmount) {
super.setClipTopAmount(clipTopAmount);
mPrivateLayout.setClipTopAmount(clipTopAmount);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index 71baf57..2652319 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -60,7 +60,8 @@
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int ownMaxHeight = mMaxViewHeight;
+ boolean limitViewHeight = shouldLimitViewHeight();
+ int ownMaxHeight = limitViewHeight ? mMaxViewHeight : Integer.MAX_VALUE;
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
boolean hasFixedHeight = heightMode == MeasureSpec.EXACTLY;
if (hasFixedHeight) {
@@ -72,7 +73,7 @@
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
- if (child.getVisibility() == GONE || isChildInvisible(child)) {
+ if (child.getVisibility() == GONE) {
continue;
}
int childHeightSpec = newHeightSpec;
@@ -80,7 +81,7 @@
if (layoutParams.height != ViewGroup.LayoutParams.MATCH_PARENT) {
if (layoutParams.height >= 0) {
// An actual height is set
- childHeightSpec = layoutParams.height > ownMaxHeight
+ childHeightSpec = layoutParams.height > ownMaxHeight && limitViewHeight
? MeasureSpec.makeMeasureSpec(ownMaxHeight, MeasureSpec.EXACTLY)
: MeasureSpec.makeMeasureSpec(layoutParams.height, MeasureSpec.EXACTLY);
}
@@ -109,6 +110,10 @@
setMeasuredDimension(width, ownHeight);
}
+ protected boolean shouldLimitViewHeight() {
+ return true;
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
@@ -362,10 +367,7 @@
return mActualHeight - getBottomDecorHeight();
}
- /**
- * @return whether the given child can be ignored for layouting and measuring purposes
- */
- protected boolean isChildInvisible(View child) {
+ public boolean isSummaryWithChildren() {
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index 310625e..bf107ce 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -205,6 +205,20 @@
return true;
}
+ /**
+ * @return whether a given notification is a summary in a group which has children
+ */
+ public boolean isSummaryOfGroup(StatusBarNotification sbn) {
+ if (sbn.getNotification().isGroupChild()) {
+ return false;
+ }
+ NotificationGroup group = mGroupMap.get(sbn.getGroupKey());
+ if (group == null) {
+ return false;
+ }
+ return !group.children.isEmpty();
+ }
+
public ExpandableNotificationRow getGroupSummary(StatusBarNotification sbn) {
NotificationGroup group = mGroupMap.get(sbn.getGroupKey());
return group == null ? null