diff options
author | Daniel Sandler <dsandler@android.com> | 2012-09-12 17:23:10 -0700 |
---|---|---|
committer | Daniel Sandler <dsandler@android.com> | 2012-09-13 13:17:54 -0700 |
commit | 0c89049ebf463bde186c41fe9fad63ad27182eb2 (patch) | |
tree | 4d6d00a087368e7c8d4b2dac21937e80bbf0243e /core/java/android/app/Notification.java | |
parent | 8a0e1fefeeefac5024ff1ca1d044caa66b6c36a6 (diff) | |
download | frameworks_base-0c89049ebf463bde186c41fe9fad63ad27182eb2.zip frameworks_base-0c89049ebf463bde186c41fe9fad63ad27182eb2.tar.gz frameworks_base-0c89049ebf463bde186c41fe9fad63ad27182eb2.tar.bz2 |
Add Notification.Builder.setShowWhen(boolean).
No more setting when to 0 to hide the timestamp! *cheering*
Bug: 6915046
Change-Id: I1560a1c2dd366d416d1d059704ca7c63149334eb
Diffstat (limited to 'core/java/android/app/Notification.java')
-rw-r--r-- | core/java/android/app/Notification.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index cb83dc2..4bb7589 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -951,6 +951,7 @@ public class Notification implements Parcelable private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS); private boolean mUseChronometer; private Style mStyle; + private boolean mShowWhen = true; /** * Constructs a new Builder with the defaults: @@ -982,8 +983,9 @@ public class Notification implements Parcelable /** * Add a timestamp pertaining to the notification (usually the time the event occurred). + * It will be shown in the notification content view by default; use + * {@link Builder#setShowWhen(boolean) setShowWhen} to control this. * - * @see Notification#when */ public Builder setWhen(long when) { @@ -992,6 +994,15 @@ public class Notification implements Parcelable } /** + * Control whether the timestamp set with {@link Builder#setWhen(long) setWhen} is shown + * in the content view. + */ + public Builder setShowWhen(boolean show) { + mShowWhen = show; + return this; + } + + /** * Show the {@link Notification#when} field as a stopwatch. * * Instead of presenting <code>when</code> as a timestamp, the notification will show an @@ -1467,7 +1478,7 @@ public class Notification implements Parcelable contentView.setViewPadding(R.id.line1, 0, 0, 0, 0); } - if (mWhen != 0) { + if (mWhen != 0 && mShowWhen) { if (mUseChronometer) { contentView.setViewVisibility(R.id.chronometer, View.VISIBLE); contentView.setLong(R.id.chronometer, "setBase", @@ -1477,7 +1488,10 @@ public class Notification implements Parcelable contentView.setViewVisibility(R.id.time, View.VISIBLE); contentView.setLong(R.id.time, "setTime", mWhen); } + } else { + contentView.setViewVisibility(R.id.time, View.GONE); } + contentView.setViewVisibility(R.id.line3, showLine3 ? View.VISIBLE : View.GONE); contentView.setViewVisibility(R.id.overflow_divider, showLine3 ? View.VISIBLE : View.GONE); return contentView; |