@@ -951,6 +951,7 @@ public static class Builder {
951951 private ArrayList <Action > mActions = new ArrayList <Action >(MAX_ACTION_BUTTONS );
952952 private boolean mUseChronometer ;
953953 private Style mStyle ;
954+ private boolean mShowWhen = true ;
954955
955956 /**
956957 * Constructs a new Builder with the defaults:
@@ -982,15 +983,25 @@ public Builder(Context context) {
982983
983984 /**
984985 * Add a timestamp pertaining to the notification (usually the time the event occurred).
986+ * It will be shown in the notification content view by default; use
987+ * {@link Builder#setShowWhen(boolean) setShowWhen} to control this.
985988 *
986-
987989 * @see Notification#when
988990 */
989991 public Builder setWhen (long when ) {
990992 mWhen = when ;
991993 return this ;
992994 }
993995
996+ /**
997+ * Control whether the timestamp set with {@link Builder#setWhen(long) setWhen} is shown
998+ * in the content view.
999+ */
1000+ public Builder setShowWhen (boolean show ) {
1001+ mShowWhen = show ;
1002+ return this ;
1003+ }
1004+
9941005 /**
9951006 * Show the {@link Notification#when} field as a stopwatch.
9961007 *
@@ -1467,7 +1478,7 @@ private RemoteViews applyStandardTemplate(int resId, boolean fitIn1U) {
14671478 contentView .setViewPadding (R .id .line1 , 0 , 0 , 0 , 0 );
14681479 }
14691480
1470- if (mWhen != 0 ) {
1481+ if (mWhen != 0 && mShowWhen ) {
14711482 if (mUseChronometer ) {
14721483 contentView .setViewVisibility (R .id .chronometer , View .VISIBLE );
14731484 contentView .setLong (R .id .chronometer , "setBase" ,
@@ -1477,7 +1488,10 @@ private RemoteViews applyStandardTemplate(int resId, boolean fitIn1U) {
14771488 contentView .setViewVisibility (R .id .time , View .VISIBLE );
14781489 contentView .setLong (R .id .time , "setTime" , mWhen );
14791490 }
1491+ } else {
1492+ contentView .setViewVisibility (R .id .time , View .GONE );
14801493 }
1494+
14811495 contentView .setViewVisibility (R .id .line3 , showLine3 ? View .VISIBLE : View .GONE );
14821496 contentView .setViewVisibility (R .id .overflow_divider , showLine3 ? View .VISIBLE : View .GONE );
14831497 return contentView ;
0 commit comments