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

Commit ced7b8dc authored by Ng Zhi An's avatar Ng Zhi An
Browse files

Make print options layout respect RTL

Bug: 69693271
Test: manual, in a RTL system language, build, sync, open a PDF, print
Change-Id: I90e0dabfee1256663a4bececb0538f91389cfaac
parent dd312aba
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

import com.android.printspooler.R;

/**
@@ -126,6 +127,7 @@ public final class PrintOptionsLayout extends ViewGroup {
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        final int childCount = getChildCount();
        final int rowCount = childCount / mColumnCount + childCount % mColumnCount;
        final boolean isLayoutRtl = isLayoutRtl();

        int cellStart = getPaddingStart();
        int cellTop = getPaddingTop();
@@ -134,7 +136,13 @@ public final class PrintOptionsLayout extends ViewGroup {
            int rowHeight = 0;

            for (int col = 0; col < mColumnCount; col++) {
                final int childIndex = row * mColumnCount + col;
                final int childIndex;
                if (isLayoutRtl) {
                    // if RTL, layout the right most child first
                    childIndex = row * mColumnCount + (mColumnCount - col - 1);
                } else {
                    childIndex = row * mColumnCount + col;
                }

                if (childIndex >= childCount) {
                    break;
@@ -148,14 +156,14 @@ public final class PrintOptionsLayout extends ViewGroup {

                MarginLayoutParams childParams = (MarginLayoutParams) child.getLayoutParams();

                final int childLeft = cellStart + childParams.getMarginStart();
                final int childStart = cellStart + childParams.getMarginStart();
                final int childTop = cellTop + childParams.topMargin;
                final int childRight = childLeft + child.getMeasuredWidth();
                final int childEnd = childStart + child.getMeasuredWidth();
                final int childBottom = childTop + child.getMeasuredHeight();

                child.layout(childLeft, childTop, childRight, childBottom);
                child.layout(childStart, childTop, childEnd, childBottom);

                cellStart = childRight + childParams.getMarginEnd();
                cellStart = childEnd + childParams.getMarginEnd();

                rowHeight = Math.max(rowHeight, child.getMeasuredHeight()
                        + childParams.topMargin + childParams.bottomMargin);