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

Commit 8d54389b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make print options layout respect RTL"

parents 3157acc3 ced7b8dc
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);