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

[Android] do not call setHyphenationFrequency on AndroidSdk < 23 #29258

Closed
Closed
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,6 +7,7 @@

package com.facebook.react.views.text;

import android.os.Build;
import android.text.Layout;
import android.text.Spannable;
import android.text.TextUtils;
Expand All @@ -23,6 +24,7 @@
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.annotations.ReactPropGroup;
import com.facebook.yoga.YogaConstants;
import com.facebook.common.logging.FLog;

/**
* Abstract class for anchor {@code <Text>}-ish spannable views, such as {@link TextView} or {@link
Expand All @@ -39,6 +41,7 @@ public abstract class ReactTextAnchorViewManager<T extends View, C extends React
private static final int[] SPACING_TYPES = {
Spacing.ALL, Spacing.LEFT, Spacing.RIGHT, Spacing.TOP, Spacing.BOTTOM,
};
private static final String TAG = "ReactTextAnchorViewManager";

// maxLines can only be set in master view (block), doesn't really make sense to set in a span
@ReactProp(name = ViewProps.NUMBER_OF_LINES, defaultInt = ViewDefaults.NUMBER_OF_LINES)
Expand Down Expand Up @@ -99,6 +102,10 @@ 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