OSDN Git Service

Fine-tuning the DeskClock UI.
authorDaniel Sandler <dsandler@google.com>
Fri, 13 Nov 2009 20:02:08 +0000 (12:02 -0800)
committerDaniel Sandler <dsandler@google.com>
Fri, 13 Nov 2009 20:03:23 +0000 (12:03 -0800)
Date format used is the new full_wday_month_day_no_year,
which should fix http://b/2254472 and http://b/2247356 .

Font sizes and colors tweaked to match latest spec.

res/layout-land/desk_clock.xml
res/layout/desk_clock.xml
res/layout/desk_clock_battery.xml
res/layout/desk_clock_saver.xml
res/layout/desk_clock_time_date.xml
res/layout/desk_clock_weather.xml
src/com/android/deskclock/DeskClock.java

index 8e7ce88..6ea363b 100644 (file)
@@ -55,8 +55,7 @@
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
                     android:gravity="left"
-                    android:textSize="18sp"
-                    android:textColor="#FFFFFFFF"
+                                       android:textAppearance="?android:attr/textAppearanceMedium"
                     android:drawablePadding="6dip"
                     android:drawableLeft="@drawable/ic_lock_idle_alarm"
                     android:shadowColor="#C0000000"
index 2246a2f..7ffd1d2 100644 (file)
@@ -57,8 +57,7 @@
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
                     android:gravity="left"
-                    android:textSize="18sp"
-                    android:textColor="#FFFFFFFF"
+                                       android:textAppearance="?android:attr/textAppearanceMedium"
                     android:drawablePadding="6dip"
                     android:drawableLeft="@drawable/ic_lock_idle_alarm"
                     android:shadowColor="#C0000000"
index ded2ffc..9537500 100644 (file)
@@ -17,8 +17,7 @@
 <!-- battery/charge status -->
 <TextView android:id="@+id/battery" xmlns:android="http://schemas.android.com/apk/res/android"
     android:gravity="right"
-    android:textSize="18sp"
-    android:textColor="#FFFFFFFF"
+       android:textAppearance="?android:attr/textAppearanceMedium"
     android:drawablePadding="6dip"
     android:shadowColor="#C0000000"
     android:shadowDx="0"
index d34adfd..9450661 100644 (file)
@@ -40,8 +40,7 @@
             android:layout_height="wrap_content"
             android:layout_marginBottom="10dip"
             android:gravity="left"
-            android:textSize="18sp"
-            android:textColor="#FFFFFFFF"
+                       android:textAppearance="?android:attr/textAppearanceMedium"
             android:drawablePadding="6dip"
             />
         <include layout="@layout/desk_clock_time_date"
index d6791f3..411115e 100644 (file)
             android:layout_width="wrap_content"
             android:layout_height="fill_parent"
             android:gravity="bottom"
-            android:textSize="24sp"
+                       android:textAppearance="?android:attr/textAppearanceMedium"
+                       android:textStyle="bold"
             android:singleLine="true"
             android:layout_marginLeft="3dip"
-            android:textColor="#FFFFFFFF"
             android:shadowColor="#C0000000"
             android:shadowDx="0"
             android:shadowDy="0"
@@ -63,8 +63,7 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:gravity="left"
-        android:textSize="22sp"
-        android:textColor="#FFFFFFFF"
+               android:textAppearance="?android:attr/textAppearanceMedium"
         android:shadowColor="#C0000000"
         android:shadowDx="0"
         android:shadowDy="0"
index 6847d14..c5ee761 100644 (file)
@@ -40,8 +40,8 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:singleLine="true"
-            android:textSize="50sp"
-            android:textColor="#FFFFFFFF"
+            android:textSize="46sp"
+                       android:textColor="?android:attr/textColorPrimary"
             android:shadowColor="#C0000000"
             android:shadowDx="0"
             android:shadowDy="0"
@@ -55,8 +55,8 @@
             android:layout_width="40sp"
             android:layout_height="wrap_content"
             android:singleLine="true"
-            android:textSize="16sp"
-            android:textColor="#FFBEBEBE"
+                       android:textAppearance="?android:attr/textAppearanceSmall"
+                       android:textColor="?android:attr/textColorSecondary"
             android:shadowColor="#C0000000"
             android:shadowDx="0"
             android:shadowDy="0"
@@ -68,8 +68,8 @@
             android:layout_width="40sp"
             android:layout_height="wrap_content"
             android:singleLine="true"
-            android:textSize="18sp"
-            android:textColor="#FFFFFFFF"
+                       android:textAppearance="?android:attr/textAppearanceSmall"
+                       android:textColor="?android:attr/textColorPrimary"
             android:shadowColor="#C0000000"
             android:shadowDx="0"
             android:shadowDy="0"
index e7060b5..654d6d9 100644 (file)
@@ -41,6 +41,7 @@ import android.os.SystemClock;
 import android.os.PowerManager;
 import android.provider.Settings;
 import android.text.TextUtils;
+import android.text.format.DateFormat;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.ContextMenu.ContextMenuInfo;
@@ -74,8 +75,6 @@ import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Locale;
@@ -155,7 +154,7 @@ public class DeskClock extends Activity {
     private boolean mDimmed = false;
     private boolean mScreenSaverMode = false;
 
-    private DateFormat mDateFormat;
+    private String mDateFormat;
 
     private int mBatteryLevel = -1;
     private boolean mPluggedIn = false;
@@ -336,16 +335,6 @@ public class DeskClock extends Activity {
         mWeatherFetchScheduled = false;
     }
 
-    private static final boolean sCelsius;
-    static {
-        String cc = Locale.getDefault().getCountry().toLowerCase();
-        sCelsius = !("us".equals(cc) || "bz".equals(cc) || "jm".equals(cc));
-    }
-
-    private static int celsiusToLocal(int tempC) {
-        return sCelsius ? tempC : (int) Math.round(tempC * 1.8f + 32);
-    }
-
     private void fetchWeatherData() {
         // if we couldn't load the weather widget's resources, we simply
         // assume it's not present on the device.
@@ -390,11 +379,11 @@ public class DeskClock extends Activity {
             mWeatherIconDrawable = mGenieResources.getDrawable(cur.getInt(
                 cur.getColumnIndexOrThrow("iconResId")));
             mWeatherCurrentTemperatureString = String.format("%d\u00b0",
-                celsiusToLocal(cur.getInt(cur.getColumnIndexOrThrow("temperature"))));
+                (cur.getInt(cur.getColumnIndexOrThrow("temperature"))));
             mWeatherHighTemperatureString = String.format("%d\u00b0",
-                celsiusToLocal(cur.getInt(cur.getColumnIndexOrThrow("highTemperature"))));
+                (cur.getInt(cur.getColumnIndexOrThrow("highTemperature"))));
             mWeatherLowTemperatureString = String.format("%d\u00b0",
-                celsiusToLocal(cur.getInt(cur.getColumnIndexOrThrow("lowTemperature"))));
+                (cur.getInt(cur.getColumnIndexOrThrow("lowTemperature"))));
             mWeatherLocationString = cur.getString(
                 cur.getColumnIndexOrThrow("location"));
         } else {
@@ -455,7 +444,7 @@ public class DeskClock extends Activity {
     private void refreshDate() {
         final Date now = new Date();
         if (DEBUG) Log.d(LOG_TAG, "refreshing date..." + now);
-        mDate.setText(mDateFormat.format(now));
+        mDate.setText(DateFormat.format(mDateFormat, now));
     }
 
     private void refreshAlarm() {
@@ -521,15 +510,7 @@ public class DeskClock extends Activity {
 
         // reload the date format in case the user has changed settings
         // recently
-        final SimpleDateFormat dateFormat = (SimpleDateFormat)
-                java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL);
-        // This is a little clumsy; we want to honor the locale's date format
-        // (rather than simply hardcoding "Weekday, Month Date") but
-        // DateFormat.FULL includes the year (at least, in enUS). So we lop
-        // that bit off if it's there; should have no effect on
-        // locale-specific date strings that look different.
-        mDateFormat = new SimpleDateFormat(dateFormat.toPattern()
-                    .replace(", yyyy", "")); // no year
+        mDateFormat = getString(com.android.internal.R.string.full_wday_month_day_no_year);
 
         IntentFilter filter = new IntentFilter();
         filter.addAction(Intent.ACTION_DATE_CHANGED);