Skip to content

Commit b164055

Browse files
NickGerlemankelset
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 3cdcbe7 commit b164055

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
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;
@@ -656,6 +657,16 @@ public boolean test(ReactBackgroundColorSpan span) {
656657
return span.getBackgroundColor() == mReactBackgroundManager.getBackgroundColor();
657658
}
658659
});
660+
661+
stripSpansOfKind(
662+
sb,
663+
ReactForegroundColorSpan.class,
664+
new SpanPredicate<ReactForegroundColorSpan>() {
665+
@Override
666+
public boolean test(ReactForegroundColorSpan span) {
667+
return span.getForegroundColor() == getCurrentTextColor();
668+
}
669+
});
659670
}
660671

661672
private <T> void stripSpansOfKind(
@@ -682,6 +693,7 @@ private void restoreStyleEquivalentSpans(SpannableStringBuilder workingText) {
682693

683694
List<Object> spans = new ArrayList<>();
684695
spans.add(new ReactAbsoluteSizeSpan(mTextAttributes.getEffectiveFontSize()));
696+
spans.add(new ReactForegroundColorSpan(getCurrentTextColor()));
685697

686698
int backgroundColor = mReactBackgroundManager.getBackgroundColor();
687699
if (backgroundColor != Color.TRANSPARENT) {

0 commit comments

Comments
 (0)