Skip to content

Commit 205623c

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 62d9920 commit 205623c

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;
@@ -662,6 +663,16 @@ public boolean test(ReactBackgroundColorSpan span) {
662663
return span.getBackgroundColor() == mReactBackgroundManager.getBackgroundColor();
663664
}
664665
});
666+
667+
stripSpansOfKind(
668+
sb,
669+
ReactForegroundColorSpan.class,
670+
new SpanPredicate<ReactForegroundColorSpan>() {
671+
@Override
672+
public boolean test(ReactForegroundColorSpan span) {
673+
return span.getForegroundColor() == getCurrentTextColor();
674+
}
675+
});
665676
}
666677

667678
private <T> void stripSpansOfKind(
@@ -688,6 +699,7 @@ private void restoreStyleEquivalentSpans(SpannableStringBuilder workingText) {
688699

689700
List<Object> spans = new ArrayList<>();
690701
spans.add(new ReactAbsoluteSizeSpan(mTextAttributes.getEffectiveFontSize()));
702+
spans.add(new ReactForegroundColorSpan(getCurrentTextColor()));
691703

692704
int backgroundColor = mReactBackgroundManager.getBackgroundColor();
693705
if (backgroundColor != Color.TRANSPARENT) {

0 commit comments

Comments
 (0)