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

Commit 6e37e5a0 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Implement RTL support in framework ViewPager, DatePicker"

parents 38dee056 ddf655c4
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -195,10 +195,24 @@ class DayPickerView extends ViewGroup {
        mNextButton.measure(buttonWidthSpec, buttonHeightSpec);
    }

    @Override
    public void onRtlPropertiesChanged(@ResolvedLayoutDir int layoutDirection) {
        super.onRtlPropertiesChanged(layoutDirection);

        requestLayout();
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        final ImageButton leftButton = mPrevButton;
        final ImageButton rightButton = mNextButton;
        final ImageButton leftButton;
        final ImageButton rightButton;
        if (isLayoutRtl()) {
            leftButton = mNextButton;
            rightButton = mPrevButton;
        } else {
            leftButton = mPrevButton;
            rightButton = mNextButton;
        }

        final int width = right - left;
        final int height = bottom - top;
+47 −9
Original line number Diff line number Diff line
@@ -162,7 +162,6 @@ class SimpleMonthView extends View {
        mTitleFormatter = new SimpleDateFormat(titleFormat, locale);
        mDayOfWeekFormatter = new SimpleDateFormat(DAY_OF_WEEK_FORMAT, locale);

        setClickable(true);
        initPaints(res);
    }

@@ -318,7 +317,8 @@ class SimpleMonthView extends View {
        final int x = (int) (event.getX() + 0.5f);
        final int y = (int) (event.getY() + 0.5f);

        switch (event.getAction()) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_MOVE:
                final int touchedItem = getDayAtLocation(x, y);
@@ -326,6 +326,10 @@ class SimpleMonthView extends View {
                    mTouchedItem = touchedItem;
                    invalidate();
                }
                if (action == MotionEvent.ACTION_DOWN && touchedItem < 0) {
                    // Touch something that's not an item, reject event.
                    return false;
                }
                break;

            case MotionEvent.ACTION_UP:
@@ -376,9 +380,16 @@ class SimpleMonthView extends View {

        for (int col = 0; col < DAYS_IN_WEEK; col++) {
            final int colCenter = colWidth * col + colWidth / 2;
            final int colCenterRtl;
            if (isLayoutRtl()) {
                colCenterRtl = mPaddedWidth - colCenter;
            } else {
                colCenterRtl = colCenter;
            }

            final int dayOfWeek = (col + mWeekStart) % DAYS_IN_WEEK;
            final String label = getDayOfWeekLabel(dayOfWeek);
            canvas.drawText(label, colCenter, rowCenter - halfLineHeight, p);
            canvas.drawText(label, colCenterRtl, rowCenter - halfLineHeight, p);
        }
    }

@@ -402,6 +413,13 @@ class SimpleMonthView extends View {

        for (int day = 1, col = findDayOffset(); day <= mDaysInMonth; day++) {
            final int colCenter = colWidth * col + colWidth / 2;
            final int colCenterRtl;
            if (isLayoutRtl()) {
                colCenterRtl = mPaddedWidth - colCenter;
            } else {
                colCenterRtl = colCenter;
            }

            int stateMask = 0;

            if (day >= mEnabledDayStart && day <= mEnabledDayEnd) {
@@ -413,12 +431,12 @@ class SimpleMonthView extends View {
                stateMask |= StateSet.VIEW_STATE_ACTIVATED;

                // Adjust the circle to be centered on the row.
                canvas.drawCircle(colCenter, rowCenter, mDaySelectorRadius, mDaySelectorPaint);
                canvas.drawCircle(colCenterRtl, rowCenter, mDaySelectorRadius, mDaySelectorPaint);
            } else if (mTouchedItem == day) {
                stateMask |= StateSet.VIEW_STATE_PRESSED;

                // Adjust the circle to be centered on the row.
                canvas.drawCircle(colCenter, rowCenter, mDaySelectorRadius, mDayHighlightPaint);
                canvas.drawCircle(colCenterRtl, rowCenter, mDaySelectorRadius, mDayHighlightPaint);
            }

            final boolean isDayToday = mToday == day;
@@ -431,7 +449,7 @@ class SimpleMonthView extends View {
            }
            p.setColor(dayTextColor);

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

            col++;

@@ -582,6 +600,13 @@ class SimpleMonthView extends View {
        setMeasuredDimension(resolvedWidth, resolvedHeight);
    }

    @Override
    public void onRtlPropertiesChanged(@ResolvedLayoutDir int layoutDirection) {
        super.onRtlPropertiesChanged(layoutDirection);

        requestLayout();
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        if (!changed) {
@@ -657,8 +682,16 @@ class SimpleMonthView extends View {
            return -1;
        }

        // Adjust for RTL after applying padding.
        final int paddedXRtl;
        if (isLayoutRtl()) {
            paddedXRtl = mPaddedWidth - paddedX;
        } else {
            paddedXRtl = paddedX;
        }

        final int row = (paddedY - headerHeight) / mDayHeight;
        final int col = (paddedX * DAYS_IN_WEEK) / mPaddedWidth;
        final int col = (paddedXRtl * DAYS_IN_WEEK) / mPaddedWidth;
        final int index = col + row * DAYS_IN_WEEK;
        final int day = index + 1 - findDayOffset();
        if (day < 1 || day > mDaysInMonth) {
@@ -681,10 +714,15 @@ class SimpleMonthView extends View {

        final int index = id - 1 + findDayOffset();

        // Compute left edge.
        // Compute left edge, taking into account RTL.
        final int col = index % DAYS_IN_WEEK;
        final int colWidth = mCellWidth;
        final int left = getPaddingLeft() + col * colWidth;
        final int left;
        if (isLayoutRtl()) {
            left = getWidth() - getPaddingRight() - (col + 1) * colWidth;
        } else {
            left = getPaddingLeft() + col * colWidth;
        }

        // Compute top edge.
        final int row = index / DAYS_IN_WEEK;
+279 −296

File changed.

Preview size limit exceeded, changes collapsed.

+2 −1
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@
        android:height="24dp"
        android:viewportWidth="24"
        android:viewportHeight="24"
        android:tint="?attr/colorControlNormal">
        android:tint="?attr/colorControlNormal"
        android:autoMirrored="true">
    <path
        android:fillColor="#FF000000"
        android:pathData="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6,-6z"/>
+2 −1
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@
        android:height="24dp"
        android:viewportWidth="24"
        android:viewportHeight="24"
        android:tint="?attr/colorControlNormal">
        android:tint="?attr/colorControlNormal"
        android:autoMirrored="true">
    <path
        android:fillColor="#FF000000"
        android:pathData="M15.41 7.41L14 6l-6 6 6 6 1.41,-1.41L10.83 12z"/>
Loading