From 071cae825129b81d03d3c66ca4a724e949c0de66 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Mon, 23 May 2022 03:59:47 -0700 Subject: [PATCH] Cleanup ReactTextInputManager inner classes and helpers Summary: * Make inner classes static where possible * Make member variables final when set from constructor * Remove Nullable on `mFabricViewStateManager` and associated checks * Remove `createInternalEditText` which has moved to the ShadowNode (paper-only) Changelog: [Internal] Reviewed By: genkikondo Differential Revision: D36545807 fbshipit-source-id: 85517511d1734f0e55de5caa012e32feb40e8492 --- .../react/views/textinput/ReactEditText.java | 11 ++- .../textinput/ReactTextInputManager.java | 70 +++++++------------ 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 0b96e0b2047..d6ef3952e8d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -114,8 +114,7 @@ public class ReactEditText extends AppCompatEditText private ReactViewBackgroundManager mReactBackgroundManager; - private final @Nullable FabricViewStateManager mFabricViewStateManager = - new FabricViewStateManager(); + private final FabricViewStateManager mFabricViewStateManager = new FabricViewStateManager(); protected boolean mDisableTextDiffing = false; protected boolean mIsSettingTextFromState = false; @@ -642,7 +641,7 @@ public class ReactEditText extends AppCompatEditText // This is hacked in for Fabric. When we delete non-Fabric code, we might be able to simplify or // clean this up a bit. private void addSpansForMeasurement(Spannable spannable) { - if (mFabricViewStateManager != null && !mFabricViewStateManager.hasStateWrapper()) { + if (!mFabricViewStateManager.hasStateWrapper()) { return; } @@ -748,9 +747,7 @@ public class ReactEditText extends AppCompatEditText // view, we don't need to construct one or apply it at all - it provides no use in Fabric. ReactContext reactContext = getReactContext(this); - if (mFabricViewStateManager != null - && !mFabricViewStateManager.hasStateWrapper() - && !reactContext.isBridgeless()) { + if (!mFabricViewStateManager.hasStateWrapper() && !reactContext.isBridgeless()) { final ReactTextInputLocalData localData = new ReactTextInputLocalData(this); UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class); if (uiManager != null) { @@ -986,7 +983,7 @@ public class ReactEditText extends AppCompatEditText */ private void updateCachedSpannable(boolean resetStyles) { // Noops in non-Fabric - if (mFabricViewStateManager != null && !mFabricViewStateManager.hasStateWrapper()) { + if (!mFabricViewStateManager.hasStateWrapper()) { return; } // If this view doesn't have an ID yet, we don't have a cache key, so bail here 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 203fcec733f..29411fbcae3 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 @@ -27,7 +27,6 @@ import android.view.Gravity; import android.view.KeyEvent; import android.view.View; import android.view.inputmethod.EditorInfo; -import android.widget.EditText; import android.widget.TextView; import androidx.annotation.Nullable; import androidx.autofill.HintConstants; @@ -972,12 +971,11 @@ public class ReactTextInputManager extends BaseViewManager