Skip to content

Commit c35dcb3

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Remove support for Android API < 23 in TextLayoutManagerMapBuffer (#39677)
Summary: Pull Request resolved: #39677 Since minsdk version was increased to 23, we are deleting code using Android APIs < 23 for class TextLayoutManagerMapBuffer bypass-github-export-checks changelog: [Android][Breaking] Remove support for Android API < 23 in TextLayoutManagerMapBuffer Reviewed By: NickGerleman Differential Revision: D48545518 fbshipit-source-id: fe64730c40ddf42aab0a7f5a19e51eecea4c4bcd
1 parent 4a563f3 commit c35dcb3

File tree

1 file changed

+21
-46
lines changed

1 file changed

+21
-46
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -299,26 +299,14 @@ private static Layout createLayout(
299299
// unicode characters.
300300

301301
int hintWidth = (int) Math.ceil(desiredWidth);
302-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
303-
layout =
304-
new StaticLayout(
305-
text,
306-
sTextPaintInstance,
307-
hintWidth,
308-
Layout.Alignment.ALIGN_NORMAL,
309-
1.f,
310-
0.f,
311-
includeFontPadding);
312-
} else {
313-
layout =
314-
StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, hintWidth)
315-
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
316-
.setLineSpacing(0.f, 1.f)
317-
.setIncludePad(includeFontPadding)
318-
.setBreakStrategy(textBreakStrategy)
319-
.setHyphenationFrequency(hyphenationFrequency)
320-
.build();
321-
}
302+
layout =
303+
StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, hintWidth)
304+
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
305+
.setLineSpacing(0.f, 1.f)
306+
.setIncludePad(includeFontPadding)
307+
.setBreakStrategy(textBreakStrategy)
308+
.setHyphenationFrequency(hyphenationFrequency)
309+
.build();
322310

323311
} else if (boring != null && (unconstrainedWidth || boring.width <= width)) {
324312
int boringLayoutWidth = boring.width;
@@ -341,32 +329,19 @@ private static Layout createLayout(
341329
includeFontPadding);
342330
} else {
343331
// Is used for multiline, boring text and the width is known.
344-
345-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
346-
layout =
347-
new StaticLayout(
348-
text,
349-
sTextPaintInstance,
350-
(int) width,
351-
Layout.Alignment.ALIGN_NORMAL,
352-
1.f,
353-
0.f,
354-
includeFontPadding);
355-
} else {
356-
StaticLayout.Builder builder =
357-
StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, (int) width)
358-
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
359-
.setLineSpacing(0.f, 1.f)
360-
.setIncludePad(includeFontPadding)
361-
.setBreakStrategy(textBreakStrategy)
362-
.setHyphenationFrequency(hyphenationFrequency);
363-
364-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
365-
builder.setUseLineSpacingFromFallbacks(true);
366-
}
367-
368-
layout = builder.build();
332+
StaticLayout.Builder builder =
333+
StaticLayout.Builder.obtain(text, 0, spanLength, sTextPaintInstance, (int) width)
334+
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
335+
.setLineSpacing(0.f, 1.f)
336+
.setIncludePad(includeFontPadding)
337+
.setBreakStrategy(textBreakStrategy)
338+
.setHyphenationFrequency(hyphenationFrequency);
339+
340+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
341+
builder.setUseLineSpacingFromFallbacks(true);
369342
}
343+
344+
layout = builder.build();
370345
}
371346
return layout;
372347
}
@@ -445,7 +420,7 @@ public static long measureText(
445420
// Android 11+ introduces changes in text width calculation which leads to cases
446421
// where the container is measured smaller than text. Math.ceil prevents it
447422
// See T136756103 for investigation
448-
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.Q) {
423+
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
449424
calculatedWidth = (float) Math.ceil(calculatedWidth);
450425
}
451426

0 commit comments

Comments
 (0)