mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Minimize EditText Spans 4/9: ReactForegroundColorSpan (#36545)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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]( https://github.com/facebook/react-native/issues/35936#issuecomment-1411437789) 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
This commit is contained in:
committed by
Lorenzo Sciandra
parent
e7e2556f56
commit
ab6be34269
@@ -52,6 +52,7 @@ import com.facebook.react.views.text.CustomLineHeightSpan;
|
||||
import com.facebook.react.views.text.CustomStyleSpan;
|
||||
import com.facebook.react.views.text.ReactAbsoluteSizeSpan;
|
||||
import com.facebook.react.views.text.ReactBackgroundColorSpan;
|
||||
import com.facebook.react.views.text.ReactForegroundColorSpan;
|
||||
import com.facebook.react.views.text.ReactSpan;
|
||||
import com.facebook.react.views.text.ReactTextUpdate;
|
||||
import com.facebook.react.views.text.ReactTypefaceUtils;
|
||||
@@ -657,6 +658,16 @@ public class ReactEditText extends AppCompatEditText
|
||||
return span.getBackgroundColor() == mReactBackgroundManager.getBackgroundColor();
|
||||
}
|
||||
});
|
||||
|
||||
stripSpansOfKind(
|
||||
sb,
|
||||
ReactForegroundColorSpan.class,
|
||||
new SpanPredicate<ReactForegroundColorSpan>() {
|
||||
@Override
|
||||
public boolean test(ReactForegroundColorSpan span) {
|
||||
return span.getForegroundColor() == getCurrentTextColor();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private <T> void stripSpansOfKind(
|
||||
@@ -683,6 +694,7 @@ public class ReactEditText extends AppCompatEditText
|
||||
|
||||
List<Object> spans = new ArrayList<>();
|
||||
spans.add(new ReactAbsoluteSizeSpan(mTextAttributes.getEffectiveFontSize()));
|
||||
spans.add(new ReactForegroundColorSpan(getCurrentTextColor()));
|
||||
|
||||
int backgroundColor = mReactBackgroundManager.getBackgroundColor();
|
||||
if (backgroundColor != Color.TRANSPARENT) {
|
||||
|
||||
Reference in New Issue
Block a user