diff options
| -rw-r--r-- | api/current.txt | 3 | ||||
| -rw-r--r-- | api/system-current.txt | 3 | ||||
| -rw-r--r-- | api/test-current.txt | 3 | ||||
| -rw-r--r-- | core/java/android/app/Notification.java | 27 | ||||
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 14 |
5 files changed, 50 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 9aa7dfb2380c..95c43b2d9a31 100644 --- a/api/current.txt +++ b/api/current.txt @@ -4907,6 +4907,7 @@ package android.app { field public static final int DEFAULT_VIBRATE = 2; // 0x2 field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri"; field public static final java.lang.String EXTRA_BIG_TEXT = "android.bigText"; + field public static final java.lang.String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown"; field public static final java.lang.String EXTRA_COMPACT_ACTIONS = "android.compactActions"; field public static final java.lang.String EXTRA_INFO_TEXT = "android.infoText"; field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon"; @@ -5058,6 +5059,7 @@ package android.app { method public android.app.Notification.Builder setActions(android.app.Notification.Action...); method public android.app.Notification.Builder setAutoCancel(boolean); method public android.app.Notification.Builder setCategory(java.lang.String); + method public android.app.Notification.Builder setChronometerCountsDown(boolean); method public android.app.Notification.Builder setColor(int); method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews); method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence); @@ -47216,6 +47218,7 @@ package android.widget { method public void setChar(int, java.lang.String, char); method public void setCharSequence(int, java.lang.String, java.lang.CharSequence); method public void setChronometer(int, long, java.lang.String, boolean); + method public void setChronometerCountsDown(int, boolean); method public void setContentDescription(int, java.lang.CharSequence); method public void setDisplayedChild(int, int); method public void setDouble(int, java.lang.String, double); diff --git a/api/system-current.txt b/api/system-current.txt index 966877e6d032..47c642f2eb24 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5039,6 +5039,7 @@ package android.app { field public static final int DEFAULT_VIBRATE = 2; // 0x2 field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri"; field public static final java.lang.String EXTRA_BIG_TEXT = "android.bigText"; + field public static final java.lang.String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown"; field public static final java.lang.String EXTRA_COMPACT_ACTIONS = "android.compactActions"; field public static final java.lang.String EXTRA_INFO_TEXT = "android.infoText"; field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon"; @@ -5190,6 +5191,7 @@ package android.app { method public android.app.Notification.Builder setActions(android.app.Notification.Action...); method public android.app.Notification.Builder setAutoCancel(boolean); method public android.app.Notification.Builder setCategory(java.lang.String); + method public android.app.Notification.Builder setChronometerCountsDown(boolean); method public android.app.Notification.Builder setColor(int); method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews); method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence); @@ -50334,6 +50336,7 @@ package android.widget { method public void setChar(int, java.lang.String, char); method public void setCharSequence(int, java.lang.String, java.lang.CharSequence); method public void setChronometer(int, long, java.lang.String, boolean); + method public void setChronometerCountsDown(int, boolean); method public void setContentDescription(int, java.lang.CharSequence); method public void setDisplayedChild(int, int); method public void setDouble(int, java.lang.String, double); diff --git a/api/test-current.txt b/api/test-current.txt index 4d59b6fc5b8b..7a9557c2744f 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -4907,6 +4907,7 @@ package android.app { field public static final int DEFAULT_VIBRATE = 2; // 0x2 field public static final java.lang.String EXTRA_BACKGROUND_IMAGE_URI = "android.backgroundImageUri"; field public static final java.lang.String EXTRA_BIG_TEXT = "android.bigText"; + field public static final java.lang.String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown"; field public static final java.lang.String EXTRA_COMPACT_ACTIONS = "android.compactActions"; field public static final java.lang.String EXTRA_INFO_TEXT = "android.infoText"; field public static final java.lang.String EXTRA_LARGE_ICON = "android.largeIcon"; @@ -5058,6 +5059,7 @@ package android.app { method public android.app.Notification.Builder setActions(android.app.Notification.Action...); method public android.app.Notification.Builder setAutoCancel(boolean); method public android.app.Notification.Builder setCategory(java.lang.String); + method public android.app.Notification.Builder setChronometerCountsDown(boolean); method public android.app.Notification.Builder setColor(int); method public deprecated android.app.Notification.Builder setContent(android.widget.RemoteViews); method public android.app.Notification.Builder setContentInfo(java.lang.CharSequence); @@ -47233,6 +47235,7 @@ package android.widget { method public void setChar(int, java.lang.String, char); method public void setCharSequence(int, java.lang.String, java.lang.CharSequence); method public void setChronometer(int, long, java.lang.String, boolean); + method public void setChronometerCountsDown(int, boolean); method public void setContentDescription(int, java.lang.CharSequence); method public void setDisplayedChild(int, int); method public void setDouble(int, java.lang.String, double); diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 402c112fdb63..d98c7179888f 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -823,6 +823,12 @@ public class Notification implements Parcelable public static final String EXTRA_SHOW_CHRONOMETER = "android.showChronometer"; /** + * {@link #extras} key: whether the chronometer set on the notification should count down + * instead of counting up. Is only relevant if key {@link #EXTRA_SHOW_CHRONOMETER} is present. + */ + public static final String EXTRA_CHRONOMETER_COUNTS_DOWN = "android.chronometerCountsDown"; + + /** * {@link #extras} key: whether {@link #when} should be shown, * as supplied to {@link Builder#setShowWhen(boolean)}. */ @@ -2158,8 +2164,12 @@ public class Notification implements Parcelable * * Useful when showing an elapsed time (like an ongoing phone call). * + * The counter can also be set to count down to <code>when</code> when using + * {@link #setChronometerCountsDown(boolean)}. + * * @see android.widget.Chronometer * @see Notification#when + * @see #setChronometerCountsDown(boolean) */ public Builder setUsesChronometer(boolean b) { mN.extras.putBoolean(EXTRA_SHOW_CHRONOMETER, b); @@ -2167,6 +2177,19 @@ public class Notification implements Parcelable } /** + * Sets the Chronometer to count down instead of counting up. + * + * <p>This is only relevant if {@link #setUsesChronometer(boolean)} has been set to true. + * If it isn't set the chronometer will count up. + * + * @see #setUsesChronometer(boolean) + */ + public Builder setChronometerCountsDown(boolean countsDown) { + mN.extras.putBoolean(EXTRA_CHRONOMETER_COUNTS_DOWN, countsDown); + return this; + } + + /** * Set the small icon resource, which will be used to represent the notification in the * status bar. * @@ -3097,6 +3120,8 @@ public class Notification implements Parcelable contentView.setLong(R.id.chronometer, "setBase", mN.when + (SystemClock.elapsedRealtime() - System.currentTimeMillis())); contentView.setBoolean(R.id.chronometer, "setStarted", true); + boolean countsDown = mN.extras.getBoolean(EXTRA_CHRONOMETER_COUNTS_DOWN); + contentView.setChronometerCountsDown(R.id.chronometer, countsDown); } else { contentView.setViewVisibility(R.id.time, View.VISIBLE); contentView.setLong(R.id.time, "setTime", mN.when); @@ -3328,6 +3353,8 @@ public class Notification implements Parcelable savedBundle.getBoolean(EXTRA_SHOW_WHEN)); publicExtras.putBoolean(EXTRA_SHOW_CHRONOMETER, savedBundle.getBoolean(EXTRA_SHOW_CHRONOMETER)); + publicExtras.putBoolean(EXTRA_CHRONOMETER_COUNTS_DOWN, + savedBundle.getBoolean(EXTRA_CHRONOMETER_COUNTS_DOWN)); publicExtras.putCharSequence(EXTRA_TITLE, mContext.getString(R.string.notification_hidden_text)); mN.extras = publicExtras; diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 1cccfaeb7dc3..063288e2adfc 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -2563,6 +2563,8 @@ public class RemoteViews implements Parcelable, Filter { * @param format The Chronometer format string, or null to * simply display the timer value. * @param started True if you want the clock to be started, false if not. + * + * @see #setChronometerCountsDown(int, boolean) */ public void setChronometer(int viewId, long base, String format, boolean started) { setLong(viewId, "setBase", base); @@ -2571,6 +2573,18 @@ public class RemoteViews implements Parcelable, Filter { } /** + * Equivalent to calling {@link Chronometer#setCountDown(boolean) Chronometer.setCountDown} on + * the chronometer with the given viewId. + * + * @param viewId The id of the {@link Chronometer} to change + * @param isCountDown True if you want the chronometer to count down to base instead of + * counting up. + */ + public void setChronometerCountsDown(int viewId, boolean isCountDown) { + setBoolean(viewId, "setCountDown", isCountDown); + } + + /** * Equivalent to calling {@link ProgressBar#setMax ProgressBar.setMax}, * {@link ProgressBar#setProgress ProgressBar.setProgress}, and * {@link ProgressBar#setIndeterminate ProgressBar.setIndeterminate} |