diff options
| author | Elliott Hughes <enh@google.com> | 2013-05-01 14:53:28 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2013-05-01 14:53:28 -0700 |
| commit | c255800fb0f46ea5f68d2c145605ac7dcd3a89b6 (patch) | |
| tree | e60e969e8df23a4f31d04fa7140dc81736d9375a /core | |
| parent | f7ae746a157b65dbc3003f0b18679f1acd9e740f (diff) | |
| parent | 6d82f86fa01800ee0523743366e0dc1113178fd9 (diff) | |
| download | frameworks_base-c255800fb0f46ea5f68d2c145605ac7dcd3a89b6.zip frameworks_base-c255800fb0f46ea5f68d2c145605ac7dcd3a89b6.tar.gz frameworks_base-c255800fb0f46ea5f68d2c145605ac7dcd3a89b6.tar.bz2 | |
am 6d82f86f: Merge "Show CJK dates as all-numeric in the DatePicker."
* commit '6d82f86fa01800ee0523743366e0dc1113178fd9':
Show CJK dates as all-numeric in the DatePicker.
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/widget/DatePicker.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java index 76b4830..d03161e 100644 --- a/core/java/android/widget/DatePicker.java +++ b/core/java/android/widget/DatePicker.java @@ -39,6 +39,7 @@ import android.widget.NumberPicker.OnValueChangeListener; import com.android.internal.R; +import java.text.DateFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; @@ -480,14 +481,27 @@ public class DatePicker extends FrameLayout { mCurrentDate = getCalendarForLocale(mCurrentDate, locale); mNumberOfMonths = mTempDate.getActualMaximum(Calendar.MONTH) + 1; - mShortMonths = new String[mNumberOfMonths]; - for (int i = 0; i < mNumberOfMonths; i++) { - mShortMonths[i] = DateUtils.getMonthString(Calendar.JANUARY + i, - DateUtils.LENGTH_MEDIUM); + mShortMonths = new DateFormatSymbols().getShortMonths(); + + if (usingNumericMonths()) { + // We're in a locale where a date should either be all-numeric, or all-text. + // All-text would require custom NumberPicker formatters for day and year. + mShortMonths = new String[mNumberOfMonths]; + for (int i = 0; i < mNumberOfMonths; ++i) { + mShortMonths[i] = String.format("%d", i + 1); + } } } /** + * Tests whether the current locale is one where there are no real month names, + * such as Chinese, Japanese, or Korean locales. + */ + private boolean usingNumericMonths() { + return Character.isDigit(mShortMonths[Calendar.JANUARY].charAt(0)); + } + + /** * Gets a calendar for locale bootstrapped with the value of a given calendar. * * @param oldCalendar The old calendar. @@ -667,7 +681,7 @@ public class DatePicker extends FrameLayout { mMonthSpinner.setValue(mCurrentDate.get(Calendar.MONTH)); mDaySpinner.setValue(mCurrentDate.get(Calendar.DAY_OF_MONTH)); - if (Character.isDigit(displayedValues[0].charAt(0))) { + if (usingNumericMonths()) { mMonthSpinnerInput.setRawInputType(InputType.TYPE_CLASS_NUMBER); } } |
