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
This commit is contained in:
Selim Cinek
2015-10-22 13:00:05 -07:00
parent 34d93b0985
commit 8d6440dbab
4 changed files with 87 additions and 2 deletions

View File

@@ -33,9 +33,9 @@ import android.widget.ImageView;
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 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
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);
}

View File

@@ -442,4 +442,16 @@ public class NotificationContentView extends FrameLayout {
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);
}
}
}

View File

@@ -27,10 +27,12 @@ import android.graphics.ColorMatrixColorFilter;
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 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
/** 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 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
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 @@ public class NotificationTemplateViewWrapper extends NotificationViewWrapper {
}
}
@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);
}

View File

@@ -30,6 +30,7 @@ public abstract class NotificationViewWrapper {
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 @@ public abstract class NotificationViewWrapper {
/**
* 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 abstract class NotificationViewWrapper {
public boolean needsRoundRectClipping() {
return false;
}
/**
* Change the subTextVisibility
* @param visible Should the subtext be visible
*/
public void setSubTextVisible(boolean visible) {
mSubTextVisible = visible;
}
}