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"
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"
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"
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"
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"
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;
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;
private boolean mDimmed = false;
private boolean mScreenSaverMode = false;
- private DateFormat mDateFormat;
+ private String mDateFormat;
private int mBatteryLevel = -1;
private boolean mPluggedIn = false;
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.
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 {
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() {
// 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);