From 3d1728c03a0cd1aaed6bc81c97de27d62c771a6e Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Wed, 31 Oct 2012 20:31:58 -0700 Subject: A new clock widget to create lock screen appwidgets This new widget replaces DigitalClock. It listens to all the correct system events and offer the ability to customize the formatting patterns in 12-hour and 24-hour modes. It also supports fixed time zones to create world clocks. One more step towards becoming ClockOS! Change-Id: I677e5dfca8cd8c8d1f8c49e54d7507f4d1885bf4 --- core/java/android/widget/DigitalClock.java | 31 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'core/java/android/widget/DigitalClock.java') diff --git a/core/java/android/widget/DigitalClock.java b/core/java/android/widget/DigitalClock.java index 3e9107f..c6b6dd6 100644 --- a/core/java/android/widget/DigitalClock.java +++ b/core/java/android/widget/DigitalClock.java @@ -17,7 +17,6 @@ package android.widget; import android.content.Context; -import android.content.res.Resources; import android.database.ContentObserver; import android.os.Handler; import android.os.SystemClock; @@ -32,14 +31,12 @@ import java.util.Calendar; /** * Like AnalogClock, but digital. Shows seconds. * - * FIXME: implement separate views for hours/minutes/seconds, so - * proportional fonts don't shake rendering - * - * @deprecated It is recommended you use a {@link TextView} and {@link DateFormat} - * to implement the same behavior. + * @deprecated It is recommended you use {@link TextClock} instead. */ @Deprecated public class DigitalClock extends TextView { + // FIXME: implement separate views for hours/minutes/seconds, so + // proportional fonts don't shake rendering Calendar mCalendar; private final static String m12 = "h:mm:ss aa"; @@ -86,16 +83,16 @@ public class DigitalClock extends TextView { * requests a tick on the next hard-second boundary */ mTicker = new Runnable() { - public void run() { - if (mTickerStopped) return; - mCalendar.setTimeInMillis(System.currentTimeMillis()); - setText(DateFormat.format(mFormat, mCalendar)); - invalidate(); - long now = SystemClock.uptimeMillis(); - long next = now + (1000 - now % 1000); - mHandler.postAtTime(mTicker, next); - } - }; + public void run() { + if (mTickerStopped) return; + mCalendar.setTimeInMillis(System.currentTimeMillis()); + setText(DateFormat.format(mFormat, mCalendar)); + invalidate(); + long now = SystemClock.uptimeMillis(); + long next = now + (1000 - now % 1000); + mHandler.postAtTime(mTicker, next); + } + }; mTicker.run(); } @@ -134,12 +131,14 @@ public class DigitalClock extends TextView { @Override public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); + //noinspection deprecation event.setClassName(DigitalClock.class.getName()); } @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); + //noinspection deprecation info.setClassName(DigitalClock.class.getName()); } } -- cgit v1.1