Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for Android API < 23 in ReactTextAnchorViewManager #39676

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

package com.facebook.react.views.text;

import android.os.Build;
import android.text.Layout;
import android.text.Spannable;
import android.text.TextUtils;
Expand Down Expand Up @@ -118,10 +117,6 @@ public void setSelectionColor(ReactTextView view, @Nullable Integer color) {

@ReactProp(name = "android_hyphenationFrequency")
public void setAndroidHyphenationFrequency(ReactTextView view, @Nullable String frequency) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
FLog.w(TAG, "android_hyphenationFrequency only available since android 23");
return;
}
if (frequency == null || frequency.equals("none")) {
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE);
} else if (frequency.equals("full")) {
Expand Down