diff options
| author | 2020-10-14 11:09:40 -0400 | |
|---|---|---|
| committer | 2020-10-20 10:35:41 -0400 | |
| commit | 8be7d6e3c44146d32ddb8b224a83db6bab638412 (patch) | |
| tree | 42bcb509754060f3895277e8c6d48c78549cb68e | |
| parent | 019f0c13205e5349a1ad2a8f2f5df0b32da658bd (diff) | |
Minimize exposure of NotificationHeaderView; prefer NotificationViewWrapper.
Test: atest SystemUITests
Test: manual testing with notify APK
Change-Id: I91ed49411f29f42ce6708fdb816ebe650a6d7e8b
13 files changed, 130 insertions, 141 deletions
diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index 8b0de0807872..546e26a85d6e 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -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; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java index 670a65f55844..b7f4e67e48d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationHeaderUtil.java @@ -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()); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ViewTransformationHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/ViewTransformationHelper.java index 83e51cd43ed2..7ecdc812cbd3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ViewTransformationHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ViewTransformationHelper.java @@ -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; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index ba88f628d632..5e774ab4f30f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -410,8 +410,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++) { @@ -435,10 +441,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); } } @@ -594,7 +599,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) { @@ -1040,22 +1045,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) { @@ -1422,7 +1430,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView @Override public View getShelfTransformationTarget() { if (mIsSummaryWithChildren && !shouldShowPublic()) { - return mChildrenContainer.getVisibleHeader().getIcon(); + return mChildrenContainer.getVisibleWrapper().getShelfTransformationTarget(); } return getShowingLayout().getShelfTransformationTarget(); } @@ -1693,37 +1701,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); } }); @@ -2303,8 +2304,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()); @@ -2414,9 +2419,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; @@ -2504,12 +2509,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); @@ -2867,7 +2867,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; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index 3b55f7c1e6e8..160b6f78d9a3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -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; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigTextTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigTextTemplateViewWrapper.java index 41f93cceacc7..d58c183f27e3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigTextTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationBigTextTemplateViewWrapper.java @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java index 3f5867477f16..8314aff99c65 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java @@ -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(); } } @@ -296,6 +293,11 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { } @Override + public CachingIconView getIcon() { + return mIcon; + } + + @Override public int getOriginalIconColor() { return mIcon.getOriginalIconColor(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java index 33c939054be5..2535e5ddc3d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationMediaTemplateViewWrapper.java @@ -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); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java index 14aab9d62dfd..76ec59e0ec28 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationTemplateViewWrapper.java @@ -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; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java index 42f5e389d5a8..e2f0799a5c35 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java @@ -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; } 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 a396305a49b6..a5d51c64d4ee 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 @@ -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() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java index 8f1d71c80e2d..891179c32315 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java @@ -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 diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java index b9055ec0bb7b..7c41abba6176 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainerTest.java @@ -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 |