From a38e30562df00f000e20ca90a117d526bfdadce9 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 26 Sep 2023 13:43:25 -0700 Subject: [PATCH] Remove support for Android API < 23 in ReactBaseTextShadowNode Summary: Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class ReactBaseTextShadowNode chnagelog: [Android][Breaking] Remove support for Android API < 23 in ReactBaseTextShadowNode Differential Revision: D48545509 fbshipit-source-id: 41ddd0ea43afd4505080ae48a20067e514ccd0fe --- .../views/text/ReactBaseTextShadowNode.java | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java index d2c2d6e7b80ba4..cb02e705da57ae 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java @@ -7,7 +7,6 @@ package com.facebook.react.views.text; -import android.annotation.TargetApi; import android.graphics.Color; import android.graphics.Typeface; import android.os.Build; @@ -50,7 +49,6 @@ *

This also node calculates {@link Spannable} object based on subnodes of the same type, which * can be used in concrete classes to feed native views and compute layout. */ -@TargetApi(Build.VERSION_CODES.M) public abstract class ReactBaseTextShadowNode extends LayoutShadowNode { // Use a direction weak character so the placeholder doesn't change the direction of the previous @@ -75,9 +73,9 @@ private static void buildSpannedFromShadowNode( ReactBaseTextShadowNode textShadowNode, SpannableStringBuilder sb, List ops, - TextAttributes parentTextAttributes, + @Nullable TextAttributes parentTextAttributes, boolean supportsInlineViews, - Map inlineViews, + @Nullable Map inlineViews, int start) { TextAttributes textAttributes; @@ -226,7 +224,7 @@ private static void buildSpannedFromShadowNode( // `nativeViewHierarchyOptimizer` can be `null` as long as `supportsInlineViews` is `false`. protected Spannable spannedFromShadowNode( ReactBaseTextShadowNode textShadowNode, - String text, + @Nullable String text, boolean supportsInlineViews, NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) { Assertions.assertCondition( @@ -240,8 +238,7 @@ protected Spannable spannedFromShadowNode( // up-to-bottom, otherwise all the spannables that are within the region for which one may set // a new spannable will be wiped out List ops = new ArrayList<>(); - Map inlineViews = - supportsInlineViews ? new HashMap() : null; + Map inlineViews = supportsInlineViews ? new HashMap<>() : null; if (text != null) { // Handle text that is provided via a prop (e.g. the `value` and `defaultValue` props on @@ -312,10 +309,8 @@ protected Spannable spannedFromShadowNode( protected int mNumberOfLines = UNSET; protected int mTextAlign = Gravity.NO_GRAVITY; - protected int mTextBreakStrategy = - (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY; - protected int mHyphenationFrequency = - (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.HYPHENATION_FREQUENCY_NONE; + protected int mTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY; + protected int mHyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE; protected int mJustificationMode = (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) ? 0 : Layout.JUSTIFICATION_MODE_NONE; @@ -554,10 +549,6 @@ public void setTextDecorationLine(@Nullable String textDecorationLineString) { @ReactProp(name = ViewProps.TEXT_BREAK_STRATEGY) public void setTextBreakStrategy(@Nullable String textBreakStrategy) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - return; - } - if (textBreakStrategy == null || "highQuality".equals(textBreakStrategy)) { mTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY; } else if ("simple".equals(textBreakStrategy)) {