diff options
author | Alan Viverette <alanv@google.com> | 2014-08-19 18:11:54 -0700 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2014-08-19 18:11:54 -0700 |
commit | fd2dd208d9b0957657589b26c14c48b8e2b7f387 (patch) | |
tree | 031a51972cd716a7367005557fff4d55e8d8aa00 /core/java/android/widget/SimpleMonthView.java | |
parent | 9e4329ea0b8b725ca5bcec74032b765d01deaa80 (diff) | |
download | frameworks_base-fd2dd208d9b0957657589b26c14c48b8e2b7f387.zip frameworks_base-fd2dd208d9b0957657589b26c14c48b8e2b7f387.tar.gz frameworks_base-fd2dd208d9b0957657589b26c14c48b8e2b7f387.tar.bz2 |
Use correct single-letter date format in SimpleMonthView
Also fixes layout on sw600dp-land (by removing the sw600dp layout!).
BUG: 17068298
Change-Id: I2545d0e1904a0028156b96b6ad17674c6107ce5d
Diffstat (limited to 'core/java/android/widget/SimpleMonthView.java')
-rw-r--r-- | core/java/android/widget/SimpleMonthView.java | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/core/java/android/widget/SimpleMonthView.java b/core/java/android/widget/SimpleMonthView.java index a0d9475..27763eb 100644 --- a/core/java/android/widget/SimpleMonthView.java +++ b/core/java/android/widget/SimpleMonthView.java @@ -18,6 +18,7 @@ package android.widget; import android.content.Context; import android.content.res.ColorStateList; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Paint; @@ -38,6 +39,7 @@ import android.view.accessibility.AccessibilityNodeInfo; import com.android.internal.R; import com.android.internal.widget.ExploreByTouchHelper; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Formatter; import java.util.List; @@ -72,6 +74,9 @@ class SimpleMonthView extends View { // used for scaling to the device density private static float mScale = 0; + /** Single-letter (when available) formatter for the day of week label. */ + private SimpleDateFormat mDayFormatter = new SimpleDateFormat("EEEEE", Locale.getDefault()); + // affects the padding on the sides of this view private int mPadding = 0; @@ -181,6 +186,13 @@ class SimpleMonthView extends View { initView(); } + @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + mDayFormatter = new SimpleDateFormat("EEEEE", newConfig.locale); + } + void setTextColor(ColorStateList colors) { final Resources res = getContext().getResources(); @@ -426,16 +438,16 @@ class SimpleMonthView extends View { } private void drawWeekDayLabels(Canvas canvas) { - int y = mMonthHeaderSize - (mMonthDayLabelTextSize / 2); - int dayWidthHalf = (mWidth - mPadding * 2) / (mNumDays * 2); + final int y = mMonthHeaderSize - (mMonthDayLabelTextSize / 2); + final int dayWidthHalf = (mWidth - mPadding * 2) / (mNumDays * 2); for (int i = 0; i < mNumDays; i++) { - int calendarDay = (i + mWeekStart) % mNumDays; - int x = (2 * i + 1) * dayWidthHalf + mPadding; + final int calendarDay = (i + mWeekStart) % mNumDays; mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay); - canvas.drawText("" + mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK, - Calendar.SHORT, Locale.getDefault()).toUpperCase(Locale.getDefault()).charAt(0), - x, y, mMonthDayLabelPaint); + + final String dayLabel = mDayFormatter.format(mDayLabelCalendar.getTime()); + final int x = (2 * i + 1) * dayWidthHalf + mPadding; + canvas.drawText(dayLabel, x, y, mMonthDayLabelPaint); } } |