From 5feac1690f4f9461b26539c2e7504926b1bc78d9 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 29 Sep 2023 07:10:10 -0700 Subject: [PATCH 01/10] Remove support for Android API < 23 in ReactTextShadowNode Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class ReactTextShadowNode chnagelog: [Android][Breaking] Remove support for Android API < 23 in ReactTextShadowNode Differential Revision: D48545511 fbshipit-source-id: 68e887ea02193fbb0b6e706d0f868029ee7063fb --- .../react/views/text/ReactTextShadowNode.java | 80 ++++++++----------- 1 file changed, 33 insertions(+), 47 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java index a66950c7966af6..d53f18a5aa3289 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java @@ -7,7 +7,6 @@ package com.facebook.react.views.text; -import android.annotation.TargetApi; import android.os.Build; import android.text.BoringLayout; import android.text.Layout; @@ -47,7 +46,6 @@ *

The class measures text in {@code } view and feeds native {@link TextView} using {@code * Spannable} object constructed in superclass. */ -@TargetApi(Build.VERSION_CODES.M) public class ReactTextShadowNode extends ReactBaseTextShadowNode { // It's important to pass the ANTI_ALIAS_FLAG flag to the constructor rather than setting it @@ -148,7 +146,7 @@ public long measure( } } - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.Q) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { layoutWidth = (float) Math.ceil(layoutWidth); } float layoutHeight = height; @@ -222,28 +220,22 @@ private Layout measureSpannedText(Spannable text, float width, YogaMeasureMode w || (!YogaConstants.isUndefined(desiredWidth) && desiredWidth <= width))) { // Is used when the width is not known and the text is not boring, ie. if it contains // unicode characters. - int hintWidth = (int) Math.ceil(desiredWidth); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - layout = - new StaticLayout(text, textPaint, hintWidth, alignment, 1.f, 0.f, mIncludeFontPadding); - } else { - StaticLayout.Builder builder = - StaticLayout.Builder.obtain(text, 0, text.length(), textPaint, hintWidth) - .setAlignment(alignment) - .setLineSpacing(0.f, 1.f) - .setIncludePad(mIncludeFontPadding) - .setBreakStrategy(mTextBreakStrategy) - .setHyphenationFrequency(mHyphenationFrequency); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - builder.setJustificationMode(mJustificationMode); - } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - builder.setUseLineSpacingFromFallbacks(true); - } - layout = builder.build(); + StaticLayout.Builder builder = + StaticLayout.Builder.obtain(text, 0, text.length(), textPaint, hintWidth) + .setAlignment(alignment) + .setLineSpacing(0.f, 1.f) + .setIncludePad(mIncludeFontPadding) + .setBreakStrategy(mTextBreakStrategy) + .setHyphenationFrequency(mHyphenationFrequency); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + builder.setJustificationMode(mJustificationMode); + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + builder.setUseLineSpacingFromFallbacks(true); } + layout = builder.build(); } else if (boring != null && (unconstrainedWidth || boring.width <= width)) { // Is used for single-line, boring text when the width is either unknown or bigger @@ -260,32 +252,25 @@ private Layout measureSpannedText(Spannable text, float width, YogaMeasureMode w mIncludeFontPadding); } else { // Is used for multiline, boring text and the width is known. + // Android 11+ introduces changes in text width calculation which leads to cases + // where the container is measured smaller than text. Math.ceil prevents it + // See T136756103 for investigation + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { + width = (float) Math.ceil(width); + } - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - layout = - new StaticLayout( - text, textPaint, (int) width, alignment, 1.f, 0.f, mIncludeFontPadding); - } else { - // Android 11+ introduces changes in text width calculation which leads to cases - // where the container is measured smaller than text. Math.ceil prevents it - // See T136756103 for investigation - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.Q) { - width = (float) Math.ceil(width); - } - - StaticLayout.Builder builder = - StaticLayout.Builder.obtain(text, 0, text.length(), textPaint, (int) width) - .setAlignment(alignment) - .setLineSpacing(0.f, 1.f) - .setIncludePad(mIncludeFontPadding) - .setBreakStrategy(mTextBreakStrategy) - .setHyphenationFrequency(mHyphenationFrequency); + StaticLayout.Builder builder = + StaticLayout.Builder.obtain(text, 0, text.length(), textPaint, (int) width) + .setAlignment(alignment) + .setLineSpacing(0.f, 1.f) + .setIncludePad(mIncludeFontPadding) + .setBreakStrategy(mTextBreakStrategy) + .setHyphenationFrequency(mHyphenationFrequency); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - builder.setUseLineSpacingFromFallbacks(true); - } - layout = builder.build(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + builder.setUseLineSpacingFromFallbacks(true); } + layout = builder.build(); } return layout; } @@ -361,6 +346,7 @@ public void setShouldNotifyOnTextLayout(boolean shouldNotifyOnTextLayout) { } @Override + @Nullable public Iterable calculateLayoutOnChildren() { // Run flexbox on and return the descendants which are inline views. @@ -374,7 +360,7 @@ public Iterable calculateLayoutOnChildren() { "Spannable element has not been prepared in onBeforeLayout"); TextInlineViewPlaceholderSpan[] placeholders = text.getSpans(0, text.length(), TextInlineViewPlaceholderSpan.class); - ArrayList shadowNodes = new ArrayList(placeholders.length); + ArrayList shadowNodes = new ArrayList<>(placeholders.length); for (TextInlineViewPlaceholderSpan placeholder : placeholders) { ReactShadowNode child = mInlineViews.get(placeholder.getReactTag()); From 4f4c4d713b18121c0a2d4918fdd8d872a550445f Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 29 Sep 2023 07:10:10 -0700 Subject: [PATCH 02/10] Remove support for Android API < 23 in ReactTextView Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class ReactTextView chnagelog: [Android][Breaking] Remove support for Android API < 23 in ReactTextView Differential Revision: D48545504 fbshipit-source-id: 769e0141365bdf1e98da7835afa3bf4ccff568f3 --- .../facebook/react/views/text/ReactTextView.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java index 4af57295d9aac6..83bacaafb9ea60 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java @@ -106,9 +106,7 @@ private void initView() { // Defaults for these fields: // https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java#L1061 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE); - } + setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE); setMovementMethod(getDefaultMovementMethod()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { setJustificationMode(Layout.JUSTIFICATION_MODE_NONE); @@ -145,10 +143,7 @@ private void initView() { setFocusable(View.FOCUSABLE_AUTO); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE); - } - + setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE); updateView(); // call after changing ellipsizeLocation in particular } @@ -399,10 +394,8 @@ public void setText(ReactTextUpdate update) { if (nextTextAlign != getGravityHorizontal()) { setGravityHorizontal(nextTextAlign); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (getBreakStrategy() != update.getTextBreakStrategy()) { - setBreakStrategy(update.getTextBreakStrategy()); - } + if (getBreakStrategy() != update.getTextBreakStrategy()) { + setBreakStrategy(update.getTextBreakStrategy()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (getJustificationMode() != update.getJustificationMode()) { From 233cdf767a27ee75e55817724e4a046208d026a3 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 29 Sep 2023 07:10:10 -0700 Subject: [PATCH 03/10] Remove support for Android API < 23 in TextAttributeProps Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class TextAttributeProps chnagelog: [Android][Breaking] Remove support for Android API < 23 in TextAttributeProps Differential Revision: D48545514 fbshipit-source-id: 366f3ebac9d77fd58afcf6060a0043a12c903bab --- .../com/facebook/react/views/text/TextAttributeProps.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java index eb03a50743f0d6..09bddc6ea292c5 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java @@ -73,10 +73,8 @@ public class TextAttributeProps { private static final int DEFAULT_TEXT_SHADOW_COLOR = 0x55000000; private static final int DEFAULT_JUSTIFICATION_MODE = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) ? 0 : Layout.JUSTIFICATION_MODE_NONE; - private static final int DEFAULT_BREAK_STRATEGY = - (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY; - private static final int DEFAULT_HYPHENATION_FREQUENCY = - (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.HYPHENATION_FREQUENCY_NONE; + private static final int DEFAULT_BREAK_STRATEGY = Layout.BREAK_STRATEGY_HIGH_QUALITY; + private static final int DEFAULT_HYPHENATION_FREQUENCY = Layout.HYPHENATION_FREQUENCY_NONE; protected float mLineHeight = Float.NaN; protected boolean mIsColorSet = false; From 7602475c7f33ba6399205b5aec721a22408fee75 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 29 Sep 2023 07:10:10 -0700 Subject: [PATCH 04/10] Remove support for Android API < 23 in TextLayoutManager Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class TextLayoutManager chnagelog: [Android][Breaking] Remove support for Android API < 23 in TextLayoutManager Differential Revision: D48545502 fbshipit-source-id: 6b70a9b5cf68efc5f9ebad6c7c1f78c1f6efb141 --- .../react/views/text/TextLayoutManager.java | 67 ++++++------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index ffd5b2f1a5c4c2..93eda5d06b3866 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -258,26 +258,14 @@ private static Layout createLayout( // unicode characters. int hintWidth = (int) Math.ceil(desiredWidth); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - layout = - new StaticLayout( - text, - sTextPaintInstance, - hintWidth, - Layout.Alignment.ALIGN_NORMAL, - 1.f, - 0.f, - includeFontPadding); - } else { - layout = - StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, hintWidth) - .setAlignment(Layout.Alignment.ALIGN_NORMAL) - .setLineSpacing(0.f, 1.f) - .setIncludePad(includeFontPadding) - .setBreakStrategy(textBreakStrategy) - .setHyphenationFrequency(hyphenationFrequency) - .build(); - } + layout = + StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, hintWidth) + .setAlignment(Layout.Alignment.ALIGN_NORMAL) + .setLineSpacing(0.f, 1.f) + .setIncludePad(includeFontPadding) + .setBreakStrategy(textBreakStrategy) + .setHyphenationFrequency(hyphenationFrequency) + .build(); } else if (boring != null && (unconstrainedWidth || boring.width <= width)) { int boringLayoutWidth = boring.width; if (boring.width < 0) { @@ -300,32 +288,19 @@ private static Layout createLayout( includeFontPadding); } else { // Is used for multiline, boring text and the width is known. - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - layout = - new StaticLayout( - text, - sTextPaintInstance, - (int) width, - Layout.Alignment.ALIGN_NORMAL, - 1.f, - 0.f, - includeFontPadding); - } else { - StaticLayout.Builder builder = - StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, (int) width) - .setAlignment(Layout.Alignment.ALIGN_NORMAL) - .setLineSpacing(0.f, 1.f) - .setIncludePad(includeFontPadding) - .setBreakStrategy(textBreakStrategy) - .setHyphenationFrequency(hyphenationFrequency); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - builder.setUseLineSpacingFromFallbacks(true); - } - - layout = builder.build(); + StaticLayout.Builder builder = + StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, (int) width) + .setAlignment(Layout.Alignment.ALIGN_NORMAL) + .setLineSpacing(0.f, 1.f) + .setIncludePad(includeFontPadding) + .setBreakStrategy(textBreakStrategy) + .setHyphenationFrequency(hyphenationFrequency); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + builder.setUseLineSpacingFromFallbacks(true); } + + layout = builder.build(); } return layout; } @@ -423,7 +398,7 @@ public static long measureText( // Android 11+ introduces changes in text width calculation which leads to cases // where the container is measured smaller than text. Math.ceil prevents it // See T136756103 for investigation - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.Q) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { calculatedWidth = (float) Math.ceil(calculatedWidth); } From 04cbb07ea455e60db38b48af99b952bcb6ee2e8b Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 29 Sep 2023 07:10:10 -0700 Subject: [PATCH 05/10] Remove support for Android API < 23 in TextLayoutManagerMapBuffer Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class TextLayoutManagerMapBuffer chnagelog: [Android][Breaking] Remove support for Android API < 23 in TextLayoutManagerMapBuffer Differential Revision: D48545518 fbshipit-source-id: 7158be914604d0f8d271ff754a8a864be18e1fa9 --- .../text/TextLayoutManagerMapBuffer.java | 67 ++++++------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java index 8cd576494a1c24..60ef5f2e28de9d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java @@ -299,26 +299,14 @@ private static Layout createLayout( // unicode characters. int hintWidth = (int) Math.ceil(desiredWidth); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - layout = - new StaticLayout( - text, - sTextPaintInstance, - hintWidth, - Layout.Alignment.ALIGN_NORMAL, - 1.f, - 0.f, - includeFontPadding); - } else { - layout = - StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, hintWidth) - .setAlignment(Layout.Alignment.ALIGN_NORMAL) - .setLineSpacing(0.f, 1.f) - .setIncludePad(includeFontPadding) - .setBreakStrategy(textBreakStrategy) - .setHyphenationFrequency(hyphenationFrequency) - .build(); - } + layout = + StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, hintWidth) + .setAlignment(Layout.Alignment.ALIGN_NORMAL) + .setLineSpacing(0.f, 1.f) + .setIncludePad(includeFontPadding) + .setBreakStrategy(textBreakStrategy) + .setHyphenationFrequency(hyphenationFrequency) + .build(); } else if (boring != null && (unconstrainedWidth || boring.width <= width)) { int boringLayoutWidth = boring.width; @@ -341,32 +329,19 @@ private static Layout createLayout( includeFontPadding); } else { // Is used for multiline, boring text and the width is known. - - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - layout = - new StaticLayout( - text, - sTextPaintInstance, - (int) width, - Layout.Alignment.ALIGN_NORMAL, - 1.f, - 0.f, - includeFontPadding); - } else { - StaticLayout.Builder builder = - StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, (int) width) - .setAlignment(Layout.Alignment.ALIGN_NORMAL) - .setLineSpacing(0.f, 1.f) - .setIncludePad(includeFontPadding) - .setBreakStrategy(textBreakStrategy) - .setHyphenationFrequency(hyphenationFrequency); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - builder.setUseLineSpacingFromFallbacks(true); - } - - layout = builder.build(); + StaticLayout.Builder builder = + StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, (int) width) + .setAlignment(Layout.Alignment.ALIGN_NORMAL) + .setLineSpacing(0.f, 1.f) + .setIncludePad(includeFontPadding) + .setBreakStrategy(textBreakStrategy) + .setHyphenationFrequency(hyphenationFrequency); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + builder.setUseLineSpacingFromFallbacks(true); } + + layout = builder.build(); } return layout; } @@ -445,7 +420,7 @@ public static long measureText( // Android 11+ introduces changes in text width calculation which leads to cases // where the container is measured smaller than text. Math.ceil prevents it // See T136756103 for investigation - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.Q) { + if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { calculatedWidth = (float) Math.ceil(calculatedWidth); } From fb13b2ab92d74fbaf8f297096e365936944c1b80 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 29 Sep 2023 07:10:10 -0700 Subject: [PATCH 06/10] Remove support for Android API < 23 in ReactEditText Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class ReactEditText chnagelog: [Android][Breaking] Remove support for Android API < 23 in ReactEditText Differential Revision: D48545507 fbshipit-source-id: da6e758420305119d30e73cfc0b7a44efe90ecc7 --- .../react/views/textinput/ReactEditText.java | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 081f2b80160f2c..ecc6165f7244bf 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -9,8 +9,6 @@ import static com.facebook.react.uimanager.UIManagerHelper.getReactContext; -import android.content.ClipData; -import android.content.ClipboardManager; import android.content.Context; import android.graphics.Color; import android.graphics.Paint; @@ -210,9 +208,7 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { public void onDestroyActionMode(ActionMode mode) {} }; setCustomSelectionActionModeCallback(customActionModeCallback); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - setCustomInsertionActionModeCallback(customActionModeCallback); - } + setCustomInsertionActionModeCallback(customActionModeCallback); } @Override @@ -308,26 +304,7 @@ public InputConnection onCreateInputConnection(EditorInfo outAttrs) { @Override public boolean onTextContextMenuItem(int id) { if (id == android.R.id.paste) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - id = android.R.id.pasteAsPlainText; - } else { - ClipboardManager clipboard = - (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); - ClipData previousClipData = clipboard.getPrimaryClip(); - if (previousClipData != null) { - for (int i = 0; i < previousClipData.getItemCount(); i++) { - final CharSequence text = previousClipData.getItemAt(i).coerceToText(getContext()); - final CharSequence paste = (text instanceof Spanned) ? text.toString() : text; - if (paste != null) { - ClipData clipData = ClipData.newPlainText(null, text); - clipboard.setPrimaryClip(clipData); - } - } - boolean actionPerformed = super.onTextContextMenuItem(id); - clipboard.setPrimaryClip(previousClipData); - return actionPerformed; - } - } + id = android.R.id.pasteAsPlainText; } return super.onTextContextMenuItem(id); } @@ -702,10 +679,8 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) { } mDisableTextDiffing = false; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (getBreakStrategy() != reactTextUpdate.getTextBreakStrategy()) { - setBreakStrategy(reactTextUpdate.getTextBreakStrategy()); - } + if (getBreakStrategy() != reactTextUpdate.getTextBreakStrategy()) { + setBreakStrategy(reactTextUpdate.getTextBreakStrategy()); } // Update cached spans (in Fabric only). From 294948d8a2b5121226c172b1bf07033f34a56fa8 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 29 Sep 2023 07:10:10 -0700 Subject: [PATCH 07/10] Remove support for Android API < 23 in ReactTextInputLocalData Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class ReactTextInputLocalData chnagelog: [Android][Breaking] Remove support for Android API < 23 in ReactTextInputLocalData Differential Revision: D48545510 fbshipit-source-id: bd9004cf9f8b741ff0655555b8a9afa3f66f1594 --- .../views/textinput/ReactTextInputLocalData.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java index a85051068d2974..d8b60b38d1c7ea 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputLocalData.java @@ -7,7 +7,6 @@ package com.facebook.react.views.textinput; -import android.os.Build; import android.text.SpannableStringBuilder; import android.util.TypedValue; import android.widget.EditText; @@ -30,12 +29,7 @@ public ReactTextInputLocalData(EditText editText) { mPlaceholder = editText.getHint(); mMinLines = editText.getMinLines(); mMaxLines = editText.getMaxLines(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - mBreakStrategy = editText.getBreakStrategy(); - } else { - mBreakStrategy = 0; - } + mBreakStrategy = editText.getBreakStrategy(); } public void apply(EditText editText) { @@ -45,8 +39,6 @@ public void apply(EditText editText) { editText.setMaxLines(mMaxLines); editText.setInputType(mInputType); editText.setHint(mPlaceholder); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - editText.setBreakStrategy(mBreakStrategy); - } + editText.setBreakStrategy(mBreakStrategy); } } From 6c7cacee03cdd4bea5f527d2475b3a6c23e3b1c9 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 29 Sep 2023 07:10:10 -0700 Subject: [PATCH 08/10] Remove support for Android API < 23 in ReactTextInputShadowNode Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class ReactTextInputShadowNode chnagelog: [Android][Breaking] Remove support for Android API < 23 in ReactTextInputShadowNode Differential Revision: D48545503 fbshipit-source-id: 6ee922970c9983a2fba27028df02a3c63700d996 --- .../views/textinput/ReactTextInputShadowNode.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java index 8c123d7545b81b..878da5199174ca 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java @@ -7,8 +7,6 @@ package com.facebook.react.views.textinput; -import android.annotation.TargetApi; -import android.os.Build; import android.text.Layout; import android.util.TypedValue; import android.view.ViewGroup; @@ -35,7 +33,6 @@ import com.facebook.yoga.YogaNode; @VisibleForTesting -@TargetApi(Build.VERSION_CODES.M) public class ReactTextInputShadowNode extends ReactBaseTextShadowNode implements YogaMeasureFunction { @@ -53,10 +50,7 @@ public class ReactTextInputShadowNode extends ReactBaseTextShadowNode public ReactTextInputShadowNode( @Nullable ReactTextViewManagerCallback reactTextViewManagerCallback) { super(reactTextViewManagerCallback); - mTextBreakStrategy = - (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) - ? Layout.BREAK_STRATEGY_SIMPLE - : Layout.BREAK_STRATEGY_HIGH_QUALITY; + mTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY; initMeasureFunction(); } @@ -118,8 +112,7 @@ public long measure( editText.setLines(mNumberOfLines); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M - && editText.getBreakStrategy() != mTextBreakStrategy) { + if (editText.getBreakStrategy() != mTextBreakStrategy) { editText.setBreakStrategy(mTextBreakStrategy); } } @@ -182,10 +175,6 @@ public void setPlaceholder(@Nullable String placeholder) { @Override public void setTextBreakStrategy(@Nullable String textBreakStrategy) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - return; - } - if (textBreakStrategy == null || "simple".equals(textBreakStrategy)) { mTextBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE; } else if ("highQuality".equals(textBreakStrategy)) { From fd0641068e6a14c13ad095fcdb7db48a946f0a7e Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 29 Sep 2023 07:10:10 -0700 Subject: [PATCH 09/10] Remove support for Android API < 23 in ReactDrawableHelper Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class ReactDrawableHelper chnagelog: [Android][Breaking] Remove support for Android API < 23 in ReactDrawableHelper Differential Revision: D48545508 fbshipit-source-id: ca98c4dae65101dca78ac78bd5af7950fe5167a9 --- .../com/facebook/react/views/view/ReactDrawableHelper.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java index 2c6107e47358f4..e67e2f74d21f77 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java @@ -13,7 +13,6 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.RippleDrawable; -import android.os.Build; import android.util.TypedValue; import androidx.annotation.Nullable; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; @@ -76,9 +75,7 @@ private static RippleDrawable getRippleDrawable( } private static Drawable setRadius(ReadableMap drawableDescriptionDict, Drawable drawable) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M - && drawableDescriptionDict.hasKey("rippleRadius") - && drawable instanceof RippleDrawable) { + if (drawableDescriptionDict.hasKey("rippleRadius") && drawable instanceof RippleDrawable) { RippleDrawable rippleDrawable = (RippleDrawable) drawable; double rippleRadius = drawableDescriptionDict.getDouble("rippleRadius"); rippleDrawable.setRadius((int) PixelUtil.toPixelFromDIP(rippleRadius)); From 64ad64a2fb6f38063a5896063fce06b5e4cf8efb Mon Sep 17 00:00:00 2001 From: David Vacca <515103+mdvacca@users.noreply.github.com> Date: Fri, 29 Sep 2023 07:13:45 -0700 Subject: [PATCH 10/10] Remove support for Android API < 23 in ReactViewManager (#39678) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39678 Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class ReactViewManager changelog: [Android][Breaking] Remove support for Android API < 23 in ReactViewManager Reviewed By: NickGerleman Differential Revision: D48545513 fbshipit-source-id: 792826fd44e756afcd4659a95212e82f256525e3 --- .../java/com/facebook/react/views/view/ReactViewManager.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java index 7f3a931e964f0b..dde735192aafa6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java @@ -7,9 +7,7 @@ package com.facebook.react.views.view; -import android.annotation.TargetApi; import android.graphics.Rect; -import android.os.Build; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -203,7 +201,6 @@ public void setNativeBackground(ReactViewGroup view, @Nullable ReadableMap bg) { : ReactDrawableHelper.createDrawableFromJSDescription(view.getContext(), bg)); } - @TargetApi(Build.VERSION_CODES.M) @ReactProp(name = "nativeForegroundAndroid") public void setNativeForeground(ReactViewGroup view, @Nullable ReadableMap fg) { view.setForeground(