From c9df1db00a0b5ee5378135877b2d57724c309c63 Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Tue, 21 May 2019 06:36:38 -0700 Subject: [PATCH] allow custom maybeSetText logic for ReactEditText subclasses (#24927) Summary: We're working on a custom EditText that supports some rich text editing, and one of the places where our logic has to be different from the textinput provided by RN is the text setting logic: https://github.com/facebook/react-native/blob/7abfd23b90db08b426c3c91b0cb6d01d161a9b9e/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java#L377 However, some of the important members are private and our subclass cannot access them (we work around this now with reflection). It would be nice if we could work with them directly, either using getters and setters or by changing the access. Let me know what you think about this. Thanks. ## Changelog [Android] [Added] - allow custom maybeSetText logic for ReactEditText subclasses Pull Request resolved: https://github.com/facebook/react-native/pull/24927 Differential Revision: D15431682 Pulled By: cpojer fbshipit-source-id: 91860cadac0798a101ff7df6f6b868f3980ba9b1 --- .../com/facebook/react/views/textinput/ReactEditText.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 1638d492501..63a941a0c2a 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 @@ -58,18 +58,18 @@ public class ReactEditText extends EditText { // This flag is set to true when we set the text of the EditText explicitly. In that case, no // *TextChanged events should be triggered. This is less expensive than removing the text // listeners and adding them back again after the text change is completed. - private boolean mIsSettingTextFromJS; + protected boolean mIsSettingTextFromJS; // This component is controlled, so we want it to get focused only when JS ask it to do so. // Whenever android requests focus (which it does for random reasons), it will be ignored. private boolean mIsJSSettingFocus; private int mDefaultGravityHorizontal; private int mDefaultGravityVertical; - private int mNativeEventCount; - private int mMostRecentEventCount; + protected int mNativeEventCount; + protected int mMostRecentEventCount; private @Nullable ArrayList mListeners; private @Nullable TextWatcherDelegator mTextWatcherDelegator; private int mStagedInputType; - private boolean mContainsImages; + protected boolean mContainsImages; private @Nullable Boolean mBlurOnSubmit; private boolean mDisableFullscreen; private @Nullable String mReturnKeyType;