@@ -16496,6 +16496,8 @@ protected float getHorizontalScrollFactor() {
1649616496 * {@link #TEXT_DIRECTION_LTR},
1649716497 * {@link #TEXT_DIRECTION_RTL},
1649816498 * {@link #TEXT_DIRECTION_LOCALE}
16499+ *
16500+ * @hide
1649916501 */
1650016502 @ViewDebug.ExportedProperty(category = "text", mapping = {
1650116503 @ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"),
@@ -16505,7 +16507,7 @@ protected float getHorizontalScrollFactor() {
1650516507 @ViewDebug.IntToString(from = TEXT_DIRECTION_RTL, to = "RTL"),
1650616508 @ViewDebug.IntToString(from = TEXT_DIRECTION_LOCALE, to = "LOCALE")
1650716509 })
16508- public int getTextDirection () {
16510+ public int getRawTextDirection () {
1650916511 return (mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_MASK) >> PFLAG2_TEXT_DIRECTION_MASK_SHIFT;
1651016512 }
1651116513
@@ -16522,7 +16524,7 @@ public int getTextDirection() {
1652216524 * {@link #TEXT_DIRECTION_LOCALE}
1652316525 */
1652416526 public void setTextDirection(int textDirection) {
16525- if (getTextDirection () != textDirection) {
16527+ if (getRawTextDirection () != textDirection) {
1652616528 // Reset the current text direction and the resolved one
1652716529 mPrivateFlags2 &= ~PFLAG2_TEXT_DIRECTION_MASK;
1652816530 resetResolvedTextDirection();
@@ -16539,10 +16541,10 @@ public void setTextDirection(int textDirection) {
1653916541 /**
1654016542 * Return the resolved text direction.
1654116543 *
16542- * This needs resolution if the value is TEXT_DIRECTION_INHERIT. The resolution matches
16543- * {@link #getTextDirection()} if it is not TEXT_DIRECTION_INHERIT, otherwise resolution proceeds
16544- * up the parent chain of the view. if there is no parent, then it will return the default
16545- * {@link #TEXT_DIRECTION_FIRST_STRONG}.
16544+ * This needs resolution if the value is TEXT_DIRECTION_INHERIT. The resolution matches what has
16545+ * been set by {@link #setTextDirection(int)} if it is not TEXT_DIRECTION_INHERIT, otherwise the
16546+ * resolution proceeds up the parent chain of the view. If there is no parent, then it will
16547+ * return the default {@link #TEXT_DIRECTION_FIRST_STRONG}.
1654616548 *
1654716549 * @return the resolved text direction. Returns one of:
1654816550 *
@@ -16552,7 +16554,7 @@ public void setTextDirection(int textDirection) {
1655216554 * {@link #TEXT_DIRECTION_RTL},
1655316555 * {@link #TEXT_DIRECTION_LOCALE}
1655416556 */
16555- public int getResolvedTextDirection () {
16557+ public int getTextDirection () {
1655616558 // The text direction will be resolved only if needed
1655716559 if ((mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_RESOLVED) != PFLAG2_TEXT_DIRECTION_RESOLVED) {
1655816560 resolveTextDirection();
@@ -16571,14 +16573,14 @@ public void resolveTextDirection() {
1657116573
1657216574 if (hasRtlSupport()) {
1657316575 // Set resolved text direction flag depending on text direction flag
16574- final int textDirection = getTextDirection ();
16576+ final int textDirection = getRawTextDirection ();
1657516577 switch(textDirection) {
1657616578 case TEXT_DIRECTION_INHERIT:
1657716579 if (canResolveTextDirection()) {
1657816580 ViewGroup viewGroup = ((ViewGroup) mParent);
1657916581
1658016582 // Set current resolved direction to the same value as the parent's one
16581- final int parentResolvedDirection = viewGroup.getResolvedTextDirection ();
16583+ final int parentResolvedDirection = viewGroup.getTextDirection ();
1658216584 switch (parentResolvedDirection) {
1658316585 case TEXT_DIRECTION_FIRST_STRONG:
1658416586 case TEXT_DIRECTION_ANY_RTL:
@@ -16624,7 +16626,7 @@ public void resolveTextDirection() {
1662416626 * @return true if text direction resolution can be done otherwise return false.
1662516627 */
1662616628 private boolean canResolveTextDirection() {
16627- switch (getTextDirection ()) {
16629+ switch (getRawTextDirection ()) {
1662816630 case TEXT_DIRECTION_INHERIT:
1662916631 return (mParent != null) && (mParent instanceof ViewGroup);
1663016632 default:
@@ -16634,14 +16636,21 @@ private boolean canResolveTextDirection() {
1663416636
1663516637 /**
1663616638 * Reset resolved text direction. Text direction can be resolved with a call to
16637- * getResolvedTextDirection ().
16639+ * getTextDirection ().
1663816640 *
1663916641 * @hide
1664016642 */
1664116643 public void resetResolvedTextDirection() {
1664216644 mPrivateFlags2 &= ~(PFLAG2_TEXT_DIRECTION_RESOLVED | PFLAG2_TEXT_DIRECTION_RESOLVED_MASK);
1664316645 }
1664416646
16647+ /**
16648+ * @hide
16649+ */
16650+ public boolean isTextDirectionInherited() {
16651+ return (getRawTextDirection() == TEXT_DIRECTION_INHERIT);
16652+ }
16653+
1664516654 /**
1664616655 * Return the value specifying the text alignment or policy that was set with
1664716656 * {@link #setTextAlignment(int)}.
0 commit comments