Use correct single-letter date format in SimpleMonthView
Also fixes layout on sw600dp-land (by removing the sw600dp layout!).
BUG: 17068298
Change-Id: I2545d0e1904a0028156b96b6ad17674c6107ce5d
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 @@
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 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 @@
// 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 @@
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 @@
}
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);
}
}
diff --git a/core/res/res/layout-sw600dp/date_picker_holo.xml b/core/res/res/layout-sw600dp/date_picker_holo.xml
deleted file mode 100644
index e5c886b..0000000
--- a/core/res/res/layout-sw600dp/date_picker_holo.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2011 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:gravity="center"
- android:orientation="vertical" >
-
- <include
- layout="@layout/date_picker_selected_date"
- android:layout_width="wrap_content"
- android:layout_height="@dimen/datepicker_selected_calendar_layout_height" />
-
- <include layout="@layout/date_picker_view_animator" />
-
-</LinearLayout>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index a29a34c..0cf41c5 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -374,7 +374,6 @@
<dimen name="datepicker_year_label_height">64dp</dimen>
<dimen name="datepicker_year_label_text_size">22dp</dimen>
<dimen name="datepicker_component_width">270dp</dimen>
- <dimen name="datepicker_selected_calendar_layout_height">155dp</dimen>
<dimen name="datepicker_selected_date_day_size">75dp</dimen>
<dimen name="datepicker_selected_date_month_size">30dp</dimen>
<dimen name="datepicker_selected_date_year_size">30dp</dimen>