Fix copy paste

Reviewed By: andreicoman11

Differential Revision: D4944482

fbshipit-source-id: 8841a57194943ced489a2d8b0c634b3befcce1d7
This commit is contained in:
Andrew Y. Chen 2017-04-25 11:15:46 -07:00 committed by Facebook Github Bot
parent 102f990861
commit 86dd77f924
1 changed files with 12 additions and 1 deletions

View File

@ -28,6 +28,7 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
@ -91,13 +92,23 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
@Override
public ReactEditText createViewInstance(ThemedReactContext context) {
ReactEditText editText = new ReactEditText(context);
final ReactEditText editText = new ReactEditText(context);
int inputType = editText.getInputType();
editText.setInputType(inputType & (~InputType.TYPE_TEXT_FLAG_MULTI_LINE));
editText.setReturnKeyType("done");
editText.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
(int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)));
// Fixes an issue where the EditText is not selectable if nested within a
// ViewPagerAndroid on some versions of Android (API 16, 23)
editText.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
editText.getViewTreeObserver().removeOnPreDrawListener(this);
editText.setTextIsSelectable(true);
return true;
}
});
return editText;
}