Started visual hierarchy for min priority notifications
Min priority notifications are now greyed out and in an
even smaller form-factor then before.
Test: add low-priority notifications - observe visuals
Bug: 34469375
Change-Id: I3ce2cbf22dbc3276ac738224a16c1b10165964f3
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 5b74e23..2f36436 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -46,6 +46,7 @@
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
+import android.os.SystemProperties;
import android.os.UserHandle;
import android.text.BidiFormatter;
import android.text.SpannableStringBuilder;
@@ -2407,6 +2408,9 @@
private static final int MAX_ACTION_BUTTONS = 3;
+ private static final boolean USE_ONLY_TITLE_IN_LOW_PRIORITY_SUMMARY =
+ SystemProperties.getBoolean("notifications.only_title", true);
+
private Context mContext;
private Notification mN;
private Bundle mUserExtras = new Bundle();
@@ -3731,7 +3735,7 @@
} else if (mActions.size() != 0) {
result = applyStandardTemplateWithActions(getBigBaseLayoutResource());
}
- adaptNotificationHeaderForBigContentView(result);
+ makeHeaderExpanded(result);
return result;
}
@@ -3766,7 +3770,12 @@
}
}
- private void adaptNotificationHeaderForBigContentView(RemoteViews result) {
+ /**
+ * Adapt the Notification header if this view is used as an expanded view.
+ *
+ * @hide
+ */
+ public static void makeHeaderExpanded(RemoteViews result) {
if (result != null) {
result.setBoolean(R.id.notification_header, "setExpanded", true);
}
@@ -3826,7 +3835,57 @@
return publicView;
}
+ /**
+ * Construct a content view for the display when low - priority
+ *
+ * @param useRegularSubtext uses the normal subtext set if there is one available. Otherwise
+ * a new subtext is created consisting of the content of the
+ * notification.
+ * @hide
+ */
+ public RemoteViews makeLowPriorityContentView(boolean useRegularSubtext) {
+ int color = mN.color;
+ mN.color = COLOR_DEFAULT;
+ CharSequence summary = mN.extras.getCharSequence(EXTRA_SUB_TEXT);
+ if (!useRegularSubtext || TextUtils.isEmpty(summary)) {
+ CharSequence newSummary = createSummaryText();
+ if (!TextUtils.isEmpty(newSummary)) {
+ mN.extras.putCharSequence(EXTRA_SUB_TEXT, newSummary);
+ }
+ }
+ RemoteViews header = makeNotificationHeader();
+ if (summary != null) {
+ mN.extras.putCharSequence(EXTRA_SUB_TEXT, summary);
+ } else {
+ mN.extras.remove(EXTRA_SUB_TEXT);
+ }
+ mN.color = color;
+ return header;
+ }
+ private CharSequence createSummaryText() {
+ CharSequence titleText = mN.extras.getCharSequence(Notification.EXTRA_TITLE);
+ if (USE_ONLY_TITLE_IN_LOW_PRIORITY_SUMMARY) {
+ return titleText;
+ }
+ SpannableStringBuilder summary = new SpannableStringBuilder();
+ if (titleText == null) {
+ titleText = mN.extras.getCharSequence(Notification.EXTRA_TITLE_BIG);
+ }
+ BidiFormatter bidi = BidiFormatter.getInstance();
+ if (titleText != null) {
+ summary.append(bidi.unicodeWrap(titleText));
+ }
+ CharSequence contentText = mN.extras.getCharSequence(Notification.EXTRA_TEXT);
+ if (titleText != null && contentText != null) {
+ summary.append(bidi.unicodeWrap(mContext.getText(
+ R.string.notification_header_divider_symbol_with_spaces)));
+ }
+ if (contentText != null) {
+ summary.append(bidi.unicodeWrap(contentText));
+ }
+ return summary;
+ }
private RemoteViews generateActionButton(Action action, boolean emphazisedMode,
boolean oddAction, boolean ambient) {
diff --git a/core/res/res/layout/notification_template_header.xml b/core/res/res/layout/notification_template_header.xml
index 1f71a18..0dfeb62 100644
--- a/core/res/res/layout/notification_template_header.xml
+++ b/core/res/res/layout/notification_template_header.xml
@@ -20,10 +20,11 @@
android:id="@+id/notification_header"
android:orientation="horizontal"
android:layout_width="wrap_content"
- android:layout_height="53dp"
+ android:layout_height="48dp"
android:clipChildren="false"
android:paddingTop="10dp"
- android:paddingBottom="16dp"
+ android:paddingBottom="11dp"
+ android:layout_marginBottom="5dp"
android:paddingStart="@dimen/notification_content_margin_start"
android:paddingEnd="16dp">
<com.android.internal.widget.CachingIconView
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index d09b190..a6c547d 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -578,6 +578,9 @@
<!-- The divider symbol between different parts of the notification header. not translatable [CHAR LIMIT=1] -->
<string name="notification_header_divider_symbol" translatable="false">•</string>
+ <!-- The divider symbol between different parts of the notification header including spaces. not translatable [CHAR LIMIT=3] -->
+ <string name="notification_header_divider_symbol_with_spaces" translatable="false">" • "</string>
+
<!-- Text shown in place of notification contents when the notification is hidden on a secure lockscreen -->
<string name="notification_hidden_text">Contents hidden</string>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index c370ef7..2f0ac9d 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2783,6 +2783,7 @@
<java-symbol type="drawable" name="lockscreen_notselected" />
<java-symbol type="drawable" name="lockscreen_selected" />
+ <java-symbol type="string" name="notification_header_divider_symbol_with_spaces" />
<java-symbol type="string" name="config_defaultCellBroadcastReceiverComponent" />
<java-symbol type="string" name="app_category_game" />
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index faf143e..c8d280d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -100,7 +100,6 @@
import com.android.systemui.assist.AssistManager;
import com.android.systemui.recents.Recents;
import com.android.systemui.statusbar.NotificationData.Entry;
-import com.android.systemui.statusbar.NotificationGuts.OnGutsClosedListener;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.phone.NavigationBarView;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
@@ -1513,8 +1512,9 @@
entry.notification.getUser().getIdentifier());
final StatusBarNotification sbn = entry.notification;
+ boolean isLowPriority = mNotificationData.isAmbient(sbn.getKey());
try {
- entry.cacheContentViews(mContext, null);
+ entry.cacheContentViews(mContext, null, isLowPriority);
} catch (RuntimeException e) {
Log.e(TAG, "Unable to get notification remote views", e);
return false;
@@ -1586,6 +1586,7 @@
workAroundBadLayerDrawableOpacity(row);
bindDismissRunnable(row);
+ row.setIsLowPriority(isLowPriority);
// NB: the large icon is now handled entirely by the template
@@ -2263,7 +2264,8 @@
boolean applyInPlace;
try {
- applyInPlace = entry.cacheContentViews(mContext, notification.getNotification());
+ applyInPlace = entry.cacheContentViews(mContext, notification.getNotification(),
+ mNotificationData.isAmbient(key));
} catch (RuntimeException e) {
Log.e(TAG, "Unable to get notification remote views", e);
applyInPlace = false;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 93c48f8..013554c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -22,6 +22,7 @@
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.Nullable;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.ColorDrawable;
@@ -51,6 +52,7 @@
import com.android.systemui.R;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.statusbar.notification.HybridNotificationView;
+import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.policy.HeadsUpManager;
@@ -201,6 +203,7 @@
private boolean mShowAmbient;
private boolean mIsLastChild;
private Runnable mOnDismissRunnable;
+ private boolean mIsLowPriority;
public boolean isGroupExpansionChanging() {
if (isChildInGroup()) {
@@ -309,6 +312,18 @@
mPublicLayout.updateExpandButtons(true);
updateLimits();
updateIconVisibilities();
+ updateShelfIconColor();
+ }
+
+ private void updateShelfIconColor() {
+ StatusBarIconView expandedIcon = mEntry.expandedIcon;
+ boolean isPreL = Boolean.TRUE.equals(expandedIcon.getTag(R.id.icon_is_pre_L));
+ boolean colorize = !isPreL || NotificationUtils.isGrayscale(expandedIcon,
+ NotificationColorUtil.getInstance(mContext));
+ if (colorize) {
+ int color = mEntry.getContrastedColor(mContext, mIsLowPriority && !isExpanded());
+ expandedIcon.setImageTintList(ColorStateList.valueOf(color));
+ }
}
private void updateLimits() {
@@ -943,6 +958,14 @@
return mPrivateLayout.getTranslationY();
}
+ public void setIsLowPriority(boolean isLowPriority) {
+ mIsLowPriority = isLowPriority;
+ mPrivateLayout.setIsLowPriority(isLowPriority);
+ if (mChildrenContainer != null) {
+ mChildrenContainer.setIsLowPriority(isLowPriority);
+ }
+ }
+
public interface ExpansionLogger {
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
}
@@ -1043,6 +1066,7 @@
@Override
public void onInflate(ViewStub stub, View inflated) {
mChildrenContainer = (NotificationChildrenContainer) inflated;
+ mChildrenContainer.setIsLowPriority(mIsLowPriority);
mChildrenContainer.setNotificationParent(ExpandableNotificationRow.this);
mChildrenContainer.onNotificationUpdated();
mTranslateableViews.add(mChildrenContainer);
@@ -1242,6 +1266,7 @@
*/
public void setUserExpanded(boolean userExpanded) {
setUserExpanded(userExpanded, false /* allowChildExpansion */);
+ updateShelfIconColor();
}
/**
@@ -1301,6 +1326,7 @@
if (expand != mIsSystemExpanded) {
final boolean wasExpanded = isExpanded();
mIsSystemExpanded = expand;
+ updateShelfIconColor();
notifyHeightChanged(false /* needsAnimation */);
logExpansionEvent(false, wasExpanded);
if (mIsSummaryWithChildren) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index b45cde8..4d0ce12 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -129,6 +129,7 @@
private boolean mHeadsUpAnimatingAway;
private boolean mIconsVisible;
private int mClipBottomAmount;
+ private boolean mIsLowPriority;
public NotificationContentView(Context context, AttributeSet attrs) {
@@ -163,20 +164,31 @@
if (mExpandedChild != null) {
int size = Math.min(maxSize, mNotificationMaxHeight);
ViewGroup.LayoutParams layoutParams = mExpandedChild.getLayoutParams();
+ boolean useExactly = false;
if (layoutParams.height >= 0) {
// An actual height is set
size = Math.min(maxSize, layoutParams.height);
+ useExactly = true;
}
int spec = size == Integer.MAX_VALUE
? MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
- : MeasureSpec.makeMeasureSpec(size, MeasureSpec.AT_MOST);
+ : MeasureSpec.makeMeasureSpec(size, useExactly
+ ? MeasureSpec.EXACTLY
+ : MeasureSpec.AT_MOST);
mExpandedChild.measure(widthMeasureSpec, spec);
maxChildHeight = Math.max(maxChildHeight, mExpandedChild.getMeasuredHeight());
}
if (mContractedChild != null) {
int heightSpec;
int size = Math.min(maxSize, mSmallHeight);
- if (shouldContractedBeFixedSize()) {
+ ViewGroup.LayoutParams layoutParams = mContractedChild.getLayoutParams();
+ boolean useExactly = false;
+ if (layoutParams.height >= 0) {
+ // An actual height is set
+ size = Math.min(size, layoutParams.height);
+ useExactly = true;
+ }
+ if (shouldContractedBeFixedSize() || useExactly) {
heightSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
} else {
heightSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.AT_MOST);
@@ -202,12 +214,15 @@
if (mHeadsUpChild != null) {
int size = Math.min(maxSize, mHeadsUpHeight);
ViewGroup.LayoutParams layoutParams = mHeadsUpChild.getLayoutParams();
+ boolean useExactly = false;
if (layoutParams.height >= 0) {
// An actual height is set
size = Math.min(size, layoutParams.height);
+ useExactly = true;
}
mHeadsUpChild.measure(widthMeasureSpec,
- MeasureSpec.makeMeasureSpec(size, MeasureSpec.AT_MOST));
+ MeasureSpec.makeMeasureSpec(size, useExactly ? MeasureSpec.EXACTLY
+ : MeasureSpec.AT_MOST));
maxChildHeight = Math.max(maxChildHeight, mHeadsUpChild.getMeasuredHeight());
}
if (mSingleLineView != null) {
@@ -225,12 +240,15 @@
if (mAmbientChild != null) {
int size = Math.min(maxSize, mNotificationAmbientHeight);
ViewGroup.LayoutParams layoutParams = mAmbientChild.getLayoutParams();
+ boolean useExactly = false;
if (layoutParams.height >= 0) {
// An actual height is set
size = Math.min(size, layoutParams.height);
+ useExactly = true;
}
mAmbientChild.measure(widthMeasureSpec,
- MeasureSpec.makeMeasureSpec(size, MeasureSpec.AT_MOST));
+ MeasureSpec.makeMeasureSpec(size, useExactly ? MeasureSpec.EXACTLY
+ : MeasureSpec.AT_MOST));
maxChildHeight = Math.max(maxChildHeight, mAmbientChild.getMeasuredHeight());
}
int ownHeight = Math.min(maxChildHeight, maxSize);
@@ -606,7 +624,7 @@
}
public int getMinHeight(boolean likeGroupExpanded) {
- if (likeGroupExpanded || !mIsChildInGroup || isGroupExpanded()) {
+ if (likeGroupExpanded || !mIsChildInGroup || isGroupExpanded() || mIsLowPriority) {
return mContractedChild.getHeight();
} else {
return mSingleLineView.getHeight();
@@ -868,7 +886,7 @@
height = mContentHeight;
}
int expandedVisualType = getVisualTypeForHeight(height);
- int collapsedVisualType = mIsChildInGroup && !isGroupExpanded()
+ int collapsedVisualType = mIsChildInGroup && !isGroupExpanded() && !mIsLowPriority
? VISIBLE_TYPE_SINGLELINE
: getVisualTypeForHeight(mContainingNotification.getCollapsedHeight());
return mTransformationStartVisibleType == collapsedVisualType
@@ -889,7 +907,7 @@
if (!noExpandedChild && viewHeight == mExpandedChild.getHeight()) {
return VISIBLE_TYPE_EXPANDED;
}
- if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded()) {
+ if (!mUserExpanding && mIsChildInGroup && !isGroupExpanded() && !mIsLowPriority) {
return VISIBLE_TYPE_SINGLELINE;
}
@@ -976,16 +994,16 @@
updateSingleLineView();
applyRemoteInput(entry);
if (mContractedChild != null) {
- mContractedWrapper.notifyContentUpdated(entry.notification);
+ mContractedWrapper.notifyContentUpdated(entry.notification, mIsLowPriority);
}
if (mExpandedChild != null) {
- mExpandedWrapper.notifyContentUpdated(entry.notification);
+ mExpandedWrapper.notifyContentUpdated(entry.notification, mIsLowPriority);
}
if (mHeadsUpChild != null) {
- mHeadsUpWrapper.notifyContentUpdated(entry.notification);
+ mHeadsUpWrapper.notifyContentUpdated(entry.notification, mIsLowPriority);
}
if (mAmbientChild != null) {
- mAmbientWrapper.notifyContentUpdated(entry.notification);
+ mAmbientWrapper.notifyContentUpdated(entry.notification, mIsLowPriority);
}
updateShowingLegacyBackground();
mForceSelectNextLayout = true;
@@ -1282,4 +1300,8 @@
}
}
}
+
+ public void setIsLowPriority(boolean isLowPriority) {
+ mIsLowPriority = isLowPriority;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index 458daf1..3530a47 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -115,14 +115,16 @@
return row.getPublicLayout().getContractedChild();
}
- public boolean cacheContentViews(Context ctx, Notification updatedNotification) {
+ public boolean cacheContentViews(Context ctx, Notification updatedNotification,
+ boolean isLowPriority) {
boolean applyInPlace = false;
if (updatedNotification != null) {
final Notification.Builder updatedNotificationBuilder
= Notification.Builder.recoverBuilder(ctx, updatedNotification);
- final RemoteViews newContentView = updatedNotificationBuilder.createContentView();
- final RemoteViews newBigContentView =
- updatedNotificationBuilder.createBigContentView();
+ final RemoteViews newContentView = createContentView(updatedNotificationBuilder,
+ isLowPriority);
+ final RemoteViews newBigContentView = createBigContentView(
+ updatedNotificationBuilder, isLowPriority);
final RemoteViews newHeadsUpContentView =
updatedNotificationBuilder.createHeadsUpContentView();
final RemoteViews newPublicNotification
@@ -150,8 +152,8 @@
final Notification.Builder builder
= Notification.Builder.recoverBuilder(ctx, notification.getNotification());
- cachedContentView = builder.createContentView();
- cachedBigContentView = builder.createBigContentView();
+ cachedContentView = createContentView(builder, isLowPriority);
+ cachedBigContentView = createBigContentView(builder, isLowPriority);
cachedHeadsUpContentView = builder.createHeadsUpContentView();
cachedPublicContentView = builder.makePublicContentView();
cachedAmbientContentView = builder.makeAmbientNotification();
@@ -161,6 +163,28 @@
return applyInPlace;
}
+ private RemoteViews createBigContentView(Notification.Builder builder,
+ boolean isLowPriority) {
+ RemoteViews bigContentView = builder.createBigContentView();
+ if (bigContentView != null) {
+ return bigContentView;
+ }
+ if (isLowPriority) {
+ RemoteViews contentView = builder.createContentView();
+ Notification.Builder.makeHeaderExpanded(contentView);
+ return contentView;
+ }
+ return null;
+ }
+
+ private RemoteViews createContentView(Notification.Builder builder,
+ boolean isAmbient) {
+ if (isAmbient) {
+ return builder.makeLowPriorityContentView(false /* useRegularSubtext */);
+ }
+ return builder.createContentView();
+ }
+
// Returns true if the RemoteViews are the same.
private boolean compareRemoteViews(final RemoteViews a, final RemoteViews b) {
return (a == null && b == null) ||
@@ -254,8 +278,9 @@
}
}
- public int getContrastedColor(Context context) {
- int rawColor = notification.getNotification().color;
+ public int getContrastedColor(Context context, boolean ambient) {
+ int rawColor = ambient ? Notification.COLOR_DEFAULT :
+ notification.getNotification().color;
if (mCachedContrastColorIsFor == rawColor && mCachedContrastColor != COLOR_INVALID) {
return mCachedContrastColor;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/TransformableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/TransformableView.java
index dd7c4c7..063252f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/TransformableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/TransformableView.java
@@ -22,7 +22,7 @@
* A view that can be transformed to and from.
*/
public interface TransformableView {
- int TRANSFORMING_VIEW_HEADER = 0;
+ int TRANSFORMING_VIEW_ICON = 0;
int TRANSFORMING_VIEW_TITLE = 1;
int TRANSFORMING_VIEW_TEXT = 2;
int TRANSFORMING_VIEW_IMAGE = 3;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HeaderTransformState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/HeaderTransformState.java
deleted file mode 100644
index 9501f90..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HeaderTransformState.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package com.android.systemui.statusbar.notification;
-
-import android.util.Pools;
-import android.view.NotificationHeaderView;
-import android.view.View;
-
-import com.android.systemui.statusbar.CrossFadeHelper;
-
-/**
- * A transform state of a text view.
-*/
-public class HeaderTransformState extends TransformState {
-
- private static Pools.SimplePool<HeaderTransformState> sInstancePool
- = new Pools.SimplePool<>(40);
- private View mExpandButton;
- private View mWorkProfileIcon;
- private TransformState mWorkProfileState;
-
- @Override
- public void initFrom(View view) {
- super.initFrom(view);
- if (view instanceof NotificationHeaderView) {
- NotificationHeaderView header = (NotificationHeaderView) view;
- mExpandButton = header.getExpandButton();
- mWorkProfileState = TransformState.obtain();
- mWorkProfileIcon = header.getWorkProfileIcon();
- mWorkProfileState.initFrom(mWorkProfileIcon);
- }
- }
-
- @Override
- public boolean transformViewTo(TransformState otherState, float transformationAmount) {
- // if the transforming notification has a header, we have ensured that it looks the same
- // but the expand button, so lets fade just that one and transform the work profile icon.
- if (!(mTransformedView instanceof NotificationHeaderView)) {
- return false;
- }
- NotificationHeaderView header = (NotificationHeaderView) mTransformedView;
- int childCount = header.getChildCount();
- for (int i = 0; i < childCount; i++) {
- View headerChild = header.getChildAt(i);
- if (headerChild.getVisibility() == View.GONE) {
- continue;
- }
- if (headerChild != mExpandButton) {
- headerChild.setVisibility(View.INVISIBLE);
- } else {
- CrossFadeHelper.fadeOut(mExpandButton, transformationAmount);
- }
- }
- return true;
- }
-
- @Override
- public void transformViewFrom(TransformState otherState, float transformationAmount) {
- // if the transforming notification has a header, we have ensured that it looks the same
- // but the expand button, so lets fade just that one and transform the work profile icon.
- if (!(mTransformedView instanceof NotificationHeaderView)) {
- return;
- }
- NotificationHeaderView header = (NotificationHeaderView) mTransformedView;
- header.setVisibility(View.VISIBLE);
- header.setAlpha(1.0f);
- int childCount = header.getChildCount();
- for (int i = 0; i < childCount; i++) {
- View headerChild = header.getChildAt(i);
- if (headerChild.getVisibility() == View.GONE) {
- continue;
- }
- if (headerChild == mExpandButton) {
- CrossFadeHelper.fadeIn(mExpandButton, transformationAmount);
- } else {
- headerChild.setVisibility(View.VISIBLE);
- if (headerChild == mWorkProfileIcon) {
- mWorkProfileState.transformViewFullyFrom(
- ((HeaderTransformState) otherState).mWorkProfileState,
- transformationAmount);
- }
- }
- }
- return;
- }
-
- public static HeaderTransformState obtain() {
- HeaderTransformState instance = sInstancePool.acquire();
- if (instance != null) {
- return instance;
- }
- return new HeaderTransformState();
- }
-
- @Override
- public void recycle() {
- super.recycle();
- sInstancePool.release(this);
- }
-
- @Override
- protected void reset() {
- super.reset();
- mExpandButton = null;
- mWorkProfileState = null;
- if (mWorkProfileState != null) {
- mWorkProfileState.recycle();
- mWorkProfileState = null;
- }
- }
-
- @Override
- public void setVisible(boolean visible, boolean force) {
- super.setVisible(visible, force);
- if (!(mTransformedView instanceof NotificationHeaderView)) {
- return;
- }
- NotificationHeaderView header = (NotificationHeaderView) mTransformedView;
- int childCount = header.getChildCount();
- for (int i = 0; i < childCount; i++) {
- View headerChild = header.getChildAt(i);
- if (!force && headerChild.getVisibility() == View.GONE) {
- continue;
- }
- headerChild.animate().cancel();
- if (headerChild.getVisibility() != View.GONE) {
- headerChild.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
- }
- if (headerChild == mExpandButton) {
- headerChild.setAlpha(visible ? 1.0f : 0.0f);
- }
- if (headerChild == mWorkProfileIcon) {
- headerChild.setTranslationX(0);
- headerChild.setTranslationY(0);
- }
- }
- }
-
- @Override
- public void prepareFadeIn() {
- super.prepareFadeIn();
- if (!(mTransformedView instanceof NotificationHeaderView)) {
- return;
- }
- NotificationHeaderView header = (NotificationHeaderView) mTransformedView;
- int childCount = header.getChildCount();
- for (int i = 0; i < childCount; i++) {
- View headerChild = header.getChildAt(i);
- if (headerChild.getVisibility() == View.GONE) {
- continue;
- }
- headerChild.animate().cancel();
- headerChild.setVisibility(View.VISIBLE);
- headerChild.setAlpha(1.0f);
- if (headerChild == mWorkProfileIcon) {
- headerChild.setTranslationX(0);
- headerChild.setTranslationY(0);
- }
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigPictureTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigPictureTemplateViewWrapper.java
index 6084770..78b967a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigPictureTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigPictureTemplateViewWrapper.java
@@ -36,8 +36,8 @@
}
@Override
- public void notifyContentUpdated(StatusBarNotification notification) {
- super.notifyContentUpdated(notification);
+ public void notifyContentUpdated(StatusBarNotification notification, boolean isLowPriority) {
+ super.notifyContentUpdated(notification, isLowPriority);
updateImageTag(notification);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigTextTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigTextTemplateViewWrapper.java
index 3f49125..39db243 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigTextTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationBigTextTemplateViewWrapper.java
@@ -41,11 +41,11 @@
}
@Override
- public void notifyContentUpdated(StatusBarNotification notification) {
+ public void notifyContentUpdated(StatusBarNotification notification, boolean isLowPriority) {
// Reinspect the notification. Before the super call, because the super call also updates
// the transformation types and we need to have our values set by then.
resolveViews(notification);
- super.notifyContentUpdated(notification);
+ super.notifyContentUpdated(notification, isLowPriority);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationCustomViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationCustomViewWrapper.java
index 85e87dd..d564741 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationCustomViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationCustomViewWrapper.java
@@ -106,8 +106,8 @@
}
@Override
- public void notifyContentUpdated(StatusBarNotification notification) {
- super.notifyContentUpdated(notification);
+ public void notifyContentUpdated(StatusBarNotification notification, boolean isLowPriority) {
+ super.notifyContentUpdated(notification, isLowPriority);
Drawable background = mView.getBackground();
mBackgroundColor = 0;
if (background instanceof ColorDrawable) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java
index 3e4c758..e1f553c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationHeaderViewWrapper.java
@@ -32,6 +32,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.TextView;
import com.android.systemui.R;
import com.android.systemui.ViewInvertHelper;
@@ -60,6 +61,9 @@
private ImageView mExpandButton;
private NotificationHeaderView mNotificationHeader;
+ private TextView mHeaderText;
+ private ImageView mWorkProfileImage;
+ private boolean mIsLowPriority;
protected NotificationHeaderViewWrapper(Context ctx, View view, ExpandableNotificationRow row) {
super(view, row);
@@ -72,7 +76,9 @@
protected void resolveHeaderViews() {
mIcon = (ImageView) mView.findViewById(com.android.internal.R.id.icon);
+ mHeaderText = (TextView) mView.findViewById(com.android.internal.R.id.header_text);
mExpandButton = (ImageView) mView.findViewById(com.android.internal.R.id.expand_button);
+ mWorkProfileImage = (ImageView) mView.findViewById(com.android.internal.R.id.profile_badge);
mColor = resolveColor(mExpandButton);
mNotificationHeader = (NotificationHeaderView) mView.findViewById(
com.android.internal.R.id.notification_header);
@@ -89,9 +95,9 @@
}
@Override
- public void notifyContentUpdated(StatusBarNotification notification) {
- super.notifyContentUpdated(notification);
-
+ public void notifyContentUpdated(StatusBarNotification notification, boolean isLowPriority) {
+ super.notifyContentUpdated(notification, isLowPriority);
+ mIsLowPriority = isLowPriority;
ArraySet<View> previousViews = mTransformationHelper.getAllTransformingViews();
// Reinspect the notification.
@@ -100,6 +106,11 @@
updateTransformedTypes();
addRemainingTransformTypes();
updateCropToPaddingForImageViews();
+ mIcon.setTag(ImageTransformState.ICON_TAG, notification.getNotification().getSmallIcon());
+ // The work profile image is always the same lets just set the icon tag for it not to
+ // animate
+ mWorkProfileImage.setTag(ImageTransformState.ICON_TAG,
+ notification.getNotification().getSmallIcon());
// We need to reset all views that are no longer transforming in case a view was previously
// transformed, but now we decided to transform its container instead.
@@ -154,8 +165,11 @@
protected void updateTransformedTypes() {
mTransformationHelper.reset();
- mTransformationHelper.addTransformedView(TransformableView.TRANSFORMING_VIEW_HEADER,
- mNotificationHeader);
+ mTransformationHelper.addTransformedView(TransformableView.TRANSFORMING_VIEW_ICON, mIcon);
+ if (mIsLowPriority) {
+ mTransformationHelper.addTransformedView(TransformableView.TRANSFORMING_VIEW_TITLE,
+ mHeaderText);
+ }
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java
index 4ce330c..04ee6aa 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMediaTemplateViewWrapper.java
@@ -40,11 +40,11 @@
}
@Override
- public void notifyContentUpdated(StatusBarNotification notification) {
+ public void notifyContentUpdated(StatusBarNotification notification, boolean isLowPriority) {
// Reinspect the notification. Before the super call, because the super call also updates
// the transformation types and we need to have our values set by then.
resolveViews(notification);
- super.notifyContentUpdated(notification);
+ super.notifyContentUpdated(notification, isLowPriority);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMessagingTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMessagingTemplateViewWrapper.java
index ff2febf..b787ae5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMessagingTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationMessagingTemplateViewWrapper.java
@@ -54,11 +54,11 @@
}
@Override
- public void notifyContentUpdated(StatusBarNotification notification) {
+ public void notifyContentUpdated(StatusBarNotification notification, boolean isLowPriority) {
// Reinspect the notification. Before the super call, because the super call also updates
// the transformation types and we need to have our values set by then.
resolveViews();
- super.notifyContentUpdated(notification);
+ super.notifyContentUpdated(notification, isLowPriority);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
index b984c0b..e9956ff 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
@@ -133,11 +133,11 @@
}
@Override
- public void notifyContentUpdated(StatusBarNotification notification) {
+ public void notifyContentUpdated(StatusBarNotification notification, boolean isLowPriority) {
// Reinspect the notification. Before the super call, because the super call also updates
// the transformation types and we need to have our values set by then.
resolveTemplateViews(notification);
- super.notifyContentUpdated(notification);
+ super.notifyContentUpdated(notification, isLowPriority);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
index 16348dfe..8106223 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationViewWrapper.java
@@ -80,9 +80,10 @@
/**
* Notifies this wrapper that the content of the view might have changed.
- * @param notification
+ * @param notification the notification this is wrapped around
+ * @param isLowPriority is this notification low priority
*/
- public void notifyContentUpdated(StatusBarNotification notification) {
+ public void notifyContentUpdated(StatusBarNotification notification, boolean isLowPriority) {
mDarkInitialized = false;
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java
index 770ec95..6b3d25d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/TransformState.java
@@ -402,11 +402,6 @@
result.initFrom(view);
return result;
}
- if (view instanceof NotificationHeaderView) {
- HeaderTransformState result = HeaderTransformState.obtain();
- result.initFrom(view);
- return result;
- }
if (view instanceof ImageView) {
ImageTransformState result = ImageTransformState.obtain();
result.initFrom(view);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
index 345dcbd..32b9969 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
@@ -154,18 +154,6 @@
NotificationShelf.SHOW_AMBIENT_ICONS);
applyNotificationIconsTint();
- ArrayList<NotificationData.Entry> activeNotifications
- = notificationData.getActiveNotifications();
- for (int i = 0; i < activeNotifications.size(); i++) {
- NotificationData.Entry entry = activeNotifications.get(i);
- boolean isPreL = Boolean.TRUE.equals(entry.expandedIcon.getTag(R.id.icon_is_pre_L));
- boolean colorize = !isPreL
- || NotificationUtils.isGrayscale(entry.expandedIcon, mNotificationColorUtil);
- if (colorize) {
- int color = entry.getContrastedColor(mContext);
- entry.expandedIcon.setImageTintList(ColorStateList.valueOf(color));
- }
- }
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
index 1a2d778..e6a3add 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
@@ -78,6 +78,7 @@
private NotificationHeaderUtil mHeaderUtil;
private ViewState mHeaderViewState;
private int mClipBottomAmount;
+ private boolean mIsLowPriority;
public NotificationChildrenContainer(Context context) {
this(context, null);
@@ -246,10 +247,13 @@
return mChildren.size();
}
- public void recreateNotificationHeader(OnClickListener listener, StatusBarNotification notification) {
+ public void recreateNotificationHeader(OnClickListener listener,
+ StatusBarNotification notification) {
final Notification.Builder builder = Notification.Builder.recoverBuilder(getContext(),
mNotificationParent.getStatusBarNotification().getNotification());
- final RemoteViews header = builder.makeNotificationHeader();
+ final RemoteViews header = mIsLowPriority
+ ? builder.makeLowPriorityContentView(true /* useRegularSubtext */)
+ : builder.makeNotificationHeader();
if (mNotificationHeader == null) {
mNotificationHeader = (NotificationHeaderView) header.apply(getContext(), this);
final View expandButton = mNotificationHeader.findViewById(
@@ -262,7 +266,7 @@
invalidate();
} else {
header.reapply(getContext(), mNotificationHeader);
- mNotificationHeaderWrapper.notifyContentUpdated(notification);
+ mNotificationHeaderWrapper.notifyContentUpdated(notification, mIsLowPriority);
}
updateChildrenHeaderAppearance();
}
@@ -367,6 +371,9 @@
* @return the intrinsic size of this children container, i.e the natural fully expanded state
*/
public int getIntrinsicHeight() {
+ if (mIsLowPriority && !mChildrenExpanded) {
+ return mNotificationHeader.getHeight();
+ }
int maxAllowedVisibleChildren = getMaxAllowedVisibleChildren();
return getIntrinsicHeight(maxAllowedVisibleChildren);
}
@@ -480,7 +487,7 @@
childState.clipTopAmount = 0;
childState.alpha = 0;
if (i < firstOverflowIndex) {
- childState.alpha = 1;
+ childState.alpha = mIsLowPriority && !mChildrenExpanded ? expandFactor : 1.0f;
} else if (expandFactor == 1.0f && i <= lastVisibleIndex) {
childState.alpha = (mActualHeight - childState.yTranslation) / childState.height;
childState.alpha = Math.max(0.0f, Math.min(1.0f, childState.alpha));
@@ -828,6 +835,9 @@
}
private int getMinHeight(int maxAllowedVisibleChildren) {
+ if (mIsLowPriority && !mChildrenExpanded) {
+ return mNotificationHeader.getHeight();
+ }
int minExpandHeight = mNotificationHeaderMargin;
int visibleChildren = 0;
boolean firstChild = true;
@@ -922,4 +932,8 @@
mClipBottomAmount = clipBottomAmount;
updateChildrenClipping();
}
+
+ public void setIsLowPriority(boolean isLowPriority) {
+ mIsLowPriority = isLowPriority;
+ }
}