@@ -16500,6 +16500,8 @@ protected float getHorizontalScrollFactor() {
1650016500 * {@link #TEXT_DIRECTION_LTR},
1650116501 * {@link #TEXT_DIRECTION_RTL},
1650216502 * {@link #TEXT_DIRECTION_LOCALE}
16503+ *
16504+ * @hide
1650316505 */
1650416506 @ViewDebug.ExportedProperty(category = "text", mapping = {
1650516507 @ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
@@ -16509,7 +16511,7 @@ protected float getHorizontalScrollFactor() {
1650916511 @ViewDebug.IntToString(from = TEXT_DIRECTION_RTL, to = "RTL"),
1651016512 @ViewDebug.IntToString(from = TEXT_DIRECTION_LOCALE, to = "LOCALE")
1651116513 })
16512- public int getTextDirection () {
16514+ public int getRawTextDirection () {
1651316515 return (mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_MASK) >> PFLAG2_TEXT_DIRECTION_MASK_SHIFT;
1651416516 }
1651516517
@@ -16526,7 +16528,7 @@ public int getTextDirection() {
1652616528 * {@link #TEXT_DIRECTION_LOCALE}
1652716529 */
1652816530 public void setTextDirection(int textDirection) {
16529- if (getTextDirection () != textDirection) {
16531+ if (getRawTextDirection () != textDirection) {
1653016532 // Reset the current text direction and the resolved one
1653116533 mPrivateFlags2 &= ~PFLAG2_TEXT_DIRECTION_MASK;
1653216534 resetResolvedTextDirection();
@@ -16543,10 +16545,10 @@ public void setTextDirection(int textDirection) {
1654316545 /**
1654416546 * Return the resolved text direction.
1654516547 *
16546- * This needs resolution if the value is TEXT_DIRECTION_INHERIT. The resolution matches
16547- * {@link #getTextDirection()} if it is not TEXT_DIRECTION_INHERIT, otherwise resolution proceeds
16548- * up the parent chain of the view. if there is no parent, then it will return the default
16549- * {@link #TEXT_DIRECTION_FIRST_STRONG}.
16548+ * This needs resolution if the value is TEXT_DIRECTION_INHERIT. The resolution matches what has
16549+ * been set by {@link #setTextDirection(int)} if it is not TEXT_DIRECTION_INHERIT, otherwise the
16550+ * resolution proceeds up the parent chain of the view. If there is no parent, then it will
16551+ * return the default {@link #TEXT_DIRECTION_FIRST_STRONG}.
1655016552 *
1655116553 * @return the resolved text direction. Returns one of:
1655216554 *
@@ -16556,7 +16558,7 @@ public void setTextDirection(int textDirection) {
1655616558 * {@link #TEXT_DIRECTION_RTL},
1655716559 * {@link #TEXT_DIRECTION_LOCALE}
1655816560 */
16559- public int getResolvedTextDirection () {
16561+ public int getTextDirection () {
1656016562 // The text direction will be resolved only if needed
1656116563 if ((mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_RESOLVED) != PFLAG2_TEXT_DIRECTION_RESOLVED) {
1656216564 resolveTextDirection();
@@ -16575,14 +16577,14 @@ public void resolveTextDirection() {
1657516577
1657616578 if (hasRtlSupport()) {
1657716579 // Set resolved text direction flag depending on text direction flag
16578- final int textDirection = getTextDirection ();
16580+ final int textDirection = getRawTextDirection ();
1657916581 switch(textDirection) {
1658016582 case TEXT_DIRECTION_INHERIT:
1658116583 if (canResolveTextDirection()) {
1658216584 ViewGroup viewGroup = ((ViewGroup) mParent);
1658316585
1658416586 // Set current resolved direction to the same value as the parent's one
16585- final int parentResolvedDirection = viewGroup.getResolvedTextDirection ();
16587+ final int parentResolvedDirection = viewGroup.getTextDirection ();
1658616588 switch (parentResolvedDirection) {
1658716589 case TEXT_DIRECTION_FIRST_STRONG:
1658816590 case TEXT_DIRECTION_ANY_RTL:
@@ -16628,7 +16630,7 @@ public void resolveTextDirection() {
1662816630 * @return true if text direction resolution can be done otherwise return false.
1662916631 */
1663016632 private boolean canResolveTextDirection() {
16631- switch (getTextDirection ()) {
16633+ switch (getRawTextDirection ()) {
1663216634 case TEXT_DIRECTION_INHERIT:
1663316635 return (mParent != null) && (mParent instanceof ViewGroup);
1663416636 default:
@@ -16638,14 +16640,21 @@ private boolean canResolveTextDirection() {
1663816640
1663916641 /**
1664016642 * Reset resolved text direction. Text direction can be resolved with a call to
16641- * getResolvedTextDirection ().
16643+ * getTextDirection ().
1664216644 *
1664316645 * @hide
1664416646 */
1664516647 public void resetResolvedTextDirection() {
1664616648 mPrivateFlags2 &= ~(PFLAG2_TEXT_DIRECTION_RESOLVED | PFLAG2_TEXT_DIRECTION_RESOLVED_MASK);
1664716649 }
1664816650
16651+ /**
16652+ * @hide
16653+ */
16654+ public boolean isTextDirectionInherited() {
16655+ return (getRawTextDirection() == TEXT_DIRECTION_INHERIT);
16656+ }
16657+
1664916658 /**
1665016659 * Return the value specifying the text alignment or policy that was set with
1665116660 * {@link #setTextAlignment(int)}.
0 commit comments