Skip to content

Commit

Permalink
Remove support for Android API < 23 in ReactBaseTextShadowNode (#39665)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39665

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

Reviewed By: NickGerleman

Differential Revision: D48545509

fbshipit-source-id: 456005c6d2d7a2e111811ee16f535c8ed3bf774b
  • Loading branch information
mdvacca committed Sep 26, 2023
1 parent bd4db26 commit a7a837f
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,7 +49,6 @@
* <p>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
Expand All @@ -75,9 +73,9 @@ private static void buildSpannedFromShadowNode(
ReactBaseTextShadowNode textShadowNode,
SpannableStringBuilder sb,
List<SetSpanOperation> ops,
TextAttributes parentTextAttributes,
@Nullable TextAttributes parentTextAttributes,
boolean supportsInlineViews,
Map<Integer, ReactShadowNode> inlineViews,
@Nullable Map<Integer, ReactShadowNode> inlineViews,
int start) {

TextAttributes textAttributes;
Expand Down Expand Up @@ -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(
Expand All @@ -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<SetSpanOperation> ops = new ArrayList<>();
Map<Integer, ReactShadowNode> inlineViews =
supportsInlineViews ? new HashMap<Integer, ReactShadowNode>() : null;
Map<Integer, ReactShadowNode> inlineViews = supportsInlineViews ? new HashMap<>() : null;

if (text != null) {
// Handle text that is provided via a prop (e.g. the `value` and `defaultValue` props on
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit a7a837f

Please sign in to comment.