Skip to content

Commit ec13924

Browse files
Fabrice Di MeglioAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug #7325234 LayoutParams are not resolved correctly (Settings apps looks broken on Manta in Arabic)" into jb-mr1-dev
2 parents ee0d8de + 6bf6eb7 commit ec13924

File tree

7 files changed

+28
-6
lines changed

7 files changed

+28
-6
lines changed

core/java/android/view/ViewGroup.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4817,6 +4817,8 @@ protected void measureChildWithMargins(View child,
48174817
int parentWidthMeasureSpec, int widthUsed,
48184818
int parentHeightMeasureSpec, int heightUsed) {
48194819
final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
4820+
final int layoutDirection = getLayoutDirection();
4821+
lp.resolveLayoutDirection(layoutDirection);
48204822

48214823
final int childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec,
48224824
mPaddingLeft + mPaddingRight + lp.leftMargin + lp.rightMargin

core/java/android/widget/FrameLayout.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,16 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
304304
int maxWidth = 0;
305305
int childState = 0;
306306

307+
final int layoutDirection = getLayoutDirection();
308+
307309
for (int i = 0; i < count; i++) {
308310
final View child = getChildAt(i);
309311
if (mMeasureAllChildren || child.getVisibility() != GONE) {
310312
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
313+
// measureChildWithMargins() has triggered layout params resolution, so no need
314+
// to do it now
311315
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
316+
312317
maxWidth = Math.max(maxWidth,
313318
child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin);
314319
maxHeight = Math.max(maxHeight,

core/java/android/widget/RelativeLayout.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,15 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
414414
final boolean isWrapContentWidth = widthMode != MeasureSpec.EXACTLY;
415415
final boolean isWrapContentHeight = heightMode != MeasureSpec.EXACTLY;
416416

417+
final int layoutDirection = getLayoutDirection();
418+
417419
View[] views = mSortedHorizontalChildren;
418420
int count = views.length;
419421
for (int i = 0; i < count; i++) {
420422
View child = views[i];
421423
if (child.getVisibility() != GONE) {
422424
LayoutParams params = (LayoutParams) child.getLayoutParams();
425+
params.resolveLayoutDirection(layoutDirection);
423426

424427
applyHorizontalSizeRules(params, myWidth);
425428
measureChildHorizontal(child, params, myWidth, myHeight);
@@ -483,8 +486,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
483486
}
484487
}
485488

486-
final int layoutDirection = getLayoutDirection();
487-
488489
if (isWrapContentWidth) {
489490
// Width already has left padding in it since it was calculated by looking at
490491
// the right of each child view

core/java/android/widget/ScrollView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,13 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
329329
return;
330330
}
331331

332+
final int layoutDirection = getLayoutDirection();
332333
if (getChildCount() > 0) {
333334
final View child = getChildAt(0);
334335
int height = getMeasuredHeight();
335336
if (child.getMeasuredHeight() < height) {
336337
final FrameLayout.LayoutParams lp = (LayoutParams) child.getLayoutParams();
338+
lp.resolveLayoutDirection(layoutDirection);
337339

338340
int childWidthMeasureSpec = getChildMeasureSpec(widthMeasureSpec,
339341
mPaddingLeft + mPaddingRight, lp.width);

core/java/android/widget/TableRow.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ void measureChildBeforeLayout(View child, int childIndex,
192192
int widthMeasureSpec, int totalWidth,
193193
int heightMeasureSpec, int totalHeight) {
194194
if (mConstrainedColumnWidths != null) {
195+
final int layoutDirection = getLayoutDirection();
195196
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
197+
lp.resolveLayoutDirection(layoutDirection);
196198

197199
int measureMode = MeasureSpec.EXACTLY;
198200
int columnWidth = 0;
@@ -226,7 +228,6 @@ void measureChildBeforeLayout(View child, int childIndex,
226228
final int childWidth = child.getMeasuredWidth();
227229
lp.mOffset[LayoutParams.LOCATION_NEXT] = columnWidth - childWidth;
228230

229-
final int layoutDirection = getLayoutDirection();
230231
final int absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection);
231232
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
232233
case Gravity.LEFT:
@@ -292,11 +293,13 @@ int[] getColumnsWidths(int widthMeasureSpec) {
292293
}
293294

294295
final int[] columnWidths = mColumnWidths;
296+
final int layoutDirection = getLayoutDirection();
295297

296298
for (int i = 0; i < numColumns; i++) {
297299
final View child = getVirtualChildAt(i);
298300
if (child != null && child.getVisibility() != GONE) {
299301
final LayoutParams layoutParams = (LayoutParams) child.getLayoutParams();
302+
layoutParams.resolveLayoutDirection(layoutDirection);
300303
if (layoutParams.span == 1) {
301304
int spec;
302305
switch (layoutParams.width) {

core/java/com/android/internal/widget/ActionBarContextView.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,11 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
343343
final int height = maxHeight - verticalPadding;
344344
final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
345345

346+
final int layoutDirection = getLayoutDirection();
346347
if (mClose != null) {
347348
availableWidth = measureChildView(mClose, availableWidth, childSpecHeight, 0);
348349
MarginLayoutParams lp = (MarginLayoutParams) mClose.getLayoutParams();
350+
lp.resolveLayoutDirection(layoutDirection);
349351
availableWidth -= lp.leftMargin + lp.rightMargin;
350352
}
351353

core/java/com/android/internal/widget/ActionBarView.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
946946
final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
947947
(ActionBar.LayoutParams) lp : null;
948948

949+
final int layoutDirection = getLayoutDirection();
950+
lp.resolveLayoutDirection(layoutDirection);
951+
949952
int horizontalMargin = 0;
950953
int verticalMargin = 0;
951954
if (ablp != null) {
@@ -1096,9 +1099,9 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
10961099
customView = mCustomNavView;
10971100
}
10981101
if (customView != null) {
1099-
final int resolvedLayoutDirection = getLayoutDirection();
11001102
ViewGroup.LayoutParams lp = customView.getLayoutParams();
1101-
lp.resolveLayoutDirection(resolvedLayoutDirection);
1103+
final int layoutDirection = getLayoutDirection();
1104+
lp.resolveLayoutDirection(layoutDirection);
11021105
final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
11031106
(ActionBar.LayoutParams) lp : null;
11041107
final int gravity = ablp != null ? ablp.gravity : DEFAULT_CUSTOM_GRAVITY;
@@ -1139,7 +1142,7 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
11391142
}
11401143

11411144
int xpos = 0;
1142-
switch (Gravity.getAbsoluteGravity(hgravity, resolvedLayoutDirection)) {
1145+
switch (Gravity.getAbsoluteGravity(hgravity, layoutDirection)) {
11431146
case Gravity.CENTER_HORIZONTAL:
11441147
xpos = ((mRight - mLeft) - navWidth) / 2;
11451148
break;
@@ -1336,11 +1339,15 @@ public int getStartOffset() {
13361339
@Override
13371340
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
13381341
measureChildWithMargins(mUpView, widthMeasureSpec, 0, heightMeasureSpec, 0);
1342+
// measureChildWithMargins() has triggered layout params resolution, so no need
1343+
// to do it now
13391344
final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams();
13401345
mUpWidth = upLp.leftMargin + mUpView.getMeasuredWidth() + upLp.rightMargin;
13411346
int width = mUpView.getVisibility() == GONE ? 0 : mUpWidth;
13421347
int height = upLp.topMargin + mUpView.getMeasuredHeight() + upLp.bottomMargin;
13431348
measureChildWithMargins(mIconView, widthMeasureSpec, width, heightMeasureSpec, 0);
1349+
// measureChildWithMargins() has triggered layout params resolution, so no need
1350+
// to do it now
13441351
final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams();
13451352
width += iconLp.leftMargin + mIconView.getMeasuredWidth() + iconLp.rightMargin;
13461353
height = Math.max(height,

0 commit comments

Comments
 (0)