diff options
author | Eric Fischer <enf@google.com> | 2009-06-11 18:16:15 -0700 |
---|---|---|
committer | Eric Fischer <enf@google.com> | 2009-06-12 13:23:07 -0700 |
commit | 188ca778702938d87313592175a3c2ff86bd3218 (patch) | |
tree | 471fde6820641f8c5c4c6384ddff3fa9b90e2bcf | |
parent | 1617706d2529b2182d1a7fe2348495fb8f40bb81 (diff) | |
download | packages_apps_settings-188ca778702938d87313592175a3c2ff86bd3218.zip packages_apps_settings-188ca778702938d87313592175a3c2ff86bd3218.tar.gz packages_apps_settings-188ca778702938d87313592175a3c2ff86bd3218.tar.bz2 |
Make the Settings side of the date format settings more locale-aware.
Remove the two formats that have a spelled-out month, since applications
using this setting are trying to format numeric dates.
Do not forcibly set the setting the first time you go into Date & Time --
let the setting remain null if it was null before.
Add a choice corresponding to null to the list of format options. It will
look like "Normal (12-31-2009)" in the list, and will cause the system
to use whatever numeric format the locale calls for.
For the other choices, feed them to the locale-aware formatter so they
will appear with the punctuation that the locale calls for.
-rw-r--r-- | res/values/arrays.xml | 14 | ||||
-rw-r--r-- | res/values/strings.xml | 4 | ||||
-rw-r--r-- | src/com/android/settings/DateTimeSettings.java | 20 |
3 files changed, 23 insertions, 15 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 4a60c36..06bf787 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -39,18 +39,12 @@ <item>All</item> </string-array> - <!-- There is a setting to control the format of dates displayed throughout the system. This is in the Date & Time Settings screen. Unfortunately, these cannot be changed at all. --> <skip /> - <!-- Do not translate. This is fed directly to the formatter. --> - <string-array name="date_format_values"> - <!-- Do not translate. This is fed directly to the formatter. --> + <!-- There is a setting to control the format of dates displayed throughout the system. This is in the Date & Time Settings screen. These will be adjusted to use punctuation appropriate to the user's locale. --> + <string-array name="date_format_values" translatable="false"> + <!-- The blank item means to use whatever the locale calls for. --> + <item></item> <item>MM-dd-yyyy</item> - <!-- Do not translate. This is fed directly to the formatter. --> <item>dd-MM-yyyy</item> - <!-- Do not translate. This is fed directly to the formatter. --> - <item>MMM d, yyyy</item> - <!-- Do not translate. This is fed directly to the formatter. --> - <item>d-MMM-yyyy</item> - <!-- Do not translate. This is fed directly to the formatter. --> <item>yyyy-MM-dd</item> </string-array> diff --git a/res/values/strings.xml b/res/values/strings.xml index 3b91ef6..d2ca51b 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -243,6 +243,10 @@ <!-- Do not translate. Used as the value for a setting. --> <string name="default_date_format"><xliff:g id="default_date_format">MM/dd/yyyy</xliff:g></string> + <!-- The option in the date-format picker for using the normal format + called for by the user's locale. --> + <string name="normal_date_format">Normal (<xliff:g id="date" example="12-31-2009">%s</xliff:g>)</string> + <!-- Label of preview text when tweaking font size --> <string name="display_preview_label">Preview:</string> <!-- Label for chosen font size --> diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java index d6e85c4..5b38651 100644 --- a/src/com/android/settings/DateTimeSettings.java +++ b/src/com/android/settings/DateTimeSettings.java @@ -87,19 +87,25 @@ public class DateTimeSettings mDatePref = findPreference("date"); mDateFormat = (ListPreference) findPreference(KEY_DATE_FORMAT); - int currentFormatIndex = -1; String [] dateFormats = getResources().getStringArray(R.array.date_format_values); String [] formattedDates = new String[dateFormats.length]; String currentFormat = getDateFormat(); // Initialize if DATE_FORMAT is not set in the system settings // This can happen after a factory reset (or data wipe) if (currentFormat == null) { - currentFormat = getResources().getString(R.string.default_date_format); - setDateFormat(currentFormat); + currentFormat = ""; } for (int i = 0; i < formattedDates.length; i++) { - formattedDates[i] = DateFormat.format(dateFormats[i], mDummyDate).toString(); - if (currentFormat.equals(dateFormats[i])) currentFormatIndex = i; + String formatted = + DateFormat.getDateFormatForSetting(this, dateFormats[i]). + format(mDummyDate.getTime()); + + if (dateFormats[i].length() == 0) { + formattedDates[i] = getResources(). + getString(R.string.normal_date_format, formatted); + } else { + formattedDates[i] = formatted; + } } mDateFormat.setEntries(formattedDates); @@ -314,6 +320,10 @@ public class DateTimeSettings } private void setDateFormat(String format) { + if (format.length() == 0) { + format = null; + } + Settings.System.putString(getContentResolver(), Settings.System.DATE_FORMAT, format); } |