Skip to content

Instantly share code, notes, and snippets.

@Kwpolska
Created October 12, 2014 17:07
Show Gist options
  • Save Kwpolska/163fe6ad0db62a1c1d0e to your computer and use it in GitHub Desktop.
Save Kwpolska/163fe6ad0db62a1c1d0e to your computer and use it in GitHub Desktop.
A patch for Android’s DeskClock, adding seconds to the display. Partially broken and not really finalized, but AOSP apps are a pain to build.
diff --git a/res/layout/main_clock_frame.xml b/res/layout/main_clock_frame.xml
index ba51c2d..fdc9f05 100644
--- a/res/layout/main_clock_frame.xml
+++ b/res/layout/main_clock_frame.xml
@@ -41,7 +41,7 @@
<TextClock
android:id="@+id/digital_clock"
android:format12Hour="@string/main_clock_12_hours_format"
- android:format24Hour="@string/clock_24_hours_format"
+ android:format24Hour="@string/clock_24_hours_format_sec"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -49,8 +49,8 @@
android:layout_marginBottom="@dimen/bottom_text_spacing_digital"
android:singleLine="true"
android:ellipsize="none"
- style="@style/big_thin"
- android:textSize="@dimen/digital_main_clock_text_size"
+ style="@style/big_thin_plus"
+ android:textSize="@dimen/digital_main_clock_text_size_plus"
android:textColor="@color/clock_white" />
</FrameLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 0c30820..f745022 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -47,6 +47,7 @@
<dimen name="digital_world_clock_text_size">60dp</dimen>
<dimen name="digital_world_clock_ampm_text_size">14dp</dimen>
<dimen name="digital_main_clock_text_size">120dp</dimen>
+ <dimen name="digital_main_clock_text_size_plus">85dp</dimen>
<dimen name="digital_screensaver_clock_text_size">100dp</dimen>
<!-- Analog clock size in the the screen saver -->
@@ -79,6 +80,7 @@
<dimen name="circletimer_marker_size">16dip</dimen>
<dimen name="big_font_size">120dp</dimen>
+ <dimen name="big_font_size_plus">85dp</dimen>
<dimen name="small_font_size">48sp</dimen>
<dimen name="medium_font_size">60dp</dimen>
<dimen name="label_font_size">14sp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 134f700..87acc36 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -805,6 +805,7 @@
<!-- format strings for clocks -->
<string name="clock_24_hours_format" translatable="false">kk&#58;mm</string>
+ <string name="clock_24_hours_format_sec" translatable="false">kk&#58;mm&#58;ss</string>
<string name="main_widget_12_hours_format" translatable="false">h&#58;mm</string>
<!-- Font size for AM/PM should match widget_label_font_size -->
<string name="wc_widget_12_hours_format" translatable="false">h&#58;mm&#8202;<b><font size="14" face="sans-serif-condensed">a</font></b></string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 9a2c149..2e5e184 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -208,6 +208,11 @@
<item name="android:fontFamily">sans-serif-thin</item>
</style>
+ <style name="big_thin_plus">
+ <item name="android:textSize">@dimen/big_font_size_plus</item>
+ <item name="android:fontFamily">sans-serif-thin</item>
+ </style>
+
<style name="widget_big_thin" parent="big_thin">
<item name="android:textSize">@dimen/widget_big_font_size</item>
</style>
diff --git a/src/com/android/deskclock/ClockFragment.java b/src/com/android/deskclock/ClockFragment.java
index 222ec4b..c35c9ab 100644
--- a/src/com/android/deskclock/ClockFragment.java
+++ b/src/com/android/deskclock/ClockFragment.java
@@ -78,7 +78,7 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
// reload the cities list with new localized names
if (action.equals(Intent.ACTION_LOCALE_CHANGED)) {
if (mDigitalClock != null) {
- Utils.setTimeFormat(
+ Utils.setTimeFormatPLUS(
(TextClock)(mDigitalClock.findViewById(R.id.digital_clock)),
(int)context.getResources().
getDimension(R.dimen.bottom_text_size));
@@ -190,7 +190,7 @@ public class ClockFragment extends DeskClockFragment implements OnSharedPreferen
mDigitalClock = mClockFrame.findViewById(R.id.digital_clock);
mAnalogClock = mClockFrame.findViewById(R.id.analog_clock);
- Utils.setTimeFormat((TextClock)(mDigitalClock.findViewById(R.id.digital_clock)),
+ Utils.setTimeFormatPLUS((TextClock)(mDigitalClock.findViewById(R.id.digital_clock)),
(int)getResources().getDimension(R.dimen.bottom_text_size));
View footerView = inflater.inflate(R.layout.blank_footer_view, mList, false);
footerView.setBackgroundResource(R.color.blackish);
diff --git a/src/com/android/deskclock/Utils.java b/src/com/android/deskclock/Utils.java
index 21257f9..0de8c8d 100644
--- a/src/com/android/deskclock/Utils.java
+++ b/src/com/android/deskclock/Utils.java
@@ -506,6 +506,13 @@ public class Utils {
clock.setFormat24Hour(get24ModeFormat());
}
}
+
+ public static void setTimeFormatPLUS(TextClock clock, int amPmFontSize) {
+ if (clock != null) {
+ clock.setFormat24Hour(get24ModeFormatPLUS());
+ }
+ }
+
/***
* @param amPmFontSize - size of am/pm label (label removed is size is 0).
* @return format string for 12 hours mode time
@@ -539,6 +546,11 @@ public class Utils {
return DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
}
+ public static CharSequence get24ModeFormatPLUS() {
+ String skeleton = "Hms";
+ return DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
+ }
+
public static CityObj[] loadCitiesFromXml(Context c) {
final Collator collator = Collator.getInstance();
Resources r = c.getResources();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment