Slight refactoring of notification groups

For the preparation of the bigger UI rewamp.

Bug: 24866646
Change-Id: Id5760ba6e5bae88c052bdd30ae47d9671a2a19c2
This commit is contained in:
Selim Cinek
2015-10-21 17:40:23 -07:00
parent 5243c12f49
commit 263398f017
3 changed files with 63 additions and 17 deletions

View File

@@ -97,6 +97,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
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 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
private FalsingManager mFalsingManager;
private boolean mJustClicked;
private boolean mChildInGroup;
public NotificationContentView getPrivateLayout() {
return mPrivateLayout;
@@ -175,6 +177,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
mStatusBarNotification = statusBarNotification;
updateVetoButton();
updateExpandButton();
onChildrenCountChanged();
}
public StatusBarNotification getStatusBarNotification() {
@@ -213,12 +216,33 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
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 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
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 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
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 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
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);
}
@@ -944,6 +969,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
return showingLayout.getMinHeight();
}
@Override
protected boolean shouldLimitViewHeight() {
return !mIsSummaryWithChildren;
}
@Override
public void setClipTopAmount(int clipTopAmount) {
super.setClipTopAmount(clipTopAmount);

View File

@@ -60,7 +60,8 @@ public abstract class ExpandableView extends FrameLayout {
@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 @@ public abstract class ExpandableView extends FrameLayout {
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 @@ public abstract class ExpandableView extends FrameLayout {
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 @@ public abstract class ExpandableView extends FrameLayout {
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 @@ public abstract class ExpandableView extends FrameLayout {
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;
}

View File

@@ -205,6 +205,20 @@ public class NotificationGroupManager {
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