Skip to content

Commit 7d8aeb4

Browse files
fabOnReactfacebook-github-bot
authored andcommitted
do not call setHyphenationFrequency on AndroidSdk < 23 (#29258)
Summary: JoshuaGross This issue fixes #28279 as discussed in #29157 (comment) Avoid calling [setHyphenationFrequency](https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int)) on Android Sdk < 23. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [Android] [Fixed] - do not call setHyphenationFrequency on AndroidSdk < 23 Pull Request resolved: #29258 Test Plan: | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | <img src="https://user-images.githubusercontent.com/24992535/86214122-05bf0e00-bb7b-11ea-93b5-2174812bfec9.png" width="300" height="" />| <img src="https://user-images.githubusercontent.com/24992535/86214130-08216800-bb7b-11ea-9fc0-68b28638bf57.png" width="300" height="" /> | The warning displayed with `adb logcat | grep -P "ReactTextAnchorViewManager"` ![image](https://user-images.githubusercontent.com/24992535/86214242-34d57f80-bb7b-11ea-9945-30ae25332bfb.png) I remain available to do improvements. Thanks a lot. Fabrizio. Reviewed By: JoshuaGross Differential Revision: D22337095 Pulled By: mdvacca fbshipit-source-id: d0943397af180929c48044ccbc7a9388549021b8
1 parent c6b9cc3 commit 7d8aeb4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java

+7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
package com.facebook.react.views.text;
99

10+
import android.os.Build;
1011
import android.text.Layout;
1112
import android.text.Spannable;
1213
import android.text.TextUtils;
1314
import android.text.util.Linkify;
1415
import android.view.Gravity;
1516
import android.view.View;
1617
import androidx.annotation.Nullable;
18+
import com.facebook.common.logging.FLog;
1719
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
1820
import com.facebook.react.uimanager.BaseViewManager;
1921
import com.facebook.react.uimanager.PixelUtil;
@@ -39,6 +41,7 @@ public abstract class ReactTextAnchorViewManager<T extends View, C extends React
3941
private static final int[] SPACING_TYPES = {
4042
Spacing.ALL, Spacing.LEFT, Spacing.RIGHT, Spacing.TOP, Spacing.BOTTOM,
4143
};
44+
private static final String TAG = "ReactTextAnchorViewManager";
4245

4346
// maxLines can only be set in master view (block), doesn't really make sense to set in a span
4447
@ReactProp(name = ViewProps.NUMBER_OF_LINES, defaultInt = ViewDefaults.NUMBER_OF_LINES)
@@ -99,6 +102,10 @@ public void setSelectionColor(ReactTextView view, @Nullable Integer color) {
99102

100103
@ReactProp(name = "android_hyphenationFrequency")
101104
public void setAndroidHyphenationFrequency(ReactTextView view, @Nullable String frequency) {
105+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
106+
FLog.w(TAG, "android_hyphenationFrequency only available since android 23");
107+
return;
108+
}
102109
if (frequency == null || frequency.equals("none")) {
103110
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE);
104111
} else if (frequency.equals("full")) {

0 commit comments

Comments
 (0)