From 7c5587e6fdfdd1992992c3b0a5423c3d2e6ddcf5 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 5 Feb 2021 17:15:41 +0100 Subject: [PATCH] fix - underlineColorAndroid not working on API 21 on API 21 we change the logic as follows to fix underlineColorAndroid: - we store the bottomBorderColor in a local variable - we set the bottomBorderColor to the same color of underlineColorAndroid - we set the underlineColorAndroid - we re-set the bottomBorderColor to the previous color As by Facebook design it defaults to transparent https://github.com/facebook/react-native/issues/18938 https://github.com/facebook/react-native/pull/18988 but it is important to notice how this default is now not anymore used as JAVA sets a new default of transparent for all colors (null is not passed to this setter) https://github.com/facebook/react-native/issues/29412#issuecomment-773412466 --- .../views/textinput/ReactTextInputManager.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index f3fc1f2c996ff8..1efc4030d055ed 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -543,14 +543,17 @@ public void setUnderlineColor(ReactEditText view, @Nullable Integer underlineCol } } - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) { - setBorderColor(view, 4, Color.TRANSPARENT); - } - if (underlineColor == null) { drawableToMutate.clearColorFilter(); } else { - drawableToMutate.setColorFilter(underlineColor, PorterDuff.Mode.SRC_IN); + if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) { + int bottomBorderColor = view.getBorderColor(Spacing.BOTTOM); + setBorderColor(view, Spacing.BOTTOM, underlineColor); + drawableToMutate.setColorFilter(underlineColor, PorterDuff.Mode.SRC_IN); + setBorderColor(view, Spacing.BOTTOM, bottomBorderColor); + } else { + drawableToMutate.setColorFilter(underlineColor, PorterDuff.Mode.SRC_IN); + } } }