diff options
author | Adrian Roos <roosa@google.com> | 2014-08-08 15:59:03 +0200 |
---|---|---|
committer | Adrian Roos <roosa@google.com> | 2014-08-08 15:59:03 +0200 |
commit | 0832b482214fc21d5458a792978ef117318e7b3f (patch) | |
tree | 0c4bcf0f0b9ecdab956cba3ca31d6a509cf5c17d | |
parent | 1940892d891c1d2538f51608b6618af646ab7481 (diff) | |
download | frameworks_base-0832b482214fc21d5458a792978ef117318e7b3f.zip frameworks_base-0832b482214fc21d5458a792978ef117318e7b3f.tar.gz frameworks_base-0832b482214fc21d5458a792978ef117318e7b3f.tar.bz2 |
QS: Make user switcher RTL aware
Bug: 16406694
Change-Id: I00efaf34281945635aa91bc3871ca6361c946ffe
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/PseudoGridView.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/PseudoGridView.java b/packages/SystemUI/src/com/android/systemui/qs/PseudoGridView.java index d58663d..cb6708e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/PseudoGridView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/PseudoGridView.java @@ -65,15 +65,14 @@ public class PseudoGridView extends ViewGroup { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int widthMode = MeasureSpec.getMode(widthMeasureSpec); - if (widthMode == MeasureSpec.UNSPECIFIED) { + if (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED) { throw new UnsupportedOperationException("Needs a maximum width"); } int width = MeasureSpec.getSize(widthMeasureSpec); int childWidth = (width - (mNumColumns - 1) * mHorizontalSpacing) / mNumColumns; int childWidthSpec = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY); - int childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + int childHeightSpec = MeasureSpec.UNSPECIFIED; int totalHeight = 0; int children = getChildCount(); int rows = (children + mNumColumns - 1) / mNumColumns; @@ -89,7 +88,9 @@ public class PseudoGridView extends ViewGroup { int maxHeightSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY); for (int i = startOfRow; i < endOfRow; i++) { View child = getChildAt(i); - child.measure(childWidthSpec, maxHeightSpec); + if (child.getMeasuredHeight() != maxHeight) { + child.measure(childWidthSpec, maxHeightSpec); + } } totalHeight += maxHeight; if (row > 0) { @@ -102,11 +103,12 @@ public class PseudoGridView extends ViewGroup { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { + boolean isRtl = isLayoutRtl(); int children = getChildCount(); int rows = (children + mNumColumns - 1) / mNumColumns; int y = 0; for (int row = 0; row < rows; row++) { - int x = 0; + int x = isRtl ? getWidth() : 0; int maxHeight = 0; int startOfRow = row * mNumColumns; int endOfRow = Math.min(startOfRow + mNumColumns, children); @@ -114,9 +116,16 @@ public class PseudoGridView extends ViewGroup { View child = getChildAt(i); int width = child.getMeasuredWidth(); int height = child.getMeasuredHeight(); + if (isRtl) { + x -= width; + } child.layout(x, y, x + width, y + height); maxHeight = Math.max(maxHeight, height); - x += width + mHorizontalSpacing; + if (isRtl) { + x -= mHorizontalSpacing; + } else { + x += width + mHorizontalSpacing; + } } y += maxHeight; if (row > 0) { |