From a9ec72d8bfa497c134d6daec7bb1ec6981820fc0 Mon Sep 17 00:00:00 2001 From: Alpha Date: Mon, 24 Aug 2020 18:27:51 -0400 Subject: [PATCH] fix(android): Invisible text input (#177) --- .../java/org/umhan35/RNSearchBarManager.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/android/src/main/java/org/umhan35/RNSearchBarManager.java b/android/src/main/java/org/umhan35/RNSearchBarManager.java index e46d0c0..870995f 100644 --- a/android/src/main/java/org/umhan35/RNSearchBarManager.java +++ b/android/src/main/java/org/umhan35/RNSearchBarManager.java @@ -147,10 +147,14 @@ public void setText(SearchView searchView, String text) { searchView.setQuery(text, false); } - @ReactProp(name = "textColor", customType = "Color") - public void setTextColor(SearchView searchView, @Nullable Integer color) { + @ReactProp(name = "textColor", defaultInt = Color.TRANSPARENT, customType = "Color") + public void setTextColor(SearchView searchView, int color) { ColorStateList colorList; - if (color == null) { + if (color == Color.TRANSPARENT) { + // A recent version of RN started sending `0` instead if `null` if a color + // parameter is not supplied JS-side. This means it is no longer possible + // to use param `@Nullable Integer color` to detect defaults. So, assume that + // transparent text is never the goal, and treat that as `null`. final int[] attrs = {android.R.attr.textColorPrimary}; final TypedArray a = searchView.getContext().obtainStyledAttributes(0, attrs); colorList = a.getColorStateList(0); @@ -166,13 +170,9 @@ public void setTextColor(SearchView searchView, @Nullable Integer color) { }); } - @ReactProp(name = "textFieldBackgroundColor", customType = "Color") - public void setTextFieldBackgroundColor(SearchView searchView, @Nullable Integer color) { - if (color == null) { - searchView.setBackgroundColor(Color.WHITE); - } else { - searchView.setBackgroundColor(color); - } + @ReactProp(name = "textFieldBackgroundColor", defaultInt = Color.WHITE, customType = "Color") + public void setTextFieldBackgroundColor(SearchView searchView, int color) { + searchView.setBackgroundColor(color); } @Nonnull