Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd2dd208 authored by Alan Viverette's avatar Alan Viverette
Browse files

Use correct single-letter date format in SimpleMonthView

Also fixes layout on sw600dp-land (by removing the sw600dp layout!).

BUG: 17068298
Change-Id: I2545d0e1904a0028156b96b6ad17674c6107ce5d
parent 9e4329ea
Loading
Loading
Loading
Loading
+19 −7
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package android.widget;


import android.content.Context;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint;
@@ -38,6 +39,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import com.android.internal.R;
import com.android.internal.R;
import com.android.internal.widget.ExploreByTouchHelper;
import com.android.internal.widget.ExploreByTouchHelper;


import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Calendar;
import java.util.Formatter;
import java.util.Formatter;
import java.util.List;
import java.util.List;
@@ -72,6 +74,9 @@ class SimpleMonthView extends View {
    // used for scaling to the device density
    // used for scaling to the device density
    private static float mScale = 0;
    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
    // affects the padding on the sides of this view
    private int mPadding = 0;
    private int mPadding = 0;


@@ -181,6 +186,13 @@ class SimpleMonthView extends View {
        initView();
        initView();
    }
    }


    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        mDayFormatter = new SimpleDateFormat("EEEEE", newConfig.locale);
    }

    void setTextColor(ColorStateList colors) {
    void setTextColor(ColorStateList colors) {
        final Resources res = getContext().getResources();
        final Resources res = getContext().getResources();


@@ -426,16 +438,16 @@ class SimpleMonthView extends View {
    }
    }


    private void drawWeekDayLabels(Canvas canvas) {
    private void drawWeekDayLabels(Canvas canvas) {
        int y = mMonthHeaderSize - (mMonthDayLabelTextSize / 2);
        final int y = mMonthHeaderSize - (mMonthDayLabelTextSize / 2);
        int dayWidthHalf = (mWidth - mPadding * 2) / (mNumDays * 2);
        final int dayWidthHalf = (mWidth - mPadding * 2) / (mNumDays * 2);


        for (int i = 0; i < mNumDays; i++) {
        for (int i = 0; i < mNumDays; i++) {
            int calendarDay = (i + mWeekStart) % mNumDays;
            final int calendarDay = (i + mWeekStart) % mNumDays;
            int x = (2 * i + 1) * dayWidthHalf + mPadding;
            mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay);
            mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay);
            canvas.drawText("" + mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK,

                    Calendar.SHORT, Locale.getDefault()).toUpperCase(Locale.getDefault()).charAt(0),
            final String dayLabel = mDayFormatter.format(mDayLabelCalendar.getTime());
                    x, y, mMonthDayLabelPaint);
            final int x = (2 * i + 1) * dayWidthHalf + mPadding;
            canvas.drawText(dayLabel, x, y, mMonthDayLabelPaint);
        }
        }
    }
    }


+0 −30
Original line number Original line Diff line number Diff line
<?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>
+0 −1
Original line number Original line Diff line number Diff line
@@ -374,7 +374,6 @@
    <dimen name="datepicker_year_label_height">64dp</dimen>
    <dimen name="datepicker_year_label_height">64dp</dimen>
    <dimen name="datepicker_year_label_text_size">22dp</dimen>
    <dimen name="datepicker_year_label_text_size">22dp</dimen>
    <dimen name="datepicker_component_width">270dp</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_day_size">75dp</dimen>
    <dimen name="datepicker_selected_date_month_size">30dp</dimen>
    <dimen name="datepicker_selected_date_month_size">30dp</dimen>
    <dimen name="datepicker_selected_date_year_size">30dp</dimen>
    <dimen name="datepicker_selected_date_year_size">30dp</dimen>