diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java index d5fced0d4b0..15719809e79 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java @@ -12,6 +12,7 @@ import android.text.Layout; import android.text.Spannable; import androidx.annotation.Nullable; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.bridge.ReadableNativeMap; import com.facebook.react.common.MapBuilder; import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.module.annotations.ReactModule; @@ -77,7 +78,9 @@ public class ReactTextViewManager public Object updateState( ReactTextView view, ReactStylesDiffMap props, @Nullable StateWrapper stateWrapper) { // TODO T55794595: Add support for updating state with null stateWrapper - ReadableMap attributedString = stateWrapper.getState().getMap("attributedString"); + ReadableNativeMap state = stateWrapper.getState(); + ReadableMap attributedString = state.getMap("attributedString"); + ReadableMap paragraphAttributes = state.getMap("paragraphAttributes"); Spannable spanned = TextLayoutManager.getOrCreateSpannableForText(view.getContext(), attributedString); @@ -85,8 +88,8 @@ public class ReactTextViewManager TextAttributeProps textViewProps = new TextAttributeProps(props); - // TODO add textBreakStrategy prop into local Data - int textBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY; + int textBreakStrategy = + getTextBreakStrategy(paragraphAttributes.getString("textBreakStrategy")); // TODO add justificationMode prop into local Data int justificationMode = Layout.JUSTIFICATION_MODE_NONE; @@ -104,6 +107,24 @@ public class ReactTextViewManager justificationMode); } + private int getTextBreakStrategy(@Nullable String textBreakStrategy) { + int androidTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY; + if (textBreakStrategy != null) { + switch (textBreakStrategy) { + case "simple": + androidTextBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE; + break; + case "balanced": + androidTextBreakStrategy = Layout.BREAK_STRATEGY_BALANCED; + break; + default: + androidTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY; + break; + } + } + return androidTextBreakStrategy; + } + @Override public @Nullable Map getExportedCustomDirectEventTypeConstants() { return MapBuilder.of(