@@ -3926,7 +3926,7 @@ protected void initializeScrollbars(TypedArray a) {
39263926 }
39273927
39283928 // Apply layout direction to the new Drawables if needed
3929- final int layoutDirection = getResolvedLayoutDirection ();
3929+ final int layoutDirection = getLayoutDirection ();
39303930 if (track != null) {
39313931 track.setLayoutDirection(layoutDirection);
39323932 }
@@ -5778,7 +5778,7 @@ public boolean isHapticFeedbackEnabled() {
57785778 @ViewDebug.IntToString(from = LAYOUT_DIRECTION_INHERIT, to = "INHERIT"),
57795779 @ViewDebug.IntToString(from = LAYOUT_DIRECTION_LOCALE, to = "LOCALE")
57805780 })
5781- public int getLayoutDirection () {
5781+ private int getRawLayoutDirection () {
57825782 return (mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_MASK) >> PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT;
57835783 }
57845784
@@ -5795,7 +5795,7 @@ public int getLayoutDirection() {
57955795 */
57965796 @RemotableViewMethod
57975797 public void setLayoutDirection(int layoutDirection) {
5798- if (getLayoutDirection () != layoutDirection) {
5798+ if (getRawLayoutDirection () != layoutDirection) {
57995799 // Reset the current layout direction and the resolved one
58005800 mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_MASK;
58015801 resetRtlProperties();
@@ -5820,7 +5820,7 @@ public void setLayoutDirection(int layoutDirection) {
58205820 @ViewDebug.IntToString(from = LAYOUT_DIRECTION_LTR, to = "RESOLVED_DIRECTION_LTR"),
58215821 @ViewDebug.IntToString(from = LAYOUT_DIRECTION_RTL, to = "RESOLVED_DIRECTION_RTL")
58225822 })
5823- public int getResolvedLayoutDirection () {
5823+ public int getLayoutDirection () {
58245824 final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion;
58255825 if (targetSdkVersion < JELLY_BEAN_MR1) {
58265826 mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED;
@@ -5842,7 +5842,7 @@ public int getResolvedLayoutDirection() {
58425842 */
58435843 @ViewDebug.ExportedProperty(category = "layout")
58445844 public boolean isLayoutRtl() {
5845- return (getResolvedLayoutDirection () == LAYOUT_DIRECTION_RTL);
5845+ return (getLayoutDirection () == LAYOUT_DIRECTION_RTL);
58465846 }
58475847
58485848 /**
@@ -9935,7 +9935,7 @@ public void setLayoutParams(ViewGroup.LayoutParams params) {
99359935 */
99369936 private void resolveLayoutParams() {
99379937 if (mLayoutParams != null) {
9938- mLayoutParams.onResolveLayoutDirection(getResolvedLayoutDirection ());
9938+ mLayoutParams.onResolveLayoutDirection(getLayoutDirection ());
99399939 }
99409940 }
99419941
@@ -11560,7 +11560,8 @@ public void resolveLayoutDirection() {
1156011560
1156111561 if (hasRtlSupport()) {
1156211562 // Set resolved depending on layout direction
11563- switch (getLayoutDirection()) {
11563+ switch ((mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_MASK) >>
11564+ PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) {
1156411565 case LAYOUT_DIRECTION_INHERIT:
1156511566 // We cannot resolve yet. LTR is by default and let the resolution happen again
1156611567 // later to get the correct resolved value
@@ -11572,7 +11573,7 @@ public void resolveLayoutDirection() {
1157211573 // resolution happen again later
1157311574 if (!viewGroup.canResolveLayoutDirection()) return;
1157411575
11575- if (viewGroup.getResolvedLayoutDirection () == LAYOUT_DIRECTION_RTL) {
11576+ if (viewGroup.getLayoutDirection () == LAYOUT_DIRECTION_RTL) {
1157611577 mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL;
1157711578 }
1157811579 break;
@@ -11602,7 +11603,8 @@ public void resolveLayoutDirection() {
1160211603 * @hide
1160311604 */
1160411605 public boolean canResolveLayoutDirection() {
11605- switch (getLayoutDirection()) {
11606+ switch ((mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_MASK) >>
11607+ PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) {
1160611608 case LAYOUT_DIRECTION_INHERIT:
1160711609 return (mParent != null) && (mParent instanceof ViewGroup);
1160811610 default:
@@ -11620,6 +11622,13 @@ public void resetResolvedLayoutDirection() {
1162011622 mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK;
1162111623 }
1162211624
11625+ /**
11626+ * @hide
11627+ */
11628+ public boolean isLayoutDirectionInherited() {
11629+ return (getRawLayoutDirection() == LAYOUT_DIRECTION_INHERIT);
11630+ }
11631+
1162311632 /**
1162411633 * Return if padding has been resolved
1162511634 *
@@ -11659,7 +11668,7 @@ public void resolvePadding() {
1165911668 // If start / end padding are defined, they will be resolved (hence overriding) to
1166011669 // left / right or right / left depending on the resolved layout direction.
1166111670 // If start / end padding are not defined, use the left / right ones.
11662- int resolvedLayoutDirection = getResolvedLayoutDirection ();
11671+ int resolvedLayoutDirection = getLayoutDirection ();
1166311672 // Set user padding to initial values ...
1166411673 mUserPaddingLeft = (mUserPaddingLeftInitial == UNDEFINED_PADDING) ?
1166511674 0 : mUserPaddingLeftInitial;
@@ -14101,9 +14110,9 @@ public void unscheduleDrawable(Drawable who) {
1410114110 */
1410214111 public void resolveDrawables() {
1410314112 if (mBackground != null) {
14104- mBackground.setLayoutDirection(getResolvedLayoutDirection ());
14113+ mBackground.setLayoutDirection(getLayoutDirection ());
1410514114 }
14106- onResolveDrawables(getResolvedLayoutDirection ());
14115+ onResolveDrawables(getLayoutDirection ());
1410714116 }
1410814117
1410914118 /**
@@ -14390,7 +14399,7 @@ public void setBackgroundDrawable(Drawable background) {
1439014399 padding = new Rect();
1439114400 sThreadLocal.set(padding);
1439214401 }
14393- background.setLayoutDirection(getResolvedLayoutDirection ());
14402+ background.setLayoutDirection(getLayoutDirection ());
1439414403 if (background.getPadding(padding)) {
1439514404 resetResolvedPadding();
1439614405 switch (background.getLayoutDirection()) {
@@ -14587,7 +14596,7 @@ public void setPaddingRelative(int start, int top, int end, int bottom) {
1458714596 mUserPaddingStart = start;
1458814597 mUserPaddingEnd = end;
1458914598
14590- switch(getResolvedLayoutDirection ()) {
14599+ switch(getLayoutDirection ()) {
1459114600 case LAYOUT_DIRECTION_RTL:
1459214601 mUserPaddingLeftInitial = end;
1459314602 mUserPaddingRightInitial = start;
@@ -14646,7 +14655,7 @@ public int getPaddingStart() {
1464614655 if (!isPaddingResolved()) {
1464714656 resolvePadding();
1464814657 }
14649- return (getResolvedLayoutDirection () == LAYOUT_DIRECTION_RTL) ?
14658+ return (getLayoutDirection () == LAYOUT_DIRECTION_RTL) ?
1465014659 mPaddingRight : mPaddingLeft;
1465114660 }
1465214661
@@ -14675,7 +14684,7 @@ public int getPaddingEnd() {
1467514684 if (!isPaddingResolved()) {
1467614685 resolvePadding();
1467714686 }
14678- return (getResolvedLayoutDirection () == LAYOUT_DIRECTION_RTL) ?
14687+ return (getLayoutDirection () == LAYOUT_DIRECTION_RTL) ?
1467914688 mPaddingLeft : mPaddingRight;
1468014689 }
1468114690
0 commit comments