Loading src/com/android/deskclock/Screensaver.java +1 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public final class Screensaver extends DreamService { setClockStyle(); Utils.setClockIconTypeface(mContentView); Utils.setTimeFormat(mDigitalClock, false); Utils.setScreensaverTimeFormat(mDigitalClock, false); mAnalogClock.enableSeconds(false); mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE Loading src/com/android/deskclock/ScreensaverActivity.java +2 −2 Original line number Diff line number Diff line Loading @@ -104,8 +104,8 @@ public class ScreensaverActivity extends BaseActivity { final AnalogClock analogClock = mMainClockView.findViewById(R.id.analog_clock); Utils.setClockIconTypeface(mMainClockView); Utils.setTimeFormat((TextClock) digitalClock, false); Utils.setClockStyle(digitalClock, analogClock); Utils.setScreensaverTimeFormat((TextClock) digitalClock, false); Utils.setScreensaverClockStyle(digitalClock, analogClock); Utils.dimClockView(true, mMainClockView); analogClock.enableSeconds(false); Loading src/com/android/deskclock/Utils.java +31 −3 Original line number Diff line number Diff line Loading @@ -326,7 +326,23 @@ public class Utils { public static void setTimeFormat(TextClock clock, boolean includeSeconds) { if (clock != null) { // Get the best format for 12 hours mode according to the locale clock.setFormat12Hour(get12ModeFormat(0.4f /* amPmRatio */, includeSeconds)); clock.setFormat12Hour(get12ModeFormat(0.4f /* amPmRatio */, includeSeconds, true)); // Get the best format for 24 hours mode according to the locale clock.setFormat24Hour(get24ModeFormat(includeSeconds)); } } /*** * Formats the time in the TextClock for the screensaver according to the Locale with a special * formatting treatment for the am/pm label. * * @param clock TextClock to format * @param includeSeconds whether or not to include seconds in the clock's time */ public static void setScreensaverTimeFormat(TextClock clock, boolean includeSeconds) { if (clock != null) { // Get the best format for 12 hours mode according to the locale clock.setFormat12Hour(get12ModeFormat(0.4f /* amPmRatio */, includeSeconds, false)); // Get the best format for 24 hours mode according to the locale clock.setFormat24Hour(get24ModeFormat(includeSeconds)); } Loading @@ -339,6 +355,18 @@ public class Utils { * @return format string for 12 hours mode time, not including seconds */ public static CharSequence get12ModeFormat(float amPmRatio, boolean includeSeconds) { return get12ModeFormat(amPmRatio, includeSeconds, true); } /** * @param amPmRatio a value between 0 and 1 that is the ratio of the relative size of the * am/pm string to the time string * @param includeSeconds whether or not to include seconds in the time string * @param amPmBolded whether or not to bold the AM/PM * @return format string for 12 hours mode time, not including seconds */ public static CharSequence get12ModeFormat(float amPmRatio, boolean includeSeconds, boolean amPmBolded) { String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), includeSeconds ? "hmsa" : "hma"); if (amPmRatio <= 0) { Loading @@ -356,8 +384,8 @@ public class Utils { final Spannable sp = new SpannableString(pattern); sp.setSpan(new RelativeSizeSpan(amPmRatio), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sp.setSpan(new StyleSpan(Typeface.BOLD), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sp.setSpan(new StyleSpan(amPmBolded ? Typeface.BOLD : Typeface.NORMAL), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sp.setSpan(new TypefaceSpan("sans-serif"), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Loading Loading
src/com/android/deskclock/Screensaver.java +1 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public final class Screensaver extends DreamService { setClockStyle(); Utils.setClockIconTypeface(mContentView); Utils.setTimeFormat(mDigitalClock, false); Utils.setScreensaverTimeFormat(mDigitalClock, false); mAnalogClock.enableSeconds(false); mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE Loading
src/com/android/deskclock/ScreensaverActivity.java +2 −2 Original line number Diff line number Diff line Loading @@ -104,8 +104,8 @@ public class ScreensaverActivity extends BaseActivity { final AnalogClock analogClock = mMainClockView.findViewById(R.id.analog_clock); Utils.setClockIconTypeface(mMainClockView); Utils.setTimeFormat((TextClock) digitalClock, false); Utils.setClockStyle(digitalClock, analogClock); Utils.setScreensaverTimeFormat((TextClock) digitalClock, false); Utils.setScreensaverClockStyle(digitalClock, analogClock); Utils.dimClockView(true, mMainClockView); analogClock.enableSeconds(false); Loading
src/com/android/deskclock/Utils.java +31 −3 Original line number Diff line number Diff line Loading @@ -326,7 +326,23 @@ public class Utils { public static void setTimeFormat(TextClock clock, boolean includeSeconds) { if (clock != null) { // Get the best format for 12 hours mode according to the locale clock.setFormat12Hour(get12ModeFormat(0.4f /* amPmRatio */, includeSeconds)); clock.setFormat12Hour(get12ModeFormat(0.4f /* amPmRatio */, includeSeconds, true)); // Get the best format for 24 hours mode according to the locale clock.setFormat24Hour(get24ModeFormat(includeSeconds)); } } /*** * Formats the time in the TextClock for the screensaver according to the Locale with a special * formatting treatment for the am/pm label. * * @param clock TextClock to format * @param includeSeconds whether or not to include seconds in the clock's time */ public static void setScreensaverTimeFormat(TextClock clock, boolean includeSeconds) { if (clock != null) { // Get the best format for 12 hours mode according to the locale clock.setFormat12Hour(get12ModeFormat(0.4f /* amPmRatio */, includeSeconds, false)); // Get the best format for 24 hours mode according to the locale clock.setFormat24Hour(get24ModeFormat(includeSeconds)); } Loading @@ -339,6 +355,18 @@ public class Utils { * @return format string for 12 hours mode time, not including seconds */ public static CharSequence get12ModeFormat(float amPmRatio, boolean includeSeconds) { return get12ModeFormat(amPmRatio, includeSeconds, true); } /** * @param amPmRatio a value between 0 and 1 that is the ratio of the relative size of the * am/pm string to the time string * @param includeSeconds whether or not to include seconds in the time string * @param amPmBolded whether or not to bold the AM/PM * @return format string for 12 hours mode time, not including seconds */ public static CharSequence get12ModeFormat(float amPmRatio, boolean includeSeconds, boolean amPmBolded) { String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), includeSeconds ? "hmsa" : "hma"); if (amPmRatio <= 0) { Loading @@ -356,8 +384,8 @@ public class Utils { final Spannable sp = new SpannableString(pattern); sp.setSpan(new RelativeSizeSpan(amPmRatio), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sp.setSpan(new StyleSpan(Typeface.BOLD), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sp.setSpan(new StyleSpan(amPmBolded ? Typeface.BOLD : Typeface.NORMAL), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); sp.setSpan(new TypefaceSpan("sans-serif"), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Loading