diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java index 8ecb0d81f44168..81f4a24c0c4ce2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule.java @@ -79,10 +79,7 @@ public AccessibilityInfoModule(ReactApplicationContext context) { mContentResolver = getReactApplicationContext().getContentResolver(); mTouchExplorationEnabled = mAccessibilityManager.isTouchExplorationEnabled(); mReduceMotionEnabled = this.getIsReduceMotionEnabledValue(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - mTouchExplorationStateChangeListener = new ReactTouchExplorationStateChangeListener(); - } + mTouchExplorationStateChangeListener = new ReactTouchExplorationStateChangeListener(); } @Override @@ -142,10 +139,8 @@ public void onHostResume() { mAccessibilityManager.addTouchExplorationStateChangeListener( mTouchExplorationStateChangeListener); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - Uri transitionUri = Settings.Global.getUriFor(Settings.Global.TRANSITION_ANIMATION_SCALE); - mContentResolver.registerContentObserver(transitionUri, false, animationScaleObserver); - } + Uri transitionUri = Settings.Global.getUriFor(Settings.Global.TRANSITION_ANIMATION_SCALE); + mContentResolver.registerContentObserver(transitionUri, false, animationScaleObserver); updateAndSendTouchExplorationChangeEvent(mAccessibilityManager.isTouchExplorationEnabled()); updateAndSendReduceMotionChangeEvent(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java index 29131862c1dbc7..f3d190b4432e22 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java @@ -15,7 +15,6 @@ import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; import android.graphics.drawable.ColorDrawable; -import android.os.Build; import android.os.Bundle; import android.widget.DatePicker; import androidx.annotation.Nullable; @@ -57,52 +56,37 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { DatePickerDialog dialog = null; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - switch (mode) { - case CALENDAR: - dialog = - new DismissableDatePickerDialog( - activityContext, - activityContext - .getResources() - .getIdentifier( - "CalendarDatePickerDialog", "style", activityContext.getPackageName()), - onDateSetListener, - year, - month, - day); - break; - case SPINNER: - dialog = - new DismissableDatePickerDialog( - activityContext, - android.R.style.Theme_Holo_Light_Dialog, - onDateSetListener, - year, - month, - day); - dialog - .getWindow() - .setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); - break; - case DEFAULT: - dialog = - new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day); - break; - } - } else { - dialog = - new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day); - - switch (mode) { - case CALENDAR: - dialog.getDatePicker().setCalendarViewShown(true); - dialog.getDatePicker().setSpinnersShown(false); - break; - case SPINNER: - dialog.getDatePicker().setCalendarViewShown(false); - break; - } + switch (mode) { + case CALENDAR: + dialog = + new DismissableDatePickerDialog( + activityContext, + activityContext + .getResources() + .getIdentifier( + "CalendarDatePickerDialog", "style", activityContext.getPackageName()), + onDateSetListener, + year, + month, + day); + break; + case SPINNER: + dialog = + new DismissableDatePickerDialog( + activityContext, + android.R.style.Theme_Holo_Light_Dialog, + onDateSetListener, + year, + month, + day); + dialog + .getWindow() + .setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); + break; + case DEFAULT: + dialog = + new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day); + break; } final DatePicker datePicker = dialog.getDatePicker(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java index b1e089921ee4d7..fc5cf31aeef772 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java @@ -50,9 +50,7 @@ public DismissableDatePickerDialog( protected void onStop() { // do *not* call super.onStop() on KitKat on lower, as that would erroneously call the // OnDateSetListener when the dialog is dismissed, or call it twice when "OK" is pressed. - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - super.onStop(); - } + super.onStop(); } private void fixSpinner(Context context, int year, int month, int dayOfMonth) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java index d1fce6275e5e7f..1fc82bd357d7a9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java @@ -15,12 +15,10 @@ import android.os.Message; import android.text.TextUtils; import android.webkit.CookieManager; -import android.webkit.CookieSyncManager; import android.webkit.ValueCallback; import androidx.annotation.Nullable; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.GuardedAsyncTask; -import com.facebook.react.bridge.GuardedResultAsyncTask; import com.facebook.react.bridge.ReactContext; import java.io.IOException; import java.net.CookieHandler; @@ -40,10 +38,6 @@ public class ForwardingCookieHandler extends CookieHandler { private static final String VERSION_ONE_HEADER = "Set-cookie2"; private static final String COOKIE_HEADER = "Cookie"; - // As CookieManager was synchronous before API 21 this class emulates the async behavior on < 21. - private static final boolean USES_LEGACY_STORE = - Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP; - private final CookieSaver mCookieSaver; private final ReactContext mContext; private @Nullable CookieManager mCookieManager; @@ -79,26 +73,7 @@ public void put(URI uri, Map> headers) throws IOException { } public void clearCookies(final Callback callback) { - if (USES_LEGACY_STORE) { - new GuardedResultAsyncTask(mContext) { - @Override - protected Boolean doInBackgroundGuarded() { - CookieManager cookieManager = getCookieManager(); - if (cookieManager != null) { - cookieManager.removeAllCookie(); - } - mCookieSaver.onCookiesModified(); - return true; - } - - @Override - protected void onPostExecuteGuarded(Boolean result) { - callback.invoke(result); - } - }.execute(); - } else { - clearCookiesAsync(callback); - } + clearCookiesAsync(callback); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) @@ -116,38 +91,17 @@ public void onReceiveValue(Boolean value) { } } - public void destroy() { - if (USES_LEGACY_STORE) { - CookieManager cookieManager = getCookieManager(); - if (cookieManager != null) { - cookieManager.removeExpiredCookie(); - } - mCookieSaver.persistCookies(); - } - } + public void destroy() {} public void addCookies(final String url, final List cookies) { final CookieManager cookieManager = getCookieManager(); if (cookieManager == null) return; - if (USES_LEGACY_STORE) { - runInBackground( - new Runnable() { - @Override - public void run() { - for (String cookie : cookies) { - cookieManager.setCookie(url, cookie); - } - mCookieSaver.onCookiesModified(); - } - }); - } else { - for (String cookie : cookies) { - addCookieAsync(url, cookie); - } - cookieManager.flush(); - mCookieSaver.onCookiesModified(); + for (String cookie : cookies) { + addCookieAsync(url, cookie); } + cookieManager.flush(); + mCookieSaver.onCookiesModified(); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) @@ -199,24 +153,12 @@ protected void doInBackgroundGuarded(Void... params) { throw exception; } } - - if (USES_LEGACY_STORE) { - mCookieManager.removeExpiredCookie(); - } } return mCookieManager; } - private static void possiblyWorkaroundSyncManager(Context context) { - if (USES_LEGACY_STORE) { - // This is to work around a bug where CookieManager may fail to instantiate if - // CookieSyncManager has never been created. Note that the sync() may not be required but is - // here of legacy reasons. - CookieSyncManager syncManager = CookieSyncManager.createInstance(context); - syncManager.sync(); - } - } + private static void possiblyWorkaroundSyncManager(Context context) {} /** * Responsible for flushing cookies to disk. Flushes to disk with a maximum delay of 30 seconds. @@ -246,11 +188,7 @@ public boolean handleMessage(Message msg) { }); } - public void onCookiesModified() { - if (USES_LEGACY_STORE) { - mHandler.sendEmptyMessageDelayed(MSG_PERSIST_COOKIES, TIMEOUT); - } - } + public void onCookiesModified() {} public void persistCookies() { mHandler.removeMessages(MSG_PERSIST_COOKIES); @@ -258,12 +196,7 @@ public void persistCookies() { new Runnable() { @Override public void run() { - if (USES_LEGACY_STORE) { - CookieSyncManager syncManager = CookieSyncManager.getInstance(); - syncManager.sync(); - } else { - flush(); - } + flush(); } }); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/OkHttpClientProvider.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/OkHttpClientProvider.java index 5515eeb8d95683..38b2a0f961294d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/OkHttpClientProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/OkHttpClientProvider.java @@ -8,19 +8,13 @@ package com.facebook.react.modules.network; import android.content.Context; -import android.os.Build; import androidx.annotation.Nullable; -import com.facebook.common.logging.FLog; import java.io.File; import java.security.Provider; import java.security.Security; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.TimeUnit; import okhttp3.Cache; -import okhttp3.ConnectionSpec; import okhttp3.OkHttpClient; -import okhttp3.TlsVersion; /** * Helper class that provides the same OkHttpClient instance that will be used for all networking @@ -101,26 +95,6 @@ public static OkHttpClient.Builder createClientBuilder(Context context, int cach enables it. */ public static OkHttpClient.Builder enableTls12OnPreLollipop(OkHttpClient.Builder client) { - if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { - try { - client.sslSocketFactory(new TLSSocketFactory()); - - ConnectionSpec cs = - new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) - .tlsVersions(TlsVersion.TLS_1_2) - .build(); - - List specs = new ArrayList<>(); - specs.add(cs); - specs.add(ConnectionSpec.COMPATIBLE_TLS); - specs.add(ConnectionSpec.CLEARTEXT); - - client.connectionSpecs(specs); - } catch (Exception ex) { - FLog.e("OkHttpClientProvider", "Error while enabling TLS 1.2", ex); - } - } - return client; } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java index 1898a62a127b33..b4a4e80e68485e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java @@ -60,7 +60,7 @@ public String getName() { : 0; String statusBarColorString = "black"; - if (activity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (activity != null) { final int statusBarColor = activity.getWindow().getStatusBarColor(); statusBarColorString = String.format("#%06X", (0xFFFFFF & statusBarColor)); } @@ -81,38 +81,33 @@ public void setColor(final double colorDouble, final boolean animated) { return; } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - - UiThreadUtil.runOnUiThread( - new GuardedRunnable(getReactApplicationContext()) { - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - @Override - public void runGuarded() { - activity - .getWindow() - .addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - if (animated) { - int curColor = activity.getWindow().getStatusBarColor(); - ValueAnimator colorAnimation = - ValueAnimator.ofObject(new ArgbEvaluator(), curColor, color); - - colorAnimation.addUpdateListener( - new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animator) { - activity - .getWindow() - .setStatusBarColor((Integer) animator.getAnimatedValue()); - } - }); - colorAnimation.setDuration(300).setStartDelay(0); - colorAnimation.start(); - } else { - activity.getWindow().setStatusBarColor(color); - } + UiThreadUtil.runOnUiThread( + new GuardedRunnable(getReactApplicationContext()) { + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + public void runGuarded() { + activity + .getWindow() + .addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + if (animated) { + int curColor = activity.getWindow().getStatusBarColor(); + ValueAnimator colorAnimation = + ValueAnimator.ofObject(new ArgbEvaluator(), curColor, color); + + colorAnimation.addUpdateListener( + new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animator) { + activity.getWindow().setStatusBarColor((Integer) animator.getAnimatedValue()); + } + }); + colorAnimation.setDuration(300).setStartDelay(0); + colorAnimation.start(); + } else { + activity.getWindow().setStatusBarColor(color); } - }); - } + } + }); } @Override @@ -125,36 +120,34 @@ public void setTranslucent(final boolean translucent) { return; } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - UiThreadUtil.runOnUiThread( - new GuardedRunnable(getReactApplicationContext()) { - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - @Override - public void runGuarded() { - // If the status bar is translucent hook into the window insets calculations - // and consume all the top insets so no padding will be added under the status bar. - View decorView = activity.getWindow().getDecorView(); - if (translucent) { - decorView.setOnApplyWindowInsetsListener( - new View.OnApplyWindowInsetsListener() { - @Override - public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { - WindowInsets defaultInsets = v.onApplyWindowInsets(insets); - return defaultInsets.replaceSystemWindowInsets( - defaultInsets.getSystemWindowInsetLeft(), - 0, - defaultInsets.getSystemWindowInsetRight(), - defaultInsets.getSystemWindowInsetBottom()); - } - }); - } else { - decorView.setOnApplyWindowInsetsListener(null); - } - - ViewCompat.requestApplyInsets(decorView); + UiThreadUtil.runOnUiThread( + new GuardedRunnable(getReactApplicationContext()) { + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + @Override + public void runGuarded() { + // If the status bar is translucent hook into the window insets calculations + // and consume all the top insets so no padding will be added under the status bar. + View decorView = activity.getWindow().getDecorView(); + if (translucent) { + decorView.setOnApplyWindowInsetsListener( + new View.OnApplyWindowInsetsListener() { + @Override + public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { + WindowInsets defaultInsets = v.onApplyWindowInsets(insets); + return defaultInsets.replaceSystemWindowInsets( + defaultInsets.getSystemWindowInsetLeft(), + 0, + defaultInsets.getSystemWindowInsetRight(), + defaultInsets.getSystemWindowInsetBottom()); + } + }); + } else { + decorView.setOnApplyWindowInsetsListener(null); } - }); - } + + ViewCompat.requestApplyInsets(decorView); + } + }); } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java index 2028bdb6082536..7ab93dc676f313 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java @@ -183,8 +183,7 @@ public void setViewState(@NonNull T view, @Nullable ReadableMap accessibilitySta && accessibilityState.getType(STATE_CHECKED) == ReadableType.String)) { updateViewContentDescription(view); break; - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP - && view.isAccessibilityFocused()) { + } else if (view.isAccessibilityFocused()) { // Internally Talkback ONLY uses TYPE_VIEW_CLICKED for "checked" and // "selected" announcements. Send a click event to make sure Talkback // get notified for the state changes that don't happen upon users' click. diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.java index b629caa15155ef..8ecd9cdf94221a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.java @@ -8,17 +8,12 @@ package com.facebook.react.uimanager; import android.content.Context; -import android.os.Build; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; import androidx.annotation.Nullable; -import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.WritableNativeMap; -import com.facebook.react.common.ReactConstants; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; @@ -65,32 +60,7 @@ public static void initDisplayMetrics(Context context) { // // See: // http://developer.android.com/reference/android/view/Display.html#getRealMetrics(android.util.DisplayMetrics) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - display.getRealMetrics(screenDisplayMetrics); - } else { - // For 14 <= API level <= 16, we need to invoke getRawHeight and getRawWidth to get the real - // dimensions. - // Since react-native only supports API level 16+ we don't have to worry about other cases. - // - // Reflection exceptions are rethrown at runtime. - // - // See: - // http://stackoverflow.com/questions/14341041/how-to-get-real-screen-height-and-width/23861333#23861333 - try { - Method mGetRawH = Display.class.getMethod("getRawHeight"); - Method mGetRawW = Display.class.getMethod("getRawWidth"); - screenDisplayMetrics.widthPixels = (Integer) mGetRawW.invoke(display); - screenDisplayMetrics.heightPixels = (Integer) mGetRawH.invoke(display); - } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { - // this may not be 100% accurate, but it's all we've got - screenDisplayMetrics.widthPixels = display.getWidth(); - screenDisplayMetrics.heightPixels = display.getHeight(); - FLog.e( - ReactConstants.TAG, - "Unable to access getRawHeight and getRawWidth to get real dimensions.", - e); - } - } + display.getRealMetrics(screenDisplayMetrics); DisplayMetricsHolder.setScreenDisplayMetrics(screenDisplayMetrics); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/CustomStyleSpan.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/CustomStyleSpan.java index 1becdbacaf63d9..cf0c8b141b0073 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/CustomStyleSpan.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/CustomStyleSpan.java @@ -10,7 +10,6 @@ import android.content.res.AssetManager; import android.graphics.Paint; import android.graphics.Typeface; -import android.os.Build; import android.text.TextPaint; import android.text.style.MetricAffectingSpan; import androidx.annotation.NonNull; @@ -83,9 +82,7 @@ private static void apply( AssetManager assetManager) { Typeface typeface = ReactTypefaceUtils.applyStyles(paint.getTypeface(), style, weight, family, assetManager); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - paint.setFontFeatureSettings(fontFeatureSettings); - } + paint.setFontFeatureSettings(fontFeatureSettings); paint.setTypeface(typeface); paint.setSubpixelText(true); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java index 18b8d6b6845403..add0c3e616320b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java @@ -24,7 +24,6 @@ import android.graphics.RectF; import android.graphics.Region; import android.graphics.drawable.Drawable; -import android.os.Build; import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.common.annotations.VisibleForTesting; @@ -184,10 +183,6 @@ public int getOpacity() { /* Android's elevation implementation requires this to be implemented to know where to draw the shadow. */ @Override public void getOutline(Outline outline) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - super.getOutline(outline); - return; - } if ((!YogaConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) { updatePath(); @@ -545,60 +540,58 @@ private void updatePath() { float bottomRightRadius = getBorderRadiusOrDefaultTo(borderRadius, BorderRadiusLocation.BOTTOM_RIGHT); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL; - float topStartRadius = getBorderRadius(BorderRadiusLocation.TOP_START); - float topEndRadius = getBorderRadius(BorderRadiusLocation.TOP_END); - float bottomStartRadius = getBorderRadius(BorderRadiusLocation.BOTTOM_START); - float bottomEndRadius = getBorderRadius(BorderRadiusLocation.BOTTOM_END); + final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL; + float topStartRadius = getBorderRadius(BorderRadiusLocation.TOP_START); + float topEndRadius = getBorderRadius(BorderRadiusLocation.TOP_END); + float bottomStartRadius = getBorderRadius(BorderRadiusLocation.BOTTOM_START); + float bottomEndRadius = getBorderRadius(BorderRadiusLocation.BOTTOM_END); - if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) { - if (YogaConstants.isUndefined(topStartRadius)) { - topStartRadius = topLeftRadius; - } + if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) { + if (YogaConstants.isUndefined(topStartRadius)) { + topStartRadius = topLeftRadius; + } - if (YogaConstants.isUndefined(topEndRadius)) { - topEndRadius = topRightRadius; - } + if (YogaConstants.isUndefined(topEndRadius)) { + topEndRadius = topRightRadius; + } - if (YogaConstants.isUndefined(bottomStartRadius)) { - bottomStartRadius = bottomLeftRadius; - } + if (YogaConstants.isUndefined(bottomStartRadius)) { + bottomStartRadius = bottomLeftRadius; + } - if (YogaConstants.isUndefined(bottomEndRadius)) { - bottomEndRadius = bottomRightRadius; - } + if (YogaConstants.isUndefined(bottomEndRadius)) { + bottomEndRadius = bottomRightRadius; + } - final float directionAwareTopLeftRadius = isRTL ? topEndRadius : topStartRadius; - final float directionAwareTopRightRadius = isRTL ? topStartRadius : topEndRadius; - final float directionAwareBottomLeftRadius = isRTL ? bottomEndRadius : bottomStartRadius; - final float directionAwareBottomRightRadius = isRTL ? bottomStartRadius : bottomEndRadius; + final float directionAwareTopLeftRadius = isRTL ? topEndRadius : topStartRadius; + final float directionAwareTopRightRadius = isRTL ? topStartRadius : topEndRadius; + final float directionAwareBottomLeftRadius = isRTL ? bottomEndRadius : bottomStartRadius; + final float directionAwareBottomRightRadius = isRTL ? bottomStartRadius : bottomEndRadius; - topLeftRadius = directionAwareTopLeftRadius; - topRightRadius = directionAwareTopRightRadius; - bottomLeftRadius = directionAwareBottomLeftRadius; - bottomRightRadius = directionAwareBottomRightRadius; - } else { - final float directionAwareTopLeftRadius = isRTL ? topEndRadius : topStartRadius; - final float directionAwareTopRightRadius = isRTL ? topStartRadius : topEndRadius; - final float directionAwareBottomLeftRadius = isRTL ? bottomEndRadius : bottomStartRadius; - final float directionAwareBottomRightRadius = isRTL ? bottomStartRadius : bottomEndRadius; + topLeftRadius = directionAwareTopLeftRadius; + topRightRadius = directionAwareTopRightRadius; + bottomLeftRadius = directionAwareBottomLeftRadius; + bottomRightRadius = directionAwareBottomRightRadius; + } else { + final float directionAwareTopLeftRadius = isRTL ? topEndRadius : topStartRadius; + final float directionAwareTopRightRadius = isRTL ? topStartRadius : topEndRadius; + final float directionAwareBottomLeftRadius = isRTL ? bottomEndRadius : bottomStartRadius; + final float directionAwareBottomRightRadius = isRTL ? bottomStartRadius : bottomEndRadius; - if (!YogaConstants.isUndefined(directionAwareTopLeftRadius)) { - topLeftRadius = directionAwareTopLeftRadius; - } + if (!YogaConstants.isUndefined(directionAwareTopLeftRadius)) { + topLeftRadius = directionAwareTopLeftRadius; + } - if (!YogaConstants.isUndefined(directionAwareTopRightRadius)) { - topRightRadius = directionAwareTopRightRadius; - } + if (!YogaConstants.isUndefined(directionAwareTopRightRadius)) { + topRightRadius = directionAwareTopRightRadius; + } - if (!YogaConstants.isUndefined(directionAwareBottomLeftRadius)) { - bottomLeftRadius = directionAwareBottomLeftRadius; - } + if (!YogaConstants.isUndefined(directionAwareBottomLeftRadius)) { + bottomLeftRadius = directionAwareBottomLeftRadius; + } - if (!YogaConstants.isUndefined(directionAwareBottomRightRadius)) { - bottomRightRadius = directionAwareBottomRightRadius; - } + if (!YogaConstants.isUndefined(directionAwareBottomRightRadius)) { + bottomRightRadius = directionAwareBottomRightRadius; } } @@ -1038,43 +1031,41 @@ private void drawRectangularBackgroundWithBorders(Canvas canvas) { int colorRight = getBorderColor(Spacing.RIGHT); int colorBottom = getBorderColor(Spacing.BOTTOM); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { - final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL; - int colorStart = getBorderColor(Spacing.START); - int colorEnd = getBorderColor(Spacing.END); + final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL; + int colorStart = getBorderColor(Spacing.START); + int colorEnd = getBorderColor(Spacing.END); - if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) { - if (!isBorderColorDefined(Spacing.START)) { - colorStart = colorLeft; - } + if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) { + if (!isBorderColorDefined(Spacing.START)) { + colorStart = colorLeft; + } - if (!isBorderColorDefined(Spacing.END)) { - colorEnd = colorRight; - } + if (!isBorderColorDefined(Spacing.END)) { + colorEnd = colorRight; + } - final int directionAwareColorLeft = isRTL ? colorEnd : colorStart; - final int directionAwareColorRight = isRTL ? colorStart : colorEnd; + final int directionAwareColorLeft = isRTL ? colorEnd : colorStart; + final int directionAwareColorRight = isRTL ? colorStart : colorEnd; - colorLeft = directionAwareColorLeft; - colorRight = directionAwareColorRight; - } else { - final int directionAwareColorLeft = isRTL ? colorEnd : colorStart; - final int directionAwareColorRight = isRTL ? colorStart : colorEnd; + colorLeft = directionAwareColorLeft; + colorRight = directionAwareColorRight; + } else { + final int directionAwareColorLeft = isRTL ? colorEnd : colorStart; + final int directionAwareColorRight = isRTL ? colorStart : colorEnd; - final boolean isColorStartDefined = isBorderColorDefined(Spacing.START); - final boolean isColorEndDefined = isBorderColorDefined(Spacing.END); - final boolean isDirectionAwareColorLeftDefined = - isRTL ? isColorEndDefined : isColorStartDefined; - final boolean isDirectionAwareColorRightDefined = - isRTL ? isColorStartDefined : isColorEndDefined; + final boolean isColorStartDefined = isBorderColorDefined(Spacing.START); + final boolean isColorEndDefined = isBorderColorDefined(Spacing.END); + final boolean isDirectionAwareColorLeftDefined = + isRTL ? isColorEndDefined : isColorStartDefined; + final boolean isDirectionAwareColorRightDefined = + isRTL ? isColorStartDefined : isColorEndDefined; - if (isDirectionAwareColorLeftDefined) { - colorLeft = directionAwareColorLeft; - } + if (isDirectionAwareColorLeftDefined) { + colorLeft = directionAwareColorLeft; + } - if (isDirectionAwareColorRightDefined) { - colorRight = directionAwareColorRight; - } + if (isDirectionAwareColorRightDefined) { + colorRight = directionAwareColorRight; } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java index 851ec10c6f331c..66aacfcfd157d6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java @@ -335,10 +335,9 @@ private void handleHotspotUpdate(ReactViewGroup root, @Nullable ReadableArray ar throw new JSApplicationIllegalArgumentException( "Illegal number of arguments for 'updateHotspot' command"); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - float x = PixelUtil.toPixelFromDIP(args.getDouble(0)); - float y = PixelUtil.toPixelFromDIP(args.getDouble(1)); - root.drawableHotspotChanged(x, y); - } + + float x = PixelUtil.toPixelFromDIP(args.getDouble(0)); + float y = PixelUtil.toPixelFromDIP(args.getDouble(1)); + root.drawableHotspotChanged(x, y); } } diff --git a/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.java b/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.java index e88d04928c363c..7da483cd24522d 100644 --- a/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.java +++ b/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.java @@ -7,7 +7,6 @@ package com.facebook.systrace; -import android.os.Build; import android.os.Trace; /** @@ -49,15 +48,11 @@ public static boolean isTracing(long tag) { public static void traceInstant(long tag, final String title, EventScope scope) {} public static void beginSection(long tag, final String sectionName) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - Trace.beginSection(sectionName); - } + Trace.beginSection(sectionName); } public static void endSection(long tag) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - Trace.endSection(); - } + Trace.endSection(); } public static void beginAsyncSection(long tag, final String sectionName, final int cookie) {}