Merge "Use correct single-letter date format in SimpleMonthView" into lmp-dev

This commit is contained in:
Alan Viverette
2014-08-20 19:59:54 +00:00
committed by Android (Google) Code Review
3 changed files with 19 additions and 38 deletions

View File

@@ -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);
}
}

View File

@@ -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>

View File

@@ -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>