summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DateTimeSettings.java
diff options
context:
space:
mode:
authorEric Fischer <enf@google.com>2009-06-11 18:16:15 -0700
committerEric Fischer <enf@google.com>2009-06-12 13:23:07 -0700
commit188ca778702938d87313592175a3c2ff86bd3218 (patch)
tree471fde6820641f8c5c4c6384ddff3fa9b90e2bcf /src/com/android/settings/DateTimeSettings.java
parent1617706d2529b2182d1a7fe2348495fb8f40bb81 (diff)
downloadpackages_apps_Settings-188ca778702938d87313592175a3c2ff86bd3218.tar.gz
packages_apps_Settings-188ca778702938d87313592175a3c2ff86bd3218.tar.bz2
packages_apps_Settings-188ca778702938d87313592175a3c2ff86bd3218.zip
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.
Diffstat (limited to 'src/com/android/settings/DateTimeSettings.java')
-rw-r--r--src/com/android/settings/DateTimeSettings.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java
index d6e85c4e5..5b38651ce 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);
}