Remove the ambient group layout

Because the layout looks pretty much the same as when awake, we're
going back to the regular group layout.

Test: atest SystemUiTests
Fixes: 127697886
Change-Id: I5eafaf74435151faab13d8f84850b4939196edd9
This commit is contained in:
Selim Cinek
2019-03-06 15:21:39 -08:00
parent d6f7187db3
commit 7927c73ffd
7 changed files with 10 additions and 202 deletions

View File

@@ -522,27 +522,6 @@ public class ContrastColorUtil {
return ColorUtilsFromCompat.LABToColor(result[0], result[1], result[2]);
}
public static int resolveAmbientColor(Context context, int notificationColor) {
final int resolvedColor = notificationColor == Notification.COLOR_DEFAULT
? context.getColor(com.android.internal.R.color.notification_default_color_dark)
: notificationColor;
int color = resolvedColor;
color = ContrastColorUtil.ensureTextContrastOnBlack(color);
if (color != resolvedColor) {
if (DEBUG){
Log.w(TAG, String.format(
"Ambient contrast of notification for %s is %s (over black)"
+ " by changing #%s to #%s",
context.getPackageName(),
ContrastColorUtil.contrastChange(resolvedColor, color, Color.BLACK),
Integer.toHexString(resolvedColor), Integer.toHexString(color)));
}
}
return color;
}
public static int resolvePrimaryColor(Context context, int backgroundColor,
boolean defaultBackgroundIsDark) {
boolean useDark = shouldUseDark(backgroundColor, defaultBackgroundIsDark);

View File

@@ -651,8 +651,6 @@
<!-- The overflow indicator shown when a group has more notification inside the group than the visible ones. An example is "+ 3" [CHAR LIMIT=5] -->
<string name="notification_group_overflow_indicator">+ <xliff:g id="number" example="3">%s</xliff:g></string>
<!-- The overflow indicator shown when a group has more notification inside the group than the visible ones. An example is "New message, +3" [CHAR LIMIT=7] -->
<string name="notification_group_overflow_indicator_ambient"><xliff:g id="notification_title" example="New message">%1$s</xliff:g>, +<xliff:g id="overflow" example="+3">%2$s</xliff:g></string>
<!-- Content description describing how many more notifications are in a group [CHAR LIMIT=NONE] -->
<plurals name="notification_group_overflow_description">

View File

@@ -334,7 +334,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
private boolean mUseIncreasedHeadsUpHeight;
private float mTranslationWhenRemoved;
private boolean mWasChildInGroupWhenRemoved;
private int mNotificationColorAmbient;
private NotificationInlineImageResolver mImageResolver;
private NotificationMediaManager mMediaManager;
@@ -1284,18 +1283,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
mNotificationColor = ContrastColorUtil.resolveContrastColor(mContext,
getStatusBarNotification().getNotification().color,
getBackgroundColorWithoutTint(), nightMode);
mNotificationColorAmbient = ContrastColorUtil.resolveAmbientColor(mContext,
getStatusBarNotification().getNotification().color);
}
public HybridNotificationView getSingleLineView() {
return mPrivateLayout.getSingleLineView();
}
public HybridNotificationView getAmbientSingleLineView() {
return getShowingLayout().getAmbientSingleLineChild();
}
public boolean isOnKeyguard() {
return mOnKeyguard;
}
@@ -1628,10 +1621,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
return mNotificationInflater;
}
public int getNotificationColorAmbient() {
return mNotificationColorAmbient;
}
public interface ExpansionLogger {
void logNotificationExpansion(String key, boolean userAction, boolean expanded);
}
@@ -2316,7 +2305,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
return mPrivateLayout.getMinHeight();
} else if (mSensitive && mHideSensitiveForIntrinsicHeight) {
return getMinHeight();
} else if (mIsSummaryWithChildren && (!mOnKeyguard || mOnAmbient)) {
} else if (mIsSummaryWithChildren && !mOnKeyguard) {
return mChildrenContainer.getIntrinsicHeight();
} else if (isHeadsUpAllowed() && (mIsHeadsUp || mHeadsupDisappearRunning)) {
if (isPinned() || mHeadsupDisappearRunning) {
@@ -3018,9 +3007,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
public void setOnAmbient(boolean onAmbient) {
if (onAmbient != mOnAmbient) {
mOnAmbient = onAmbient;
if (mChildrenContainer != null) {
mChildrenContainer.notifyDozingStateChanged();
}
notifyHeightChanged(false /* needsAnimation */);
}
}

View File

@@ -36,7 +36,6 @@ import com.android.systemui.statusbar.notification.NotificationUtils;
public class HybridGroupManager {
private final Context mContext;
private final NotificationDozeHelper mDozer;
private final ViewGroup mParent;
private float mOverflowNumberSize;
@@ -47,7 +46,6 @@ public class HybridGroupManager {
public HybridGroupManager(Context ctx, ViewGroup parent) {
mContext = ctx;
mParent = parent;
mDozer = new NotificationDozeHelper();
initDimens();
}
@@ -94,12 +92,6 @@ public class HybridGroupManager {
R.style.HybridNotification);
}
public HybridNotificationView bindAmbientFromNotification(HybridNotificationView reusableView,
Notification notification) {
return bindFromNotificationWithStyle(reusableView, notification,
R.style.HybridNotification);
}
private HybridNotificationView bindFromNotificationWithStyle(
HybridNotificationView reusableView, Notification notification, int style) {
if (reusableView == null) {
@@ -147,15 +139,4 @@ public class HybridGroupManager {
updateOverFlowNumberColor(reusableView);
return reusableView;
}
public TextView bindOverflowNumberAmbient(TextView titleView, Notification notification,
int number) {
String text = mContext.getResources().getString(
R.string.notification_group_overflow_indicator_ambient,
resolveTitle(notification), number);
if (!text.equals(titleView.getText())) {
titleView.setText(text);
}
return titleView;
}
}

View File

@@ -72,7 +72,6 @@ public class NotificationContentView extends FrameLayout {
public static final int VISIBLE_TYPE_HEADSUP = 2;
private static final int VISIBLE_TYPE_SINGLELINE = 3;
public static final int VISIBLE_TYPE_AMBIENT = 4;
private static final int VISIBLE_TYPE_AMBIENT_SINGLELINE = 5;
public static final int UNDEFINED = -1;
private final Rect mClipBounds = new Rect();
@@ -84,7 +83,6 @@ public class NotificationContentView extends FrameLayout {
private View mHeadsUpChild;
private HybridNotificationView mSingleLineView;
private View mAmbientChild;
private HybridNotificationView mAmbientSingleLineChild;
private RemoteInputView mExpandedRemoteInput;
private RemoteInputView mHeadsUpRemoteInput;
@@ -301,27 +299,6 @@ public class NotificationContentView extends FrameLayout {
: MeasureSpec.AT_MOST));
maxChildHeight = Math.max(maxChildHeight, mAmbientChild.getMeasuredHeight());
}
if (mAmbientSingleLineChild != null) {
int size = mNotificationAmbientHeight;
ViewGroup.LayoutParams layoutParams = mAmbientSingleLineChild.getLayoutParams();
boolean useExactly = false;
if (layoutParams.height >= 0) {
// An actual height is set
size = Math.min(size, layoutParams.height);
useExactly = true;
}
int ambientSingleLineWidthSpec = widthMeasureSpec;
if (mSingleLineWidthIndention != 0
&& MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED) {
ambientSingleLineWidthSpec = MeasureSpec.makeMeasureSpec(
width - mSingleLineWidthIndention + mAmbientSingleLineChild.getPaddingEnd(),
MeasureSpec.EXACTLY);
}
mAmbientSingleLineChild.measure(ambientSingleLineWidthSpec,
MeasureSpec.makeMeasureSpec(size, useExactly ? MeasureSpec.EXACTLY
: MeasureSpec.AT_MOST));
maxChildHeight = Math.max(maxChildHeight, mAmbientSingleLineChild.getMeasuredHeight());
}
int ownHeight = Math.min(maxChildHeight, maxSize);
setMeasuredDimension(width, ownHeight);
}
@@ -432,10 +409,6 @@ public class NotificationContentView extends FrameLayout {
return mAmbientChild;
}
public HybridNotificationView getAmbientSingleLineChild() {
return mAmbientSingleLineChild;
}
/**
* Sets the contracted view. Child may be null to remove the content view.
*
@@ -693,10 +666,7 @@ public class NotificationContentView extends FrameLayout {
int hint;
if (mAmbientChild != null && isVisibleOrTransitioning(VISIBLE_TYPE_AMBIENT)) {
hint = mAmbientChild.getHeight();
} else if (mAmbientSingleLineChild != null && isVisibleOrTransitioning(
VISIBLE_TYPE_AMBIENT_SINGLELINE)) {
hint = mAmbientSingleLineChild.getHeight();
} else if (mHeadsUpChild != null && isVisibleOrTransitioning(VISIBLE_TYPE_HEADSUP)) {
} else if (mHeadsUpChild != null && isVisibleOrTransitioning(VISIBLE_TYPE_HEADSUP)) {
hint = getViewHeight(VISIBLE_TYPE_HEADSUP);
} else if (mExpandedChild != null) {
hint = getViewHeight(VISIBLE_TYPE_EXPANDED);
@@ -833,7 +803,7 @@ public class NotificationContentView extends FrameLayout {
}
public View getShowingAmbientView() {
View v = mIsChildInGroup ? mAmbientSingleLineChild : mAmbientChild;
View v = mIsChildInGroup ? mSingleLineView : mAmbientChild;
if (v != null) {
return v;
} else {
@@ -923,8 +893,6 @@ public class NotificationContentView extends FrameLayout {
forceUpdateVisibility(VISIBLE_TYPE_HEADSUP, mHeadsUpChild, mHeadsUpWrapper);
forceUpdateVisibility(VISIBLE_TYPE_SINGLELINE, mSingleLineView, mSingleLineView);
forceUpdateVisibility(VISIBLE_TYPE_AMBIENT, mAmbientChild, mAmbientWrapper);
forceUpdateVisibility(VISIBLE_TYPE_AMBIENT_SINGLELINE, mAmbientSingleLineChild,
mAmbientSingleLineChild);
fireExpandedVisibleListenerIfVisible();
// forceUpdateVisibilities cancels outstanding animations without updating the
// mAnimationStartVisibleType. Do so here instead.
@@ -1002,8 +970,6 @@ public class NotificationContentView extends FrameLayout {
mSingleLineView, mSingleLineView);
updateViewVisibility(visibleType, VISIBLE_TYPE_AMBIENT,
mAmbientChild, mAmbientWrapper);
updateViewVisibility(visibleType, VISIBLE_TYPE_AMBIENT_SINGLELINE,
mAmbientSingleLineChild, mAmbientSingleLineChild);
fireExpandedVisibleListenerIfVisible();
// updateViewVisibilities cancels outstanding animations without updating the
// mAnimationStartVisibleType. Do so here instead.
@@ -1066,8 +1032,6 @@ public class NotificationContentView extends FrameLayout {
return mSingleLineView;
case VISIBLE_TYPE_AMBIENT:
return mAmbientWrapper;
case VISIBLE_TYPE_AMBIENT_SINGLELINE:
return mAmbientSingleLineChild;
default:
return mContractedWrapper;
}
@@ -1087,8 +1051,6 @@ public class NotificationContentView extends FrameLayout {
return mSingleLineView;
case VISIBLE_TYPE_AMBIENT:
return mAmbientChild;
case VISIBLE_TYPE_AMBIENT_SINGLELINE:
return mAmbientSingleLineChild;
default:
return mContractedChild;
}
@@ -1145,8 +1107,7 @@ public class NotificationContentView extends FrameLayout {
}
boolean onAmbient = mContainingNotification.isOnAmbient();
if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded()) {
return onAmbient ? VISIBLE_TYPE_AMBIENT_SINGLELINE
: VISIBLE_TYPE_SINGLELINE;
return VISIBLE_TYPE_SINGLELINE;
}
if ((mIsHeadsUp || mHeadsUpAnimatingAway) && mHeadsUpChild != null
@@ -1259,7 +1220,6 @@ public class NotificationContentView extends FrameLayout {
private void updateAllSingleLineViews() {
updateSingleLineView();
updateAmbientSingleLineView();
}
private void updateSingleLineView() {
@@ -1277,21 +1237,6 @@ public class NotificationContentView extends FrameLayout {
}
}
private void updateAmbientSingleLineView() {
if (mIsChildInGroup) {
boolean isNewView = mAmbientSingleLineChild == null;
mAmbientSingleLineChild = mHybridGroupManager.bindAmbientFromNotification(
mAmbientSingleLineChild, mStatusBarNotification.getNotification());
if (isNewView) {
updateViewVisibility(mVisibleType, VISIBLE_TYPE_AMBIENT_SINGLELINE,
mAmbientSingleLineChild, mAmbientSingleLineChild);
}
} else if (mAmbientSingleLineChild != null) {
removeView(mAmbientSingleLineChild);
mAmbientSingleLineChild = null;
}
}
private void applyMediaTransfer(final NotificationEntry entry) {
View bigContentView = mExpandedChild;
if (bigContentView == null || !entry.isMediaNotification()) {

View File

@@ -55,8 +55,6 @@ public class NotificationChildrenContainer extends ViewGroup {
static final int NUMBER_OF_CHILDREN_WHEN_SYSTEM_EXPANDED = 5;
@VisibleForTesting
static final int NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED = 8;
@VisibleForTesting
static final int NUMBER_OF_CHILDREN_WHEN_AMBIENT = 1;
private static final AnimationProperties ALPHA_FADE_IN = new AnimationProperties() {
private AnimationFilter mAnimationFilter = new AnimationFilter().animateAlpha();
@@ -95,8 +93,6 @@ public class NotificationChildrenContainer extends ViewGroup {
private NotificationViewWrapper mNotificationHeaderWrapper;
private NotificationHeaderView mNotificationHeaderLowPriority;
private NotificationViewWrapper mNotificationHeaderWrapperLowPriority;
private ViewGroup mNotificationHeaderAmbient;
private NotificationViewWrapper mNotificationHeaderWrapperAmbient;
private NotificationHeaderUtil mHeaderUtil;
private ViewState mHeaderViewState;
private int mClipBottomAmount;
@@ -180,11 +176,6 @@ public class NotificationChildrenContainer extends ViewGroup {
mNotificationHeaderLowPriority.getMeasuredWidth(),
mNotificationHeaderLowPriority.getMeasuredHeight());
}
if (mNotificationHeaderAmbient != null) {
mNotificationHeaderAmbient.layout(0, 0,
mNotificationHeaderAmbient.getMeasuredWidth(),
mNotificationHeaderAmbient.getMeasuredHeight());
}
}
@Override
@@ -212,8 +203,7 @@ public class NotificationChildrenContainer extends ViewGroup {
// We need to measure all children even the GONE ones, such that the heights are
// calculated correctly as they are used to calculate how many we can fit on the screen.
boolean isOverflow = i == overflowIndex;
child.setSingleLineWidthIndention(isOverflow && mOverflowNumber != null &&
!mContainingNotification.isOnAmbient()
child.setSingleLineWidthIndention(isOverflow && mOverflowNumber != null
? mOverflowNumber.getMeasuredWidth() : 0);
child.measure(widthMeasureSpec, newHeightSpec);
// layout the divider
@@ -236,10 +226,6 @@ public class NotificationChildrenContainer extends ViewGroup {
headerHeightSpec = MeasureSpec.makeMeasureSpec(mHeaderHeight, MeasureSpec.EXACTLY);
mNotificationHeaderLowPriority.measure(widthMeasureSpec, headerHeightSpec);
}
if (mNotificationHeaderAmbient != null) {
headerHeightSpec = MeasureSpec.makeMeasureSpec(mHeaderHeight, MeasureSpec.EXACTLY);
mNotificationHeaderAmbient.measure(widthMeasureSpec, headerHeightSpec);
}
setMeasuredDimension(width, height);
}
@@ -332,33 +318,10 @@ public class NotificationChildrenContainer extends ViewGroup {
}
mNotificationHeaderWrapper.onContentUpdated(mContainingNotification);
recreateLowPriorityHeader(builder);
recreateAmbientHeader(builder);
updateHeaderVisibility(false /* animate */);
updateChildrenHeaderAppearance();
}
private void recreateAmbientHeader(Notification.Builder builder) {
RemoteViews header;
StatusBarNotification notification = mContainingNotification.getStatusBarNotification();
if (builder == null) {
builder = Notification.Builder.recoverBuilder(getContext(),
notification.getNotification());
}
header = builder.makeNotificationHeader();
if (mNotificationHeaderAmbient == null) {
mNotificationHeaderAmbient = (ViewGroup) header.apply(getContext(), this);
mNotificationHeaderWrapperAmbient = NotificationViewWrapper.wrap(getContext(),
mNotificationHeaderAmbient, mContainingNotification);
mNotificationHeaderWrapperAmbient.onContentUpdated(mContainingNotification);
addView(mNotificationHeaderAmbient, 0);
invalidate();
} else {
header.reapply(getContext(), mNotificationHeaderAmbient);
}
resetHeaderVisibilityIfNeeded(mNotificationHeaderAmbient, calculateDesiredHeader());
mNotificationHeaderWrapperAmbient.onContentUpdated(mContainingNotification);
}
/**
* Recreate the low-priority header.
*
@@ -406,17 +369,6 @@ public class NotificationChildrenContainer extends ViewGroup {
if (childCount > maxAllowedVisibleChildren) {
int number = childCount - maxAllowedVisibleChildren;
mOverflowNumber = mHybridGroupManager.bindOverflowNumber(mOverflowNumber, number);
if (mContainingNotification.isOnAmbient()) {
ExpandableNotificationRow overflowView = mChildren.get(0);
HybridNotificationView ambientSingleLineView = overflowView == null ? null
: overflowView.getAmbientSingleLineView();
if (ambientSingleLineView != null) {
mHybridGroupManager.bindOverflowNumberAmbient(
ambientSingleLineView.getTitleView(),
mContainingNotification.getStatusBarNotification().getNotification(),
number);
}
}
if (mGroupOverFlowState == null) {
mGroupOverFlowState = new ViewState();
mNeverAppliedGroupState = true;
@@ -522,7 +474,7 @@ public class NotificationChildrenContainer extends ViewGroup {
if (mUserLocked) {
expandFactor = getGroupExpandFraction();
}
boolean childrenExpanded = mChildrenExpanded || mContainingNotification.isOnAmbient();
boolean childrenExpanded = mChildrenExpanded;
for (int i = 0; i < childCount; i++) {
if (visibleChildren >= maxAllowedVisibleChildren) {
break;
@@ -563,7 +515,7 @@ public class NotificationChildrenContainer extends ViewGroup {
/**
* Update the state of all its children based on a linear layout algorithm.
* @param parentState the state of the parent
* @param ambientState
* @param ambientState the ambient state containing ambient information
*/
public void updateState(ExpandableViewState parentState, AmbientState ambientState) {
int childCount = mChildren.size();
@@ -639,9 +591,7 @@ public class NotificationChildrenContainer extends ViewGroup {
getMaxAllowedVisibleChildren(true /* likeCollapsed */), childCount) - 1);
mGroupOverFlowState.copyFrom(overflowView.getViewState());
if (mContainingNotification.isOnAmbient()) {
mGroupOverFlowState.alpha = 0.0f;
} else if (!mChildrenExpanded) {
if (!mChildrenExpanded) {
HybridNotificationView alignView = overflowView.getSingleLineView();
if (alignView != null) {
View mirrorView = alignView.getTextView();
@@ -708,9 +658,6 @@ public class NotificationChildrenContainer extends ViewGroup {
@VisibleForTesting
int getMaxAllowedVisibleChildren(boolean likeCollapsed) {
if (mContainingNotification.isOnAmbient()) {
return NUMBER_OF_CHILDREN_WHEN_AMBIENT;
}
if (!likeCollapsed && (mChildrenExpanded || mContainingNotification.isUserLocked())
&& !showingAsLowPriority()) {
return NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED;
@@ -900,11 +847,6 @@ public class NotificationChildrenContainer extends ViewGroup {
return mCurrentHeader;
}
public void notifyDozingStateChanged() {
updateHeaderVisibility(false);
updateGroupOverflow();
}
private void updateHeaderVisibility(boolean animate) {
ViewGroup desiredHeader;
ViewGroup currentHeader = mCurrentHeader;
@@ -913,10 +855,6 @@ public class NotificationChildrenContainer extends ViewGroup {
if (currentHeader == desiredHeader) {
return;
}
if (desiredHeader == mNotificationHeaderAmbient
|| currentHeader == mNotificationHeaderAmbient) {
animate = false;
}
if (animate) {
if (desiredHeader != null && currentHeader != null) {
@@ -948,7 +886,6 @@ public class NotificationChildrenContainer extends ViewGroup {
}
resetHeaderVisibilityIfNeeded(mNotificationHeader, desiredHeader);
resetHeaderVisibilityIfNeeded(mNotificationHeaderAmbient, desiredHeader);
resetHeaderVisibilityIfNeeded(mNotificationHeaderLowPriority, desiredHeader);
mCurrentHeader = desiredHeader;
@@ -970,9 +907,7 @@ public class NotificationChildrenContainer extends ViewGroup {
private ViewGroup calculateDesiredHeader() {
ViewGroup desiredHeader;
if (mContainingNotification.isOnAmbient()) {
desiredHeader = mNotificationHeaderAmbient;
} else if (showingAsLowPriority()) {
if (showingAsLowPriority()) {
desiredHeader = mNotificationHeaderLowPriority;
} else {
desiredHeader = mNotificationHeader;
@@ -1015,9 +950,6 @@ public class NotificationChildrenContainer extends ViewGroup {
if (visibleHeader == mNotificationHeader) {
return mNotificationHeaderWrapper;
}
if (visibleHeader == mNotificationHeaderAmbient) {
return mNotificationHeaderWrapperAmbient;
}
return mNotificationHeaderWrapperLowPriority;
}
@@ -1126,9 +1058,7 @@ public class NotificationChildrenContainer extends ViewGroup {
}
public int getMinHeight() {
return getMinHeight(mContainingNotification.isOnAmbient()
? NUMBER_OF_CHILDREN_WHEN_AMBIENT
: NUMBER_OF_CHILDREN_WHEN_COLLAPSED, false /* likeHighPriority */);
return getMinHeight(NUMBER_OF_CHILDREN_WHEN_COLLAPSED, false /* likeHighPriority */);
}
public int getCollapsedHeight() {
@@ -1180,10 +1110,6 @@ public class NotificationChildrenContainer extends ViewGroup {
removeView(mNotificationHeaderLowPriority);
mNotificationHeaderLowPriority = null;
}
if (mNotificationHeaderAmbient != null) {
removeView(mNotificationHeaderAmbient);
mNotificationHeaderAmbient = null;
}
recreateNotificationHeader(listener);
initDimens();
for (int i = 0; i < mDividers.size(); i++) {

View File

@@ -50,13 +50,6 @@ public class NotificationChildrenContainerTest extends SysuiTestCase {
mChildrenContainer = mGroup.getChildrenContainer();
}
@Test
public void testGetMaxAllowedVisibleChildren_ambient() {
mGroup.setOnAmbient(true);
Assert.assertEquals(mChildrenContainer.getMaxAllowedVisibleChildren(),
NotificationChildrenContainer.NUMBER_OF_CHILDREN_WHEN_AMBIENT);
}
@Test
public void testGetMaxAllowedVisibleChildren_lowPriority() {
mChildrenContainer.setIsLowPriority(true);