Do not overwrite the same text in ReactEditText

Differential Revision: D6516674

fbshipit-source-id: 246b8efeff7963912bf6b1c8a004c3103be03246
This commit is contained in:
Shin-Kai Chen 2017-12-11 21:38:58 -08:00 committed by Facebook Github Bot
parent 098a63a1ce
commit 29f3f55298

View File

@ -19,6 +19,7 @@ import android.text.InputType;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextWatcher;
import android.text.TextUtils;
import android.text.method.KeyListener;
import android.text.method.QwertyKeyListener;
import android.text.style.AbsoluteSizeSpan;
@ -342,6 +343,11 @@ public class ReactEditText extends EditText {
// VisibleForTesting from {@link TextInputEventsTestCase}.
public void maybeSetText(ReactTextUpdate reactTextUpdate) {
if( isSecureText() &&
TextUtils.equals(getText(), reactTextUpdate.getText())) {
return;
}
// Only set the text if it is up to date.
mMostRecentEventCount = reactTextUpdate.getJsEventCounter();
if (mMostRecentEventCount < mNativeEventCount) {
@ -439,6 +445,14 @@ public class ReactEditText extends EditText {
return (getInputType() & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0;
}
private boolean isSecureText() {
return
(getInputType() &
(InputType.TYPE_NUMBER_VARIATION_PASSWORD |
InputType.TYPE_TEXT_VARIATION_PASSWORD))
!= 0;
}
private void onContentSizeChange() {
if (mContentSizeWatcher != null) {
mContentSizeWatcher.onLayout();