Skip to content

Commit 8c9c8ba

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Minimize EditText Spans 4/9: ReactForegroundColorSpan (#36545)
Summary: Pull Request resolved: #36545 This is part of a series of changes to minimize the number of spans committed to EditText, as a mitigation for platform issues on Samsung devices. See this [GitHub thread]( #35936 (comment)) for greater context on the platform behavior. This adds ReactForegroundColorSpan to the list of spans eligible to be stripped. Changelog: [Android][Fixed] - Minimize Spans 4/N: ReactForegroundColorSpan Reviewed By: javache Differential Revision: D44240780 fbshipit-source-id: d86939cc2d7ed9116a4167026c7d48928fc51757
1 parent cc0ba57 commit 8c9c8ba

File tree

1 file changed

+12
-0
lines changed
  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput

1 file changed

+12
-0
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java

+12
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import com.facebook.react.views.text.CustomStyleSpan;
5353
import com.facebook.react.views.text.ReactAbsoluteSizeSpan;
5454
import com.facebook.react.views.text.ReactBackgroundColorSpan;
55+
import com.facebook.react.views.text.ReactForegroundColorSpan;
5556
import com.facebook.react.views.text.ReactSpan;
5657
import com.facebook.react.views.text.ReactTextUpdate;
5758
import com.facebook.react.views.text.ReactTypefaceUtils;
@@ -692,6 +693,16 @@ public boolean test(ReactBackgroundColorSpan span) {
692693
return span.getBackgroundColor() == mReactBackgroundManager.getBackgroundColor();
693694
}
694695
});
696+
697+
stripSpansOfKind(
698+
sb,
699+
ReactForegroundColorSpan.class,
700+
new SpanPredicate<ReactForegroundColorSpan>() {
701+
@Override
702+
public boolean test(ReactForegroundColorSpan span) {
703+
return span.getForegroundColor() == getCurrentTextColor();
704+
}
705+
});
695706
}
696707

697708
private <T> void stripSpansOfKind(
@@ -718,6 +729,7 @@ private void restoreStyleEquivalentSpans(SpannableStringBuilder workingText) {
718729

719730
List<Object> spans = new ArrayList<>();
720731
spans.add(new ReactAbsoluteSizeSpan(mTextAttributes.getEffectiveFontSize()));
732+
spans.add(new ReactForegroundColorSpan(getCurrentTextColor()));
721733

722734
int backgroundColor = mReactBackgroundManager.getBackgroundColor();
723735
if (backgroundColor != Color.TRANSPARENT) {

0 commit comments

Comments
 (0)