Loading res/values/strings.xml +36 −0 Original line number Diff line number Diff line Loading @@ -844,5 +844,41 @@ <!-- String for no enabled alarms in timeline view [CHAR LIMIT=30] --> <string name="no_upcoming_alarms">NO UPCOMING ALARMS</string> <!-- String that represents time format for 12-hour time. h represents hour in range (1-12) with the minimum number of digits mm represents minute with leading 0 in case of values < 10 a represents am/pm Ex: h:mm a = 12:54 am, 8:05 pm --> <string name="time_format_12_mode">h:mm a</string> <!-- String that represents time format for 24-hour time. k represents hour in range (0-23) with the minimum number of digits mm represents minute with leading 0 in case of values < 10 Ex: k:mm = 13:51, 5:05 --> <string name="time_format_24_mode">k:mm</string> <!-- String that represents weekday, time format for 12-hour time. EEE represents weekday name in short form (ex. Mon, Tue, Wed) h represents hour in range (1-12) with the minimum number of digits mm represents minute with leading 0 in case of values < 10 a represents am/pm Ex: EEE, h:mm a = Mon, 2:55 pm --> <string name="weekday_time_format_12_mode">EEE, h:mm a</string> <!-- String that represents weekday, time format for 24-hour time. EEE represents weekday name in short form (ex. Mon, Tue, Wed) k represents hour in range (0-23) with the minimum number of digits mm represents minute with leading 0 in case of values < 10 Ex: EEE, k:mm = Mon, 2:55 --> <string name="weekday_time_format_24_mode">EEE, k:mm a</string> </resources> src/com/android/alarmclock/DigitalAppWidgetProvider.java +8 −4 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import com.android.deskclock.alarms.AlarmStateManager; import com.android.deskclock.worldclock.Cities; import com.android.deskclock.worldclock.CitiesActivity; import java.text.SimpleDateFormat; import java.util.Locale; public class DigitalAppWidgetProvider extends AppWidgetProvider { Loading Loading @@ -94,7 +95,7 @@ public class DigitalAppWidgetProvider extends AppWidgetProvider { RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget); float ratio = WidgetUtils.getScaleRatio(context, null, appWidgetId); WidgetUtils.setTimeFormat(widget, 0/*no am/pm*/, R.id.the_clock); WidgetUtils.setTimeFormat(context, widget, 0/*no am/pm*/, R.id.the_clock); WidgetUtils.setClockSize(context, widget, ratio); refreshAlarm(context, widget); appWidgetManager.partiallyUpdateAppWidget(appWidgetId, widget); Loading Loading @@ -181,12 +182,15 @@ public class DigitalAppWidgetProvider extends AppWidgetProvider { // Setup alarm text clock's format and font sizes refreshAlarm(context, widget); WidgetUtils.setTimeFormat(widget, 0/*no am/pm*/, R.id.the_clock); WidgetUtils.setTimeFormat(context, widget, 0/*no am/pm*/, R.id.the_clock); WidgetUtils.setClockSize(context, widget, ratio); // Set today's date format CharSequence dateFormat = DateFormat.getBestDateTimePattern(Locale.getDefault(), context.getString(R.string.abbrev_wday_month_day_no_year)); final CharSequence dateFormat = Utils.isJBMR2OrLater() ? DateFormat.getBestDateTimePattern(Locale.getDefault(), context.getString(R.string.abbrev_wday_month_day_no_year)) : ((SimpleDateFormat) SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT)) .toPattern(); widget.setCharSequence(R.id.date, "setFormat12Hour", dateFormat); widget.setCharSequence(R.id.date, "setFormat24Hour", dateFormat); Loading src/com/android/alarmclock/DigitalWidgetViewsFactory.java +2 −2 Original line number Diff line number Diff line Loading @@ -103,8 +103,8 @@ public class DigitalWidgetViewsFactory implements RemoteViewsFactory { now.setTimeZone(TimeZone.getTimeZone(cityTZ)); int cityDayOfWeek = now.get(Calendar.DAY_OF_WEEK); WidgetUtils.setTimeFormat(clock, (int)mResources.getDimension(R.dimen.widget_label_font_size), clockId); final int labelSize = mResources.getDimensionPixelSize(R.dimen.widget_label_font_size); WidgetUtils.setTimeFormat(mContext, clock, labelSize, clockId); float fontSize = mFontScale * (DateFormat.is24HourFormat(mContext) ? mFont24Size : mFontSize); clock.setTextViewTextSize(clockId, TypedValue.COMPLEX_UNIT_PX, fontSize * mFontScale); Loading src/com/android/alarmclock/WidgetUtils.java +6 −6 Original line number Diff line number Diff line Loading @@ -21,11 +21,8 @@ import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; import android.util.Log; import android.util.TypedValue; import android.widget.RemoteViews; import android.widget.RemoteViews.RemoteView; import android.widget.TextClock; import com.android.deskclock.R; import com.android.deskclock.Utils; Loading Loading @@ -133,15 +130,18 @@ public class WidgetUtils { } /*** * Set the format of the time on the clock accrding to the locale * Set the format of the time on the clock according to the locale * @param context - Context used to get user's locale and time preferences * @param clock - view to format * @param amPmFontSize - size of am/pm label, zero size means no am/om label * @param clockId - id of TextClock view as defined in the clock's layout. */ public static void setTimeFormat(RemoteViews clock, int amPmFontSize, int clockId) { public static void setTimeFormat(Context context, RemoteViews clock, int amPmFontSize, int clockId) { if (clock != null) { // Set the best format for 12 hours mode according to the locale clock.setCharSequence(clockId, "setFormat12Hour", Utils.get12ModeFormat(amPmFontSize)); clock.setCharSequence(clockId, "setFormat12Hour", Utils.get12ModeFormat(context, amPmFontSize)); // Set the best format for 24 hours mode according to the locale clock.setCharSequence(clockId, "setFormat24Hour", Utils.get24ModeFormat()); } Loading src/com/android/deskclock/AlarmClockFragment.java +2 −2 Original line number Diff line number Diff line Loading @@ -702,8 +702,8 @@ public abstract class AlarmClockFragment extends DeskClockFragment implements setAlarmItemBackgroundAndElevation(itemHolder.alarmItem, false /* expanded */); setDigitalTimeAlpha(itemHolder, itemHolder.onoff.isChecked()); } itemHolder.clock.setFormat( (int)mContext.getResources().getDimension(R.dimen.alarm_label_size)); itemHolder.clock.setFormat(mContext, mContext.getResources().getDimensionPixelSize(R.dimen.alarm_label_size)); itemHolder.clock.setTime(alarm.hour, alarm.minutes); itemHolder.clock.setClickable(true); itemHolder.clock.setOnClickListener(new View.OnClickListener() { Loading Loading
res/values/strings.xml +36 −0 Original line number Diff line number Diff line Loading @@ -844,5 +844,41 @@ <!-- String for no enabled alarms in timeline view [CHAR LIMIT=30] --> <string name="no_upcoming_alarms">NO UPCOMING ALARMS</string> <!-- String that represents time format for 12-hour time. h represents hour in range (1-12) with the minimum number of digits mm represents minute with leading 0 in case of values < 10 a represents am/pm Ex: h:mm a = 12:54 am, 8:05 pm --> <string name="time_format_12_mode">h:mm a</string> <!-- String that represents time format for 24-hour time. k represents hour in range (0-23) with the minimum number of digits mm represents minute with leading 0 in case of values < 10 Ex: k:mm = 13:51, 5:05 --> <string name="time_format_24_mode">k:mm</string> <!-- String that represents weekday, time format for 12-hour time. EEE represents weekday name in short form (ex. Mon, Tue, Wed) h represents hour in range (1-12) with the minimum number of digits mm represents minute with leading 0 in case of values < 10 a represents am/pm Ex: EEE, h:mm a = Mon, 2:55 pm --> <string name="weekday_time_format_12_mode">EEE, h:mm a</string> <!-- String that represents weekday, time format for 24-hour time. EEE represents weekday name in short form (ex. Mon, Tue, Wed) k represents hour in range (0-23) with the minimum number of digits mm represents minute with leading 0 in case of values < 10 Ex: EEE, k:mm = Mon, 2:55 --> <string name="weekday_time_format_24_mode">EEE, k:mm a</string> </resources>
src/com/android/alarmclock/DigitalAppWidgetProvider.java +8 −4 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import com.android.deskclock.alarms.AlarmStateManager; import com.android.deskclock.worldclock.Cities; import com.android.deskclock.worldclock.CitiesActivity; import java.text.SimpleDateFormat; import java.util.Locale; public class DigitalAppWidgetProvider extends AppWidgetProvider { Loading Loading @@ -94,7 +95,7 @@ public class DigitalAppWidgetProvider extends AppWidgetProvider { RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget); float ratio = WidgetUtils.getScaleRatio(context, null, appWidgetId); WidgetUtils.setTimeFormat(widget, 0/*no am/pm*/, R.id.the_clock); WidgetUtils.setTimeFormat(context, widget, 0/*no am/pm*/, R.id.the_clock); WidgetUtils.setClockSize(context, widget, ratio); refreshAlarm(context, widget); appWidgetManager.partiallyUpdateAppWidget(appWidgetId, widget); Loading Loading @@ -181,12 +182,15 @@ public class DigitalAppWidgetProvider extends AppWidgetProvider { // Setup alarm text clock's format and font sizes refreshAlarm(context, widget); WidgetUtils.setTimeFormat(widget, 0/*no am/pm*/, R.id.the_clock); WidgetUtils.setTimeFormat(context, widget, 0/*no am/pm*/, R.id.the_clock); WidgetUtils.setClockSize(context, widget, ratio); // Set today's date format CharSequence dateFormat = DateFormat.getBestDateTimePattern(Locale.getDefault(), context.getString(R.string.abbrev_wday_month_day_no_year)); final CharSequence dateFormat = Utils.isJBMR2OrLater() ? DateFormat.getBestDateTimePattern(Locale.getDefault(), context.getString(R.string.abbrev_wday_month_day_no_year)) : ((SimpleDateFormat) SimpleDateFormat.getDateInstance(SimpleDateFormat.SHORT)) .toPattern(); widget.setCharSequence(R.id.date, "setFormat12Hour", dateFormat); widget.setCharSequence(R.id.date, "setFormat24Hour", dateFormat); Loading
src/com/android/alarmclock/DigitalWidgetViewsFactory.java +2 −2 Original line number Diff line number Diff line Loading @@ -103,8 +103,8 @@ public class DigitalWidgetViewsFactory implements RemoteViewsFactory { now.setTimeZone(TimeZone.getTimeZone(cityTZ)); int cityDayOfWeek = now.get(Calendar.DAY_OF_WEEK); WidgetUtils.setTimeFormat(clock, (int)mResources.getDimension(R.dimen.widget_label_font_size), clockId); final int labelSize = mResources.getDimensionPixelSize(R.dimen.widget_label_font_size); WidgetUtils.setTimeFormat(mContext, clock, labelSize, clockId); float fontSize = mFontScale * (DateFormat.is24HourFormat(mContext) ? mFont24Size : mFontSize); clock.setTextViewTextSize(clockId, TypedValue.COMPLEX_UNIT_PX, fontSize * mFontScale); Loading
src/com/android/alarmclock/WidgetUtils.java +6 −6 Original line number Diff line number Diff line Loading @@ -21,11 +21,8 @@ import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; import android.util.Log; import android.util.TypedValue; import android.widget.RemoteViews; import android.widget.RemoteViews.RemoteView; import android.widget.TextClock; import com.android.deskclock.R; import com.android.deskclock.Utils; Loading Loading @@ -133,15 +130,18 @@ public class WidgetUtils { } /*** * Set the format of the time on the clock accrding to the locale * Set the format of the time on the clock according to the locale * @param context - Context used to get user's locale and time preferences * @param clock - view to format * @param amPmFontSize - size of am/pm label, zero size means no am/om label * @param clockId - id of TextClock view as defined in the clock's layout. */ public static void setTimeFormat(RemoteViews clock, int amPmFontSize, int clockId) { public static void setTimeFormat(Context context, RemoteViews clock, int amPmFontSize, int clockId) { if (clock != null) { // Set the best format for 12 hours mode according to the locale clock.setCharSequence(clockId, "setFormat12Hour", Utils.get12ModeFormat(amPmFontSize)); clock.setCharSequence(clockId, "setFormat12Hour", Utils.get12ModeFormat(context, amPmFontSize)); // Set the best format for 24 hours mode according to the locale clock.setCharSequence(clockId, "setFormat24Hour", Utils.get24ModeFormat()); } Loading
src/com/android/deskclock/AlarmClockFragment.java +2 −2 Original line number Diff line number Diff line Loading @@ -702,8 +702,8 @@ public abstract class AlarmClockFragment extends DeskClockFragment implements setAlarmItemBackgroundAndElevation(itemHolder.alarmItem, false /* expanded */); setDigitalTimeAlpha(itemHolder, itemHolder.onoff.isChecked()); } itemHolder.clock.setFormat( (int)mContext.getResources().getDimension(R.dimen.alarm_label_size)); itemHolder.clock.setFormat(mContext, mContext.getResources().getDimensionPixelSize(R.dimen.alarm_label_size)); itemHolder.clock.setTime(alarm.hour, alarm.minutes); itemHolder.clock.setClickable(true); itemHolder.clock.setOnClickListener(new View.OnClickListener() { Loading