Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve RTL #24069

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ public ReactBaseTextShadowNode() {
private int getTextAlign() {
int textAlign = mTextAlign;
if (getLayoutDirection() == YogaDirection.RTL) {
if (textAlign == Gravity.RIGHT) {
textAlign = Gravity.LEFT;
} else if (textAlign == Gravity.LEFT) {
textAlign = Gravity.RIGHT;
if (textAlign == Gravity.END) {
textAlign = Gravity.START;
} else if (textAlign == Gravity.START) {
textAlign = Gravity.END;
}
}
return textAlign;
Expand Down Expand Up @@ -364,7 +364,7 @@ public void setTextAlign(@Nullable String textAlign) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mJustificationMode = Layout.JUSTIFICATION_MODE_INTER_WORD;
}
mTextAlign = Gravity.LEFT;
mTextAlign = Gravity.START;
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mJustificationMode = Layout.JUSTIFICATION_MODE_NONE;
Expand All @@ -373,9 +373,9 @@ public void setTextAlign(@Nullable String textAlign) {
if (textAlign == null || "auto".equals(textAlign)) {
mTextAlign = Gravity.NO_GRAVITY;
} else if ("left".equals(textAlign)) {
mTextAlign = Gravity.LEFT;
mTextAlign = Gravity.START;
} else if ("right".equals(textAlign)) {
mTextAlign = Gravity.RIGHT;
mTextAlign = Gravity.END;
} else if ("center".equals(textAlign)) {
mTextAlign = Gravity.CENTER_HORIZONTAL;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public long measure(

Layout.Alignment alignment = Layout.Alignment.ALIGN_NORMAL;
switch (getTextAlign()) {
case Gravity.LEFT:
case Gravity.START:
alignment = Layout.Alignment.ALIGN_NORMAL;
break;
case Gravity.RIGHT:
case Gravity.END:
alignment = Layout.Alignment.ALIGN_OPPOSITE;
break;
case Gravity.CENTER_HORIZONTAL:
Expand Down Expand Up @@ -179,10 +179,10 @@ private void initMeasureFunction() {
private int getTextAlign() {
int textAlign = mTextAlign;
if (getLayoutDirection() == YogaDirection.RTL) {
if (textAlign == Gravity.RIGHT) {
textAlign = Gravity.LEFT;
} else if (textAlign == Gravity.LEFT) {
textAlign = Gravity.RIGHT;
if (textAlign == Gravity.END) {
textAlign = Gravity.START;
} else if (textAlign == Gravity.START) {
textAlign = Gravity.END;
}
}
return textAlign;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ public float getEffectiveLineHeight() {
public int getTextAlign() {
int textAlign = mTextAlign;
if (getLayoutDirection() == YogaDirection.RTL) {
if (textAlign == Gravity.RIGHT) {
textAlign = Gravity.LEFT;
} else if (textAlign == Gravity.LEFT) {
textAlign = Gravity.RIGHT;
if (textAlign == Gravity.END) {
textAlign = Gravity.START;
} else if (textAlign == Gravity.START) {
textAlign = Gravity.END;
}
}
return textAlign;
Expand Down Expand Up @@ -210,7 +210,7 @@ public void setTextAlign(@Nullable String textAlign) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mJustificationMode = Layout.JUSTIFICATION_MODE_INTER_WORD;
}
mTextAlign = Gravity.LEFT;
mTextAlign = Gravity.START;
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mJustificationMode = Layout.JUSTIFICATION_MODE_NONE;
Expand All @@ -219,9 +219,9 @@ public void setTextAlign(@Nullable String textAlign) {
if (textAlign == null || "auto".equals(textAlign)) {
mTextAlign = Gravity.NO_GRAVITY;
} else if ("left".equals(textAlign)) {
mTextAlign = Gravity.LEFT;
mTextAlign = Gravity.START;
} else if ("right".equals(textAlign)) {
mTextAlign = Gravity.RIGHT;
mTextAlign = Gravity.END;
} else if ("center".equals(textAlign)) {
mTextAlign = Gravity.CENTER_HORIZONTAL;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.facebook.react.views.textinput;

import android.annotation.TargetApi;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
Expand Down Expand Up @@ -478,7 +479,7 @@ public void setTextAlign(ReactEditText view, @Nullable String textAlign) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
view.setJustificationMode(Layout.JUSTIFICATION_MODE_INTER_WORD);
}
view.setGravityHorizontal(Gravity.LEFT);
view.setGravityHorizontal(Gravity.START);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
view.setJustificationMode(Layout.JUSTIFICATION_MODE_NONE);
Expand All @@ -487,9 +488,9 @@ public void setTextAlign(ReactEditText view, @Nullable String textAlign) {
if (textAlign == null || "auto".equals(textAlign)) {
view.setGravityHorizontal(Gravity.NO_GRAVITY);
} else if ("left".equals(textAlign)) {
view.setGravityHorizontal(Gravity.LEFT);
view.setGravityHorizontal(Gravity.START);
} else if ("right".equals(textAlign)) {
view.setGravityHorizontal(Gravity.RIGHT);
view.setGravityHorizontal(Gravity.END);
} else if ("center".equals(textAlign)) {
view.setGravityHorizontal(Gravity.CENTER_HORIZONTAL);
} else {
Expand Down