diff options
author | Ng Zhi An <zhin@google.com> | 2017-12-28 13:55:56 -0800 |
---|---|---|
committer | Ng Zhi An <zhin@google.com> | 2017-12-28 13:58:05 -0800 |
commit | ced7b8dca383b44b2ccef67cba925191a354d500 (patch) | |
tree | 36a59553e77dce663346a2c2de763fb6ac83f9e3 /packages/PrintSpooler/src | |
parent | dd312ababe4db018307948f956fa482c81825ff9 (diff) |
Make print options layout respect RTL
Bug: 69693271
Test: manual, in a RTL system language, build, sync, open a PDF, print
Change-Id: I90e0dabfee1256663a4bececb0538f91389cfaac
Diffstat (limited to 'packages/PrintSpooler/src')
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java index 7a80a8bd426e..24cf218fd0d8 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java +++ b/packages/PrintSpooler/src/com/android/printspooler/widget/PrintOptionsLayout.java @@ -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); |