From bbd0f03481c23b295797abd1089d5688b0d22bb9 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Mon, 16 Nov 2020 12:38:28 -0800 Subject: [PATCH] Removing pre-API 21 code Summary: We don't support pre-API 21/Android <5/pre-Lollipop anymore; delete related code or checks. No need for this to make it to the changelog, this announcement was already made. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D24965249 fbshipit-source-id: e537e62e8eb18878c29afe17b8c7861d095a37b7 --- .../views/text/ReactBaseTextShadowNode.java | 15 ++++++--------- .../react/views/text/TextLayoutManager.java | 10 ++++------ .../react/views/textinput/ReactEditText.java | 18 +++++++----------- .../react/views/view/ReactDrawableHelper.java | 6 +----- 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java index 6835918b587..f685bf567b2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java @@ -178,15 +178,12 @@ public abstract class ReactBaseTextShadowNode extends LayoutShadowNode { new SetSpanOperation( start, end, new ReactBackgroundColorSpan(textShadowNode.mBackgroundColor))); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - float effectiveLetterSpacing = textAttributes.getEffectiveLetterSpacing(); - if (!Float.isNaN(effectiveLetterSpacing) - && (parentTextAttributes == null - || parentTextAttributes.getEffectiveLetterSpacing() != effectiveLetterSpacing)) { - ops.add( - new SetSpanOperation( - start, end, new CustomLetterSpacingSpan(effectiveLetterSpacing))); - } + float effectiveLetterSpacing = textAttributes.getEffectiveLetterSpacing(); + if (!Float.isNaN(effectiveLetterSpacing) + && (parentTextAttributes == null + || parentTextAttributes.getEffectiveLetterSpacing() != effectiveLetterSpacing)) { + ops.add( + new SetSpanOperation(start, end, new CustomLetterSpacingSpan(effectiveLetterSpacing))); } int effectiveFontSize = textAttributes.getEffectiveFontSize(); if ( // `getEffectiveFontSize` always returns a value so don't need to check for anything like diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index 3b10c2c7d1c..a322eaa7ad4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -139,12 +139,10 @@ public class TextLayoutManager { new SetSpanOperation( start, end, new ReactBackgroundColorSpan(textAttributes.mBackgroundColor))); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - if (!Float.isNaN(textAttributes.getLetterSpacing())) { - ops.add( - new SetSpanOperation( - start, end, new CustomLetterSpacingSpan(textAttributes.getLetterSpacing()))); - } + if (!Float.isNaN(textAttributes.getLetterSpacing())) { + ops.add( + new SetSpanOperation( + start, end, new CustomLetterSpacingSpan(textAttributes.getLetterSpacing()))); } ops.add( new SetSpanOperation(start, end, new ReactAbsoluteSizeSpan(textAttributes.mFontSize))); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 058e154849d..f908681034f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -654,12 +654,10 @@ public class ReactEditText extends AppCompatEditText List ops = new ArrayList<>(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - if (!Float.isNaN(mTextAttributes.getLetterSpacing())) { - ops.add( - new TextLayoutManager.SetSpanOperation( - start, end, new CustomLetterSpacingSpan(mTextAttributes.getLetterSpacing()))); - } + if (!Float.isNaN(mTextAttributes.getLetterSpacing())) { + ops.add( + new TextLayoutManager.SetSpanOperation( + start, end, new CustomLetterSpacingSpan(mTextAttributes.getLetterSpacing()))); } ops.add( new TextLayoutManager.SetSpanOperation( @@ -947,11 +945,9 @@ public class ReactEditText extends AppCompatEditText // `Float.NaN`. setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextAttributes.getEffectiveFontSize()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - float effectiveLetterSpacing = mTextAttributes.getEffectiveLetterSpacing(); - if (!Float.isNaN(effectiveLetterSpacing)) { - setLetterSpacing(effectiveLetterSpacing); - } + float effectiveLetterSpacing = mTextAttributes.getEffectiveLetterSpacing(); + if (!Float.isNaN(effectiveLetterSpacing)) { + setLetterSpacing(effectiveLetterSpacing); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java index 8f5f8267330..b4a3feb9418 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.java @@ -65,11 +65,7 @@ public class ReactDrawableHelper { } private static Drawable getDefaultThemeDrawable(Context context) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - return context.getResources().getDrawable(sResolveOutValue.resourceId, context.getTheme()); - } else { - return context.getResources().getDrawable(sResolveOutValue.resourceId); - } + return context.getResources().getDrawable(sResolveOutValue.resourceId, context.getTheme()); } private static RippleDrawable getRippleDrawable(