Hiding subtext of children notifications now
If the parent header already displays the email
we don’t want to display it again in the child.
Bug: 24866646
Change-Id: I3aee62e895fef68b059a61a825eef37f0f8ad875
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 026c5f7..b8df139 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -33,9 +33,9 @@
import com.android.systemui.R;
import com.android.systemui.classifier.FalsingManager;
+import com.android.systemui.statusbar.notification.NotificationHeaderView;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.stack.NotificationChildrenContainer;
-import com.android.systemui.statusbar.notification.NotificationHeaderView;
import com.android.systemui.statusbar.stack.StackScrollState;
import com.android.systemui.statusbar.stack.StackStateAnimator;
import com.android.systemui.statusbar.stack.StackViewState;
@@ -378,6 +378,19 @@
setStatusBarNotification(entry.notification);
}
+ public CharSequence getSubText() {
+ Notification notification = mStatusBarNotification.getNotification();
+ CharSequence subText = notification.extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT);
+ if (subText == null) {
+ subText = notification.extras.getCharSequence(Notification.EXTRA_SUB_TEXT);
+ }
+ return subText;
+ }
+
+ public void setContentSubTextVisible(boolean visible) {
+ mPrivateLayout.setSubTextVisible(visible);
+ }
+
public interface ExpansionLogger {
public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 86d7f4f..0e32b62 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -442,4 +442,16 @@
public void setShowingLegacyBackground(boolean showing) {
mShowingLegacyBackground = showing;
}
+
+ public void setSubTextVisible(boolean visible) {
+ if (mExpandedChild != null) {
+ mExpandedWrapper.setSubTextVisible(visible);
+ }
+ if (mContractedChild != null) {
+ mContractedWrapper.setSubTextVisible(visible);
+ }
+ if (mHeadsUpChild != null) {
+ mHeadsUpWrapper.setSubTextVisible(visible);
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationTemplateViewWrapper.java
index 958b8b5..af6ccd8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationTemplateViewWrapper.java
@@ -27,10 +27,12 @@
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
+import android.text.TextUtils;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.ImageView;
+import android.widget.TextView;
import com.android.systemui.R;
import com.android.systemui.ViewInvertHelper;
@@ -55,6 +57,11 @@
/** Whether the icon needs to be forced grayscale when in dark mode. */
private boolean mIconForceGraysaleWhenDark;
+ private TextView mSubText;
+ private TextView mInfoText;
+ private View mProfileBadge;
+ private View mThirdLineDivider;
+ private View mThirdLine;
protected NotificationTemplateViewWrapper(Context ctx, View view) {
super(view);
@@ -76,6 +83,11 @@
mIcon = resolveIcon(largeIcon, rightIcon);
mPicture = resolvePicture(largeIcon);
mIconBackgroundColor = resolveBackgroundColor(mIcon);
+ mSubText = (TextView) mView.findViewById(com.android.internal.R.id.text);
+ mInfoText = (TextView) mView.findViewById(com.android.internal.R.id.info);
+ mProfileBadge = mView.findViewById(com.android.internal.R.id.profile_badge_line3);
+ mThirdLineDivider = mView.findViewById(com.android.internal.R.id.overflow_divider);
+ mThirdLine = mView.findViewById(com.android.internal.R.id.line3);
// If the icon already has a color filter, we assume that we already forced the icon to be
// white when we created the notification.
@@ -230,6 +242,43 @@
}
}
+ @Override
+ public void setSubTextVisible(boolean visible) {
+ if (mSubText == null) {
+ return;
+ }
+ boolean subTextAvailable = !TextUtils.isEmpty(mSubText.getText());
+ if (visible && subTextAvailable) {
+ mSubText.setVisibility(View.VISIBLE);
+ } else {
+ mSubText.setVisibility(View.GONE);
+ }
+ // TODO: figure out what to do with the number (same place as contentInfo)
+ // work profile badge. For now we hide it since it looks nicer.
+ boolean infoAvailable = !TextUtils.isEmpty(mInfoText.getText());
+ if (visible && infoAvailable) {
+ mInfoText.setVisibility(View.VISIBLE);
+ } else {
+ mInfoText.setVisibility(View.GONE);
+ }
+ boolean showThirdLine = (visible && (infoAvailable || subTextAvailable))
+ || mProfileBadge.getVisibility() == View.VISIBLE;
+ if (mThirdLineDivider != null) {
+ if (showThirdLine) {
+ mThirdLineDivider.setVisibility(View.VISIBLE);
+ } else {
+ mThirdLineDivider.setVisibility(View.GONE);
+ }
+ }
+ if (mThirdLine != null) {
+ if (showThirdLine) {
+ mThirdLine.setVisibility(View.VISIBLE);
+ } else {
+ mThirdLine.setVisibility(View.GONE);
+ }
+ }
+ }
+
private void updateGrayscaleMatrix(float intensity) {
mGrayscaleColorMatrix.setSaturation(1 - intensity);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewWrapper.java
index b362a29..9bce548 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewWrapper.java
@@ -30,6 +30,7 @@
private static final String TAG_BIG_PICTURE = "bigPicture";
protected final View mView;
+ private boolean mSubTextVisible = true;
public static NotificationViewWrapper wrap(Context ctx, View v) {
if (v.getId() == com.android.internal.R.id.status_bar_latest_event_content) {
@@ -63,7 +64,9 @@
/**
* Notifies this wrapper that the content of the view might have changed.
*/
- public void notifyContentUpdated() {}
+ public void notifyContentUpdated() {
+ setSubTextVisible(mSubTextVisible);
+ }
/**
* @return true if this template might need to be clipped with a round rect to make it look
@@ -72,4 +75,12 @@
public boolean needsRoundRectClipping() {
return false;
}
+
+ /**
+ * Change the subTextVisibility
+ * @param visible Should the subtext be visible
+ */
+ public void setSubTextVisible(boolean visible) {
+ mSubTextVisible = visible;
+ }
}