summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-04-30 11:11:53 -0700
committerElliott Hughes <enh@google.com>2013-04-30 11:11:53 -0700
commit659f145278ffd85f934a435dbec47ead685caf59 (patch)
treebc3aa376c858dd9d2516bd748272544f6c9c348d /core
parent0bb497b8d1bac2206df89a878ecb7e356d21fe99 (diff)
downloadframeworks_base-659f145278ffd85f934a435dbec47ead685caf59.zip
frameworks_base-659f145278ffd85f934a435dbec47ead685caf59.tar.gz
frameworks_base-659f145278ffd85f934a435dbec47ead685caf59.tar.bz2
Fix DatePicker's spinner order in various locales.
DatePicker always effectively uses yyyy MMM dd, so we need to ask icu4c what order those should appear in for the user's locale. The existing DateFormat code was an approximation that worked for en_US but not for all languages (fa being one example). Bug: 7207103 Change-Id: I7b12568dbc02522ebad6e1db5f8426109cd6f7ce
Diffstat (limited to 'core')
-rw-r--r--core/java/android/widget/DatePicker.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 07d3a7a..d4fd98f 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -45,6 +45,8 @@ import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
+import libcore.icu.ICU;
+
/**
* This class is a widget for selecting a date. The date can be selected by a
* year, month, and day spinners or a {@link CalendarView}. The set of spinners
@@ -508,24 +510,27 @@ public class DatePicker extends FrameLayout {
*/
private void reorderSpinners() {
mSpinners.removeAllViews();
- char[] order = DateFormat.getDateFormatOrder(getContext());
+ // We use numeric spinners for year and day, but textual months. Ask icu4c what
+ // order the user's locale uses for that combination. http://b/7207103.
+ String pattern = ICU.getBestDateTimePattern("yyyyMMMdd", Locale.getDefault().toString());
+ char[] order = ICU.getDateFormatOrder(pattern);
final int spinnerCount = order.length;
for (int i = 0; i < spinnerCount; i++) {
switch (order[i]) {
- case DateFormat.DATE:
+ case 'd':
mSpinners.addView(mDaySpinner);
setImeOptions(mDaySpinner, spinnerCount, i);
break;
- case DateFormat.MONTH:
+ case 'M':
mSpinners.addView(mMonthSpinner);
setImeOptions(mMonthSpinner, spinnerCount, i);
break;
- case DateFormat.YEAR:
+ case 'y':
mSpinners.addView(mYearSpinner);
setImeOptions(mYearSpinner, spinnerCount, i);
break;
default:
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException(Arrays.toString(order));
}
}
}