Merge "Minimize exposure of NotificationHeaderView; prefer NotificationViewWrapper."

This commit is contained in:
TreeHugger Robot
2020-10-20 22:02:23 +00:00
committed by Android (Google) Code Review
13 changed files with 130 additions and 141 deletions

View File

@@ -27,7 +27,6 @@ import android.graphics.Outline;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RemoteViews;
import com.android.internal.R;
@@ -344,14 +343,6 @@ public class NotificationHeaderView extends ViewGroup {
}
}
public View getWorkProfileIcon() {
return mProfileBadge;
}
public CachingIconView getIcon() {
return mIcon;
}
/**
* Sets the margin end for the text portion of the header, excluding right-aligned elements
* @param headerTextMarginEnd margin size
@@ -490,10 +481,6 @@ public class NotificationHeaderView extends ViewGroup {
return this;
}
public ImageView getExpandButton() {
return mExpandButton;
}
@Override
public boolean hasOverlappingRendering() {
return false;

View File

@@ -68,10 +68,8 @@ public class NotificationHeaderUtil {
@Override
public void apply(View parent, View view, boolean apply, boolean reset) {
NotificationHeaderView header = (NotificationHeaderView) view;
ImageView icon = (ImageView) view.findViewById(
com.android.internal.R.id.icon);
ImageView expand = (ImageView) view.findViewById(
com.android.internal.R.id.expand_button);
ImageView icon = view.findViewById(com.android.internal.R.id.icon);
ImageView expand = view.findViewById(com.android.internal.R.id.expand_button);
applyToChild(icon, apply, header.getOriginalIconColor());
applyToChild(expand, apply, header.getOriginalNotificationColor());
}
@@ -178,7 +176,7 @@ public class NotificationHeaderUtil {
private void sanitizeHeaderViews(ExpandableNotificationRow row) {
if (row.isSummaryWithChildren()) {
sanitizeHeader(row.getNotificationHeader());
sanitizeHeader(row.getNotificationViewWrapper().getNotificationHeader());
return;
}
final NotificationContentView layout = row.getPrivateLayout();
@@ -275,7 +273,8 @@ public class NotificationHeaderUtil {
}
public void init() {
mParentView = mParentRow.getNotificationHeader().findViewById(mId);
mParentView = mParentRow.getNotificationViewWrapper().getNotificationHeader()
.findViewById(mId);
mParentData = mExtractor == null ? null : mExtractor.extractData(mParentRow);
mApply = !mComparator.isEmpty(mParentView);
}
@@ -305,7 +304,7 @@ public class NotificationHeaderUtil {
public void apply(ExpandableNotificationRow row, boolean reset) {
boolean apply = mApply && !reset;
if (row.isSummaryWithChildren()) {
applyToView(apply, reset, row.getNotificationHeader());
applyToView(apply, reset, row.getNotificationViewWrapper().getNotificationHeader());
return;
}
applyToView(apply, reset, row.getPrivateLayout().getContractedChild());

View File

@@ -106,12 +106,8 @@ public class ViewTransformationHelper implements TransformableView,
mViewTransformationAnimation.cancel();
}
mViewTransformationAnimation = ValueAnimator.ofFloat(0.0f, 1.0f);
mViewTransformationAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
transformTo(notification, animation.getAnimatedFraction());
}
});
mViewTransformationAnimation.addUpdateListener(
animation -> transformTo(notification, animation.getAnimatedFraction()));
mViewTransformationAnimation.setInterpolator(Interpolators.LINEAR);
mViewTransformationAnimation.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD);
mViewTransformationAnimation.addListener(new AnimatorListenerAdapter() {
@@ -167,12 +163,8 @@ public class ViewTransformationHelper implements TransformableView,
mViewTransformationAnimation.cancel();
}
mViewTransformationAnimation = ValueAnimator.ofFloat(0.0f, 1.0f);
mViewTransformationAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
transformFrom(notification, animation.getAnimatedFraction());
}
});
mViewTransformationAnimation.addUpdateListener(
animation -> transformFrom(notification, animation.getAnimatedFraction()));
mViewTransformationAnimation.addListener(new AnimatorListenerAdapter() {
public boolean mCancelled;

View File

@@ -409,8 +409,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
setIconAnimationRunning(running, l);
}
if (mIsSummaryWithChildren) {
setIconAnimationRunningForChild(running, mChildrenContainer.getHeaderView());
setIconAnimationRunningForChild(running, mChildrenContainer.getLowPriorityHeaderView());
NotificationViewWrapper viewWrapper = mChildrenContainer.getNotificationViewWrapper();
if (viewWrapper != null) {
setIconAnimationRunningForChild(running, viewWrapper.getIcon());
}
NotificationViewWrapper lowPriWrapper = mChildrenContainer.getLowPriorityViewWrapper();
if (lowPriWrapper != null) {
setIconAnimationRunningForChild(running, lowPriWrapper.getIcon());
}
List<ExpandableNotificationRow> notificationChildren =
mChildrenContainer.getAttachedChildren();
for (int i = 0; i < notificationChildren.size(); i++) {
@@ -434,10 +440,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
private void setIconAnimationRunningForChild(boolean running, View child) {
if (child != null) {
ImageView icon = (ImageView) child.findViewById(com.android.internal.R.id.icon);
ImageView icon = child.findViewById(com.android.internal.R.id.icon);
setIconRunning(icon, running);
ImageView rightIcon = (ImageView) child.findViewById(
com.android.internal.R.id.right_icon);
ImageView rightIcon = child.findViewById(com.android.internal.R.id.right_icon);
setIconRunning(rightIcon, running);
}
}
@@ -593,7 +598,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
public int getOriginalIconColor() {
if (mIsSummaryWithChildren && !shouldShowPublic()) {
return mChildrenContainer.getVisibleHeader().getOriginalIconColor();
return mChildrenContainer.getVisibleWrapper().getOriginalIconColor();
}
int color = getShowingLayout().getOriginalIconColor();
if (color != Notification.COLOR_INVALID) {
@@ -1039,22 +1044,25 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
}
}
public NotificationHeaderView getNotificationHeader() {
/**
* @return the main notification view wrapper.
*/
public NotificationViewWrapper getNotificationViewWrapper() {
if (mIsSummaryWithChildren) {
return mChildrenContainer.getHeaderView();
return mChildrenContainer.getNotificationViewWrapper();
}
return mPrivateLayout.getNotificationHeader();
return mPrivateLayout.getNotificationViewWrapper();
}
/**
* @return the currently visible notification header. This can be different from
* {@link #getNotificationHeader()} in case it is a low-priority group.
* @return the currently visible notification view wrapper. This can be different from
* {@link #getNotificationViewWrapper()} in case it is a low-priority group.
*/
public NotificationHeaderView getVisibleNotificationHeader() {
public NotificationViewWrapper getVisibleNotificationViewWrapper() {
if (mIsSummaryWithChildren && !shouldShowPublic()) {
return mChildrenContainer.getVisibleHeader();
return mChildrenContainer.getVisibleWrapper();
}
return getShowingLayout().getVisibleNotificationHeader();
return getShowingLayout().getVisibleWrapper();
}
public void setLongPressListener(LongPressListener longPressListener) {
@@ -1411,7 +1419,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
@Override
public View getShelfTransformationTarget() {
if (mIsSummaryWithChildren && !shouldShowPublic()) {
return mChildrenContainer.getVisibleHeader().getIcon();
return mChildrenContainer.getVisibleWrapper().getShelfTransformationTarget();
}
return getShowingLayout().getShelfTransformationTarget();
}
@@ -1682,37 +1690,30 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
mPrivateLayout = (NotificationContentView) findViewById(R.id.expanded);
mPublicLayout = findViewById(R.id.expandedPublic);
mPrivateLayout = findViewById(R.id.expanded);
mLayouts = new NotificationContentView[] {mPrivateLayout, mPublicLayout};
for (NotificationContentView l : mLayouts) {
l.setExpandClickListener(mExpandClickListener);
l.setContainingNotification(this);
}
mGutsStub = (ViewStub) findViewById(R.id.notification_guts_stub);
mGutsStub.setOnInflateListener(new ViewStub.OnInflateListener() {
@Override
public void onInflate(ViewStub stub, View inflated) {
mGuts = (NotificationGuts) inflated;
mGuts.setClipTopAmount(getClipTopAmount());
mGuts.setActualHeight(getActualHeight());
mGutsStub = null;
}
mGutsStub = findViewById(R.id.notification_guts_stub);
mGutsStub.setOnInflateListener((stub, inflated) -> {
mGuts = (NotificationGuts) inflated;
mGuts.setClipTopAmount(getClipTopAmount());
mGuts.setActualHeight(getActualHeight());
mGutsStub = null;
});
mChildrenContainerStub = (ViewStub) findViewById(R.id.child_container_stub);
mChildrenContainerStub.setOnInflateListener(new ViewStub.OnInflateListener() {
mChildrenContainerStub = findViewById(R.id.child_container_stub);
mChildrenContainerStub.setOnInflateListener((stub, inflated) -> {
mChildrenContainer = (NotificationChildrenContainer) inflated;
mChildrenContainer.setIsLowPriority(mIsLowPriority);
mChildrenContainer.setContainingNotification(ExpandableNotificationRow.this);
mChildrenContainer.onNotificationUpdated();
@Override
public void onInflate(ViewStub stub, View inflated) {
mChildrenContainer = (NotificationChildrenContainer) inflated;
mChildrenContainer.setIsLowPriority(mIsLowPriority);
mChildrenContainer.setContainingNotification(ExpandableNotificationRow.this);
mChildrenContainer.onNotificationUpdated();
if (mShouldTranslateContents) {
mTranslateableViews.add(mChildrenContainer);
}
if (mShouldTranslateContents) {
mTranslateableViews.add(mChildrenContainer);
}
});
@@ -2292,8 +2293,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
private void onAttachedChildrenCountChanged() {
mIsSummaryWithChildren = mChildrenContainer != null
&& mChildrenContainer.getNotificationChildCount() > 0;
if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() == null) {
mChildrenContainer.recreateNotificationHeader(mExpandClickListener, isConversation());
if (mIsSummaryWithChildren) {
NotificationViewWrapper wrapper = mChildrenContainer.getNotificationViewWrapper();
if (wrapper == null || wrapper.getNotificationHeader() == null) {
mChildrenContainer.recreateNotificationHeader(mExpandClickListener,
isConversation());
}
}
getShowingLayout().updateBackgroundColor(false /* animate */);
mPrivateLayout.updateExpandButtons(isExpandable());
@@ -2403,9 +2408,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
* the top.
*/
private void updateContentShiftHeight() {
NotificationHeaderView notificationHeader = getVisibleNotificationHeader();
if (notificationHeader != null) {
CachingIconView icon = notificationHeader.getIcon();
NotificationViewWrapper wrapper = getVisibleNotificationViewWrapper();
CachingIconView icon = wrapper == null ? null : wrapper.getIcon();
if (icon != null) {
mIconTransformContentShift = getRelativeTopPadding(icon) + icon.getHeight();
} else {
mIconTransformContentShift = mContentShift;
@@ -2493,12 +2498,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
.alpha(0f)
.setStartDelay(delay)
.setDuration(duration)
.withEndAction(new Runnable() {
@Override
public void run() {
hiddenView.setVisibility(View.INVISIBLE);
}
});
.withEndAction(() -> hiddenView.setVisibility(View.INVISIBLE));
}
for (View showView : shownChildren) {
showView.setVisibility(View.VISIBLE);
@@ -2856,7 +2856,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
}
float x = event.getX();
float y = event.getY();
NotificationHeaderView header = getVisibleNotificationHeader();
NotificationHeaderView header = getVisibleNotificationViewWrapper().getNotificationHeader();
if (header != null && header.isInTouchRect(x - getTranslation(), y)) {
return true;
}

View File

@@ -1018,6 +1018,10 @@ public class NotificationContentView extends FrameLayout {
mSingleLineView };
}
public NotificationViewWrapper getVisibleWrapper() {
return getVisibleWrapper(mVisibleType);
}
public NotificationViewWrapper getVisibleWrapper(int visibleType) {
switch (visibleType) {
case VISIBLE_TYPE_EXPANDED:
@@ -1541,18 +1545,20 @@ public class NotificationContentView extends FrameLayout {
mIsContentExpandable = expandable;
}
public NotificationHeaderView getNotificationHeader() {
NotificationHeaderView header = null;
if (mContractedChild != null) {
header = mContractedWrapper.getNotificationHeader();
/**
* @return a view wrapper for one of the inflated states of the notification.
*/
public NotificationViewWrapper getNotificationViewWrapper() {
if (mContractedChild != null && mContractedWrapper != null) {
return mContractedWrapper;
}
if (header == null && mExpandedChild != null) {
header = mExpandedWrapper.getNotificationHeader();
if (mExpandedChild != null && mExpandedWrapper != null) {
return mExpandedWrapper;
}
if (header == null && mHeadsUpChild != null) {
header = mHeadsUpWrapper.getNotificationHeader();
if (mHeadsUpChild != null && mHeadsUpWrapper != null) {
return mHeadsUpWrapper;
}
return header;
return null;
}
public void showFeedbackIcon(boolean show) {
@@ -1580,11 +1586,6 @@ public class NotificationContentView extends FrameLayout {
}
}
public NotificationHeaderView getVisibleNotificationHeader() {
NotificationViewWrapper wrapper = getVisibleWrapper(mVisibleType);
return wrapper == null ? null : wrapper.getNotificationHeader();
}
public void setContainingNotification(ExpandableNotificationRow containingNotification) {
mContainingNotification = containingNotification;
}

View File

@@ -37,7 +37,7 @@ public class NotificationBigTextTemplateViewWrapper extends NotificationTemplate
}
private void resolveViews(StatusBarNotification notification) {
mBigtext = (ImageFloatingTextView) mView.findViewById(com.android.internal.R.id.big_text);
mBigtext = mView.findViewById(com.android.internal.R.id.big_text);
}
@Override

View File

@@ -55,8 +55,6 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
protected final ViewTransformationHelper mTransformationHelper;
protected int mColor;
private CachingIconView mIcon;
private NotificationExpandButton mExpandButton;
protected NotificationHeaderView mNotificationHeader;
@@ -119,7 +117,6 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
mFeedbackIcon = mView.findViewById(com.android.internal.R.id.feedback);
if (mNotificationHeader != null) {
mNotificationHeader.setShowExpandButtonAtEnd(mShowExpandButtonAtEnd);
mColor = mNotificationHeader.getOriginalIconColor();
}
}
@@ -295,6 +292,11 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
return mExpandButton;
}
@Override
public CachingIconView getIcon() {
return mIcon;
}
@Override
public int getOriginalIconColor() {
return mIcon.getOriginalIconColor();

View File

@@ -370,7 +370,7 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi
return;
}
int tintColor = getNotificationHeader().getOriginalIconColor();
int tintColor = getOriginalIconColor();
mSeekBarElapsedTime.setTextColor(tintColor);
mSeekBarTotalTime.setTextColor(tintColor);
mSeekBarTotalTime.setShadowLayer(1.5f, 1.5f, 1.5f, mBackgroundColor);

View File

@@ -140,13 +140,13 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
}
private void resolveTemplateViews(StatusBarNotification notification) {
mPicture = (ImageView) mView.findViewById(com.android.internal.R.id.right_icon);
mPicture = mView.findViewById(com.android.internal.R.id.right_icon);
if (mPicture != null) {
mPicture.setTag(ImageTransformState.ICON_TAG,
notification.getNotification().getLargeIcon());
}
mTitle = (TextView) mView.findViewById(com.android.internal.R.id.title);
mText = (TextView) mView.findViewById(com.android.internal.R.id.text);
mTitle = mView.findViewById(com.android.internal.R.id.title);
mText = mView.findViewById(com.android.internal.R.id.text);
final View progress = mView.findViewById(com.android.internal.R.id.progress);
if (progress instanceof ProgressBar) {
mProgressBar = (ProgressBar) progress;

View File

@@ -29,7 +29,6 @@ import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.ArraySet;
import android.view.NotificationHeaderView;
import android.view.View;
import android.view.ViewGroup;
@@ -38,7 +37,7 @@ import android.widget.TextView;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.graphics.ColorUtils;
import com.android.internal.util.ContrastColorUtil;
import com.android.internal.widget.ConversationLayout;
import com.android.internal.widget.CachingIconView;
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.TransformableView;
import com.android.systemui.statusbar.notification.TransformState;
@@ -67,8 +66,7 @@ public abstract class NotificationViewWrapper implements TransformableView {
} else if ("messaging".equals(v.getTag())) {
return new NotificationMessagingTemplateViewWrapper(ctx, v, row);
} else if ("conversation".equals(v.getTag())) {
return new NotificationConversationTemplateViewWrapper(ctx, (ConversationLayout) v,
row);
return new NotificationConversationTemplateViewWrapper(ctx, v, row);
}
Class<? extends Notification.Style> style =
row.getEntry().getSbn().getNotification().getNotificationStyle();
@@ -241,7 +239,16 @@ public abstract class NotificationViewWrapper implements TransformableView {
/**
* @return the expand button if it exists
*/
public @Nullable View getExpandButton() {
@Nullable
public View getExpandButton() {
return null;
}
/**
* @return the icon if it exists
*/
@Nullable
public CachingIconView getIcon() {
return null;
}

View File

@@ -31,6 +31,7 @@ import android.widget.RemoteViews;
import android.widget.TextView;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.CachingIconView;
import com.android.systemui.R;
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.statusbar.NotificationHeaderUtil;
@@ -318,9 +319,8 @@ public class NotificationChildrenContainer extends ViewGroup {
RemoteViews header = builder.makeNotificationHeader();
if (mNotificationHeader == null) {
mNotificationHeader = (NotificationHeaderView) header.apply(getContext(), this);
final View expandButton = mNotificationHeader.findViewById(
com.android.internal.R.id.expand_button);
expandButton.setVisibility(VISIBLE);
mNotificationHeader.findViewById(com.android.internal.R.id.expand_button)
.setVisibility(VISIBLE);
mNotificationHeader.setOnClickListener(mHeaderClickListener);
mNotificationHeaderWrapper = NotificationViewWrapper.wrap(getContext(),
mNotificationHeader, mContainingNotification);
@@ -361,9 +361,8 @@ public class NotificationChildrenContainer extends ViewGroup {
if (mNotificationHeaderLowPriority == null) {
mNotificationHeaderLowPriority = (NotificationHeaderView) header.apply(getContext(),
this);
final View expandButton = mNotificationHeaderLowPriority.findViewById(
com.android.internal.R.id.expand_button);
expandButton.setVisibility(VISIBLE);
mNotificationHeaderLowPriority.findViewById(com.android.internal.R.id.expand_button)
.setVisibility(VISIBLE);
mNotificationHeaderLowPriority.setOnClickListener(mHeaderClickListener);
mNotificationHeaderWrapperLowPriority = NotificationViewWrapper.wrap(getContext(),
mNotificationHeaderLowPriority, mContainingNotification);
@@ -869,12 +868,12 @@ public class NotificationChildrenContainer extends ViewGroup {
return mContainingNotification;
}
public NotificationHeaderView getHeaderView() {
return mNotificationHeader;
public NotificationViewWrapper getNotificationViewWrapper() {
return mNotificationHeaderWrapper;
}
public NotificationHeaderView getLowPriorityHeaderView() {
return mNotificationHeaderLowPriority;
public NotificationViewWrapper getLowPriorityViewWrapper() {
return mNotificationHeaderWrapperLowPriority;
}
@VisibleForTesting
@@ -1224,16 +1223,15 @@ public class NotificationChildrenContainer extends ViewGroup {
public void setShelfIconVisible(boolean iconVisible) {
if (mNotificationHeaderWrapper != null) {
NotificationHeaderView header = mNotificationHeaderWrapper.getNotificationHeader();
if (header != null) {
header.getIcon().setForceHidden(iconVisible);
CachingIconView icon = mNotificationHeaderWrapper.getIcon();
if (icon != null) {
icon.setForceHidden(iconVisible);
}
}
if (mNotificationHeaderWrapperLowPriority != null) {
NotificationHeaderView header
= mNotificationHeaderWrapperLowPriority.getNotificationHeader();
if (header != null) {
header.getIcon().setForceHidden(iconVisible);
CachingIconView icon = mNotificationHeaderWrapperLowPriority.getIcon();
if (icon != null) {
icon.setForceHidden(iconVisible);
}
}
}
@@ -1254,12 +1252,14 @@ public class NotificationChildrenContainer extends ViewGroup {
}
}
public NotificationHeaderView getVisibleHeader() {
NotificationHeaderView header = mNotificationHeader;
/**
* @return the view wrapper for the currently showing priority.
*/
public NotificationViewWrapper getVisibleWrapper() {
if (showingAsLowPriority()) {
header = mNotificationHeaderLowPriority;
return mNotificationHeaderWrapperLowPriority;
}
return header;
return mNotificationHeaderWrapper;
}
public void onExpansionChanged() {

View File

@@ -96,8 +96,8 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
mGroupRow.setSensitive(true, true);
mGroupRow.setHideSensitive(true, false, 0, 0);
mGroupRow.setHideSensitive(false, true, 0, 0);
assertTrue(mGroupRow.getChildrenContainer().getVisibleHeader().getVisibility()
== View.VISIBLE);
assertEquals(View.VISIBLE, mGroupRow.getChildrenContainer().getVisibleWrapper()
.getNotificationHeader().getVisibility());
}
@Test

View File

@@ -57,7 +57,7 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
public void testGetMaxAllowedVisibleChildren_lowPriority() {
mChildrenContainer.setIsLowPriority(true);
Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(),
NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED);
NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED);
}
@Test
@@ -72,7 +72,7 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
mChildrenContainer.setIsLowPriority(true);
mChildrenContainer.setChildrenExpanded(true);
Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(),
NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED);
NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED);
}
@Test
@@ -80,13 +80,13 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
mChildrenContainer.setIsLowPriority(true);
mChildrenContainer.setUserLocked(true);
Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(),
NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED);
NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED);
}
@Test
public void testGetMaxAllowedVisibleChildren_likeCollapsed() {
Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(true),
NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_COLLAPSED);
NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_COLLAPSED);
}
@@ -136,12 +136,13 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
@Test
public void testLowPriorityHeaderCleared() {
mGroup.setIsLowPriority(true);
NotificationHeaderView lowPriorityHeaderView = mChildrenContainer.getLowPriorityHeaderView();
Assert.assertTrue(lowPriorityHeaderView.getVisibility() == View.VISIBLE);
Assert.assertTrue(lowPriorityHeaderView.getParent() == mChildrenContainer);
NotificationHeaderView lowPriorityHeaderView =
mChildrenContainer.getLowPriorityViewWrapper().getNotificationHeader();
Assert.assertEquals(View.VISIBLE, lowPriorityHeaderView.getVisibility());
Assert.assertSame(mChildrenContainer, lowPriorityHeaderView.getParent());
mGroup.setIsLowPriority(false);
Assert.assertTrue(lowPriorityHeaderView.getParent() == null);
Assert.assertTrue(mChildrenContainer.getLowPriorityHeaderView() == null);
Assert.assertNull(lowPriorityHeaderView.getParent());
Assert.assertNull(mChildrenContainer.getLowPriorityViewWrapper());
}
@Test