Safely fix underline TextInput
Summary: Resubmit of https://github.com/facebook/react-native/pull/12493 factoring in the AOSP bug here: https://code.google.com/p/android/issues/detail?id=191754 Reviewed By: achen1 Differential Revision: D4627575 fbshipit-source-id: 8a984852db54be98bd6e781a4d00854d7d0dca68
This commit is contained in:
parent
32d753164d
commit
dfe09db990
|
@ -367,10 +367,17 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
|||
|
||||
@ReactProp(name = "underlineColorAndroid", customType = "Color")
|
||||
public void setUnderlineColor(ReactEditText view, @Nullable Integer underlineColor) {
|
||||
// Drawable.mutate() can sometimes crash due to an AOSP bug:
|
||||
// See https://code.google.com/p/android/issues/detail?id=191754 for more info
|
||||
Drawable background = view.getBackground();
|
||||
Drawable drawableToMutate = background.getConstantState() != null ?
|
||||
background.mutate() :
|
||||
background;
|
||||
|
||||
if (underlineColor == null) {
|
||||
view.getBackground().clearColorFilter();
|
||||
drawableToMutate.clearColorFilter();
|
||||
} else {
|
||||
view.getBackground().setColorFilter(underlineColor, PorterDuff.Mode.SRC_IN);
|
||||
drawableToMutate.setColorFilter(underlineColor, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue