AndroidTextInput: keep track of mostRecentEventCount in C++ State

Summary:
Keep track of AndroidTextInput's mostRecentEventCount in C++ State.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18672368

fbshipit-source-id: ea7a635629050a6d4957cbcef6ec0bda5faaad9a
This commit is contained in:
Joshua Gross
2019-11-27 12:55:47 -08:00
committed by Facebook Github Bot
parent 309de462bd
commit da5ea0215a
5 changed files with 31 additions and 7 deletions
@@ -36,6 +36,9 @@ import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.views.text.ReactSpan;
import com.facebook.react.views.text.ReactTextUpdate;
@@ -92,6 +95,8 @@ public class ReactEditText extends EditText {
private ReactViewBackgroundManager mReactBackgroundManager;
protected @Nullable StateWrapper mStateWrapper = null;
private static final KeyListener sKeyListener = QwertyKeyListener.getInstanceForFullKeyboard();
public ReactEditText(Context context) {
@@ -274,7 +279,17 @@ public class ReactEditText extends EditText {
}
public void setMostRecentEventCount(int mostRecentEventCount) {
if (mMostRecentEventCount == mostRecentEventCount) {
return;
}
mMostRecentEventCount = mostRecentEventCount;
if (mStateWrapper != null) {
WritableMap map = new WritableNativeMap();
map.putInt("mostRecentEventCount", mMostRecentEventCount);
mStateWrapper.updateState(map);
}
}
public void setScrollWatcher(ScrollWatcher scrollWatcher) {
@@ -416,8 +431,9 @@ public class ReactEditText extends EditText {
mTypefaceDirty = false;
Typeface newTypeface = ReactTypefaceUtils.applyStyles(
getTypeface(), mFontStyle, mFontWeight, mFontFamily, getContext().getAssets());
Typeface newTypeface =
ReactTypefaceUtils.applyStyles(
getTypeface(), mFontStyle, mFontWeight, mFontFamily, getContext().getAssets());
setTypeface(newTypeface);
}
@@ -1072,10 +1072,11 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
// TODO add justificationMode prop into local Data
int justificationMode = Layout.JUSTIFICATION_MODE_NONE;
view.mStateWrapper = stateWrapper;
return new ReactTextUpdate(
spanned,
view.mNativeEventCount, // TODO add this into state, and call setState when the native event
// count is incremented?
state.getInt("mostRecentEventCount"),
false, // TODO add this into local Data
textViewProps.getTextAlign(),
textBreakStrategy,