Loading api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -423,6 +423,7 @@ package android { field public static final int controlX2 = 16843774; // 0x10103fe field public static final int controlY1 = 16843773; // 0x10103fd field public static final int controlY2 = 16843775; // 0x10103ff field public static final int countDown = 16844060; // 0x101051c field public static final int country = 16843962; // 0x10104ba field public static final int cropToPadding = 16843043; // 0x1010123 field public static final int cursorVisible = 16843090; // 0x1010152 Loading Loading @@ -46069,7 +46070,9 @@ package android.widget { method public long getBase(); method public java.lang.String getFormat(); method public android.widget.Chronometer.OnChronometerTickListener getOnChronometerTickListener(); method public boolean isCountDown(); method public void setBase(long); method public void setCountDown(boolean); method public void setFormat(java.lang.String); method public void setOnChronometerTickListener(android.widget.Chronometer.OnChronometerTickListener); method public void start(); api/system-current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -518,6 +518,7 @@ package android { field public static final int controlX2 = 16843774; // 0x10103fe field public static final int controlY1 = 16843773; // 0x10103fd field public static final int controlY2 = 16843775; // 0x10103ff field public static final int countDown = 16844060; // 0x101051c field public static final int country = 16843962; // 0x10104ba field public static final int cropToPadding = 16843043; // 0x1010123 field public static final int cursorVisible = 16843090; // 0x1010152 Loading Loading @@ -49170,7 +49171,9 @@ package android.widget { method public long getBase(); method public java.lang.String getFormat(); method public android.widget.Chronometer.OnChronometerTickListener getOnChronometerTickListener(); method public boolean isCountDown(); method public void setBase(long); method public void setCountDown(boolean); method public void setFormat(java.lang.String); method public void setOnChronometerTickListener(android.widget.Chronometer.OnChronometerTickListener); method public void start(); api/test-current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -423,6 +423,7 @@ package android { field public static final int controlX2 = 16843774; // 0x10103fe field public static final int controlY1 = 16843773; // 0x10103fd field public static final int controlY2 = 16843775; // 0x10103ff field public static final int countDown = 16844060; // 0x101051c field public static final int country = 16843962; // 0x10104ba field public static final int cropToPadding = 16843043; // 0x1010123 field public static final int cursorVisible = 16843090; // 0x1010152 Loading Loading @@ -46086,7 +46087,9 @@ package android.widget { method public long getBase(); method public java.lang.String getFormat(); method public android.widget.Chronometer.OnChronometerTickListener getOnChronometerTickListener(); method public boolean isCountDown(); method public void setBase(long); method public void setCountDown(boolean); method public void setFormat(java.lang.String); method public void setOnChronometerTickListener(android.widget.Chronometer.OnChronometerTickListener); method public void start(); core/java/android/widget/Chronometer.java +42 −6 Original line number Diff line number Diff line Loading @@ -19,15 +19,14 @@ package android.widget; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.text.format.DateUtils; import android.util.AttributeSet; import android.util.Log; import android.view.accessibility.AccessibilityEvent; import android.widget.RemoteViews.RemoteView; import com.android.internal.R; import java.util.Formatter; import java.util.IllegalFormatException; import java.util.Locale; Loading @@ -37,11 +36,17 @@ import java.util.Locale; * <p> * You can give it a start time in the {@link SystemClock#elapsedRealtime} timebase, * and it counts up from that, or if you don't give it a base time, it will use the * time at which you call {@link #start}. By default it will display the current * time at which you call {@link #start}. * * <p>The timer can also count downward towards the base time by * setting {@link #setCountDown(boolean)} to true. * * <p>By default it will display the current * timer value in the form "MM:SS" or "H:MM:SS", or you can use {@link #setFormat} * to format the timer value into an arbitrary string. * * @attr ref android.R.styleable#Chronometer_format * @attr ref android.R.styleable#Chronometer_countDown */ @RemoteView public class Chronometer extends TextView { Loading Loading @@ -72,6 +77,7 @@ public class Chronometer extends TextView { private StringBuilder mFormatBuilder; private OnChronometerTickListener mOnChronometerTickListener; private StringBuilder mRecycle = new StringBuilder(8); private boolean mCountDown; /** * Initialize this Chronometer object. Loading Loading @@ -102,7 +108,8 @@ public class Chronometer extends TextView { final TypedArray a = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.Chronometer, defStyleAttr, defStyleRes); setFormat(a.getString(com.android.internal.R.styleable.Chronometer_format)); setFormat(a.getString(R.styleable.Chronometer_format)); setCountDown(a.getBoolean(R.styleable.Chronometer_countDown, false)); a.recycle(); init(); Loading @@ -113,6 +120,27 @@ public class Chronometer extends TextView { updateText(mBase); } /** * Set this view to count down to the base instead of counting up from it. * * @param countDown whether this view should count down * * @see #setBase(long) */ @android.view.RemotableViewMethod public void setCountDown(boolean countDown) { mCountDown = countDown; } /** * @return whether this view counts down * * @see #setCountDown(boolean) */ public boolean isCountDown() { return mCountDown; } /** * Set the time that the count-up timer is in reference to. * Loading Loading @@ -226,9 +254,17 @@ public class Chronometer extends TextView { private synchronized void updateText(long now) { mNow = now; long seconds = now - mBase; long seconds = mCountDown ? mBase - now : now - mBase; seconds /= 1000; boolean negative = false; if (seconds < 0) { seconds = -seconds; negative = true; } String text = DateUtils.formatElapsedTime(mRecycle, seconds); if (negative) { text = getResources().getString(R.string.negative_duration, text); } if (mFormat != null) { Locale loc = Locale.getDefault(); Loading core/res/res/values/attrs.xml +3 −0 Original line number Diff line number Diff line Loading @@ -3539,6 +3539,9 @@ i If no format string is specified, the Chronometer will simply display "MM:SS" or "H:MM:SS". --> <attr name="format" format="string" localization="suggested" /> <!-- Specifies whether this Chronometer counts down or counts up from the base. If not specified this is false and the Chronometer counts up. --> <attr name="countDown" format="boolean" /> </declare-styleable> <declare-styleable name="CompoundButton"> <!-- Indicates the initial checked state of this button. --> Loading Loading
api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -423,6 +423,7 @@ package android { field public static final int controlX2 = 16843774; // 0x10103fe field public static final int controlY1 = 16843773; // 0x10103fd field public static final int controlY2 = 16843775; // 0x10103ff field public static final int countDown = 16844060; // 0x101051c field public static final int country = 16843962; // 0x10104ba field public static final int cropToPadding = 16843043; // 0x1010123 field public static final int cursorVisible = 16843090; // 0x1010152 Loading Loading @@ -46069,7 +46070,9 @@ package android.widget { method public long getBase(); method public java.lang.String getFormat(); method public android.widget.Chronometer.OnChronometerTickListener getOnChronometerTickListener(); method public boolean isCountDown(); method public void setBase(long); method public void setCountDown(boolean); method public void setFormat(java.lang.String); method public void setOnChronometerTickListener(android.widget.Chronometer.OnChronometerTickListener); method public void start();
api/system-current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -518,6 +518,7 @@ package android { field public static final int controlX2 = 16843774; // 0x10103fe field public static final int controlY1 = 16843773; // 0x10103fd field public static final int controlY2 = 16843775; // 0x10103ff field public static final int countDown = 16844060; // 0x101051c field public static final int country = 16843962; // 0x10104ba field public static final int cropToPadding = 16843043; // 0x1010123 field public static final int cursorVisible = 16843090; // 0x1010152 Loading Loading @@ -49170,7 +49171,9 @@ package android.widget { method public long getBase(); method public java.lang.String getFormat(); method public android.widget.Chronometer.OnChronometerTickListener getOnChronometerTickListener(); method public boolean isCountDown(); method public void setBase(long); method public void setCountDown(boolean); method public void setFormat(java.lang.String); method public void setOnChronometerTickListener(android.widget.Chronometer.OnChronometerTickListener); method public void start();
api/test-current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -423,6 +423,7 @@ package android { field public static final int controlX2 = 16843774; // 0x10103fe field public static final int controlY1 = 16843773; // 0x10103fd field public static final int controlY2 = 16843775; // 0x10103ff field public static final int countDown = 16844060; // 0x101051c field public static final int country = 16843962; // 0x10104ba field public static final int cropToPadding = 16843043; // 0x1010123 field public static final int cursorVisible = 16843090; // 0x1010152 Loading Loading @@ -46086,7 +46087,9 @@ package android.widget { method public long getBase(); method public java.lang.String getFormat(); method public android.widget.Chronometer.OnChronometerTickListener getOnChronometerTickListener(); method public boolean isCountDown(); method public void setBase(long); method public void setCountDown(boolean); method public void setFormat(java.lang.String); method public void setOnChronometerTickListener(android.widget.Chronometer.OnChronometerTickListener); method public void start();
core/java/android/widget/Chronometer.java +42 −6 Original line number Diff line number Diff line Loading @@ -19,15 +19,14 @@ package android.widget; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.text.format.DateUtils; import android.util.AttributeSet; import android.util.Log; import android.view.accessibility.AccessibilityEvent; import android.widget.RemoteViews.RemoteView; import com.android.internal.R; import java.util.Formatter; import java.util.IllegalFormatException; import java.util.Locale; Loading @@ -37,11 +36,17 @@ import java.util.Locale; * <p> * You can give it a start time in the {@link SystemClock#elapsedRealtime} timebase, * and it counts up from that, or if you don't give it a base time, it will use the * time at which you call {@link #start}. By default it will display the current * time at which you call {@link #start}. * * <p>The timer can also count downward towards the base time by * setting {@link #setCountDown(boolean)} to true. * * <p>By default it will display the current * timer value in the form "MM:SS" or "H:MM:SS", or you can use {@link #setFormat} * to format the timer value into an arbitrary string. * * @attr ref android.R.styleable#Chronometer_format * @attr ref android.R.styleable#Chronometer_countDown */ @RemoteView public class Chronometer extends TextView { Loading Loading @@ -72,6 +77,7 @@ public class Chronometer extends TextView { private StringBuilder mFormatBuilder; private OnChronometerTickListener mOnChronometerTickListener; private StringBuilder mRecycle = new StringBuilder(8); private boolean mCountDown; /** * Initialize this Chronometer object. Loading Loading @@ -102,7 +108,8 @@ public class Chronometer extends TextView { final TypedArray a = context.obtainStyledAttributes( attrs, com.android.internal.R.styleable.Chronometer, defStyleAttr, defStyleRes); setFormat(a.getString(com.android.internal.R.styleable.Chronometer_format)); setFormat(a.getString(R.styleable.Chronometer_format)); setCountDown(a.getBoolean(R.styleable.Chronometer_countDown, false)); a.recycle(); init(); Loading @@ -113,6 +120,27 @@ public class Chronometer extends TextView { updateText(mBase); } /** * Set this view to count down to the base instead of counting up from it. * * @param countDown whether this view should count down * * @see #setBase(long) */ @android.view.RemotableViewMethod public void setCountDown(boolean countDown) { mCountDown = countDown; } /** * @return whether this view counts down * * @see #setCountDown(boolean) */ public boolean isCountDown() { return mCountDown; } /** * Set the time that the count-up timer is in reference to. * Loading Loading @@ -226,9 +254,17 @@ public class Chronometer extends TextView { private synchronized void updateText(long now) { mNow = now; long seconds = now - mBase; long seconds = mCountDown ? mBase - now : now - mBase; seconds /= 1000; boolean negative = false; if (seconds < 0) { seconds = -seconds; negative = true; } String text = DateUtils.formatElapsedTime(mRecycle, seconds); if (negative) { text = getResources().getString(R.string.negative_duration, text); } if (mFormat != null) { Locale loc = Locale.getDefault(); Loading
core/res/res/values/attrs.xml +3 −0 Original line number Diff line number Diff line Loading @@ -3539,6 +3539,9 @@ i If no format string is specified, the Chronometer will simply display "MM:SS" or "H:MM:SS". --> <attr name="format" format="string" localization="suggested" /> <!-- Specifies whether this Chronometer counts down or counts up from the base. If not specified this is false and the Chronometer counts up. --> <attr name="countDown" format="boolean" /> </declare-styleable> <declare-styleable name="CompoundButton"> <!-- Indicates the initial checked state of this button. --> Loading