From 1bb2bead8bef850037c8b72209cd72a442572821 Mon Sep 17 00:00:00 2001 From: Noam Schachter Date: Tue, 10 Jul 2018 08:19:01 -0700 Subject: [PATCH] Fixing Crush on SDK 15 (ICS) on ReactTextInputLocalData Summary: We had a crush reprot from Loadstone (manual tests) for RN standalone app on ICS, see: https://our.intern.facebook.com/intern/tasks/view_inline_attachment/?attachment_id=2296063267087587&fbid=314266832445741 Seems like we are using TextView.getMinLines and TextView.getMaxLines - both added in SDK 16, witought a propert guard. see: https://developer.android.com/reference/android/widget/TextView#getMinLines() https://developer.android.com/reference/android/widget/TextView#getMaxLines() Reviewed By: shergin Differential Revision: D8763942 fbshipit-source-id: a56a6fc3e575b8ea97ddab983561df878b2f341c --- .../react/views/textinput/ReactTextInputLocalData.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java index 3940e4f7c62043..ce7b2725bb690b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java @@ -25,10 +25,16 @@ public final class ReactTextInputLocalData { public ReactTextInputLocalData(EditText editText) { mText = new SpannableStringBuilder(editText.getText()); mTextSize = editText.getTextSize(); - mMinLines = editText.getMinLines(); - mMaxLines = editText.getMaxLines(); mInputType = editText.getInputType(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + mMinLines = editText.getMinLines(); + mMaxLines = editText.getMaxLines(); + } else { + mMinLines = 1; + mMaxLines = 1; + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { mBreakStrategy = editText.getBreakStrategy(); } else {