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

Commit 1ea4715c authored by Chet Haase's avatar Chet Haase
Browse files

Localize SimpleMonthView

The days of the month were not being localized, resulting in
English numbers for non-English languages. Now we format the numbers
with the current locale.

Issue #22540629  [MRA14D][Arab][Token] numbers displayed in english

Change-Id: I2b17d55ba2d0aa47b5a28c8846c6cf9723ababb1
parent e6b407b4
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import com.android.internal.R;
import com.android.internal.widget.ExploreByTouchHelper;

import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
@@ -73,6 +74,7 @@ class SimpleMonthView extends View {

    private final SimpleDateFormat mTitleFormatter;
    private final SimpleDateFormat mDayOfWeekFormatter;
    private final NumberFormat mDayFormatter;

    // Desired dimensions.
    private final int mDesiredMonthHeight;
@@ -162,6 +164,7 @@ class SimpleMonthView extends View {
        final String titleFormat = DateFormat.getBestDateTimePattern(locale, DEFAULT_TITLE_FORMAT);
        mTitleFormatter = new SimpleDateFormat(titleFormat, locale);
        mDayOfWeekFormatter = new SimpleDateFormat(DAY_OF_WEEK_FORMAT, locale);
        mDayFormatter = NumberFormat.getIntegerInstance(locale);

        initPaints(res);
    }
@@ -454,7 +457,7 @@ class SimpleMonthView extends View {
            }
            p.setColor(dayTextColor);

            canvas.drawText(Integer.toString(day), colCenterRtl, rowCenter - halfLineHeight, p);
            canvas.drawText(mDayFormatter.format(day), colCenterRtl, rowCenter - halfLineHeight, p);

            col++;

@@ -866,7 +869,7 @@ class SimpleMonthView extends View {
         */
        private CharSequence getDayText(int id) {
            if (isValidDayOfMonth(id)) {
                return Integer.toString(id);
                return mDayFormatter.format(id);
            }

            return null;