remove redundant targetApi and version checks (#23302)

Summary:
RN supports API 16 and above, but we have redundant historical artifacts where we check and target APIs 16 and below. This PR removes redundant artifacts.

[Android] [Changed] - remove redundant targetApi and version checks
Pull Request resolved: https://github.com/facebook/react-native/pull/23302

Differential Revision: D13970434

Pulled By: mdvacca

fbshipit-source-id: 096b5ee6c8f076b0365e7dda0e77940290077ea2
This commit is contained in:
Dulmandakh
2019-02-05 23:09:18 -08:00
committed by Facebook Github Bot
parent b6318acbab
commit a4840e7ae3
10 changed files with 10 additions and 53 deletions

View File

@@ -25,7 +25,7 @@ public class Arguments {
object instanceof Long ||
object instanceof Byte ||
object instanceof Short) {
return new Double(((Number) object).doubleValue());
return ((Number) object).doubleValue();
} else if (object.getClass().isArray()) {
return makeNativeArray(object);
} else if (object instanceof List) {

View File

@@ -7,7 +7,6 @@
package com.facebook.react.devsupport;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
@@ -95,7 +94,6 @@ import okhttp3.RequestBody;
* {@code <activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>}
* {@code <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>}
*/
@TargetApi(11)
public class DevSupportManagerImpl implements
DevSupportManager,
PackagerCommandListener,

View File

@@ -9,7 +9,6 @@ package com.facebook.react.devsupport;
import java.util.Locale;
import android.annotation.TargetApi;
import android.widget.FrameLayout;
import android.widget.TextView;
@@ -26,7 +25,6 @@ import com.facebook.react.modules.debug.FpsDebugFrameCallback;
*
* NB: Requires API 16 for use of FpsDebugFrameCallback.
*/
@TargetApi(16)
public class FpsView extends FrameLayout {
private static final int UPDATE_INTERVAL_MS = 500;

View File

@@ -8,10 +8,7 @@
*/
package com.facebook.react.modules.core;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.view.Choreographer;
import com.facebook.react.bridge.UiThreadUtil;
@@ -22,8 +19,6 @@ import com.facebook.react.bridge.UiThreadUtil;
public class ChoreographerCompat {
private static final long ONE_FRAME_MILLIS = 17;
private static final boolean IS_JELLYBEAN_OR_HIGHER =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
private static ChoreographerCompat sInstance;
private Handler mHandler;
@@ -38,55 +33,35 @@ public class ChoreographerCompat {
}
private ChoreographerCompat() {
if (IS_JELLYBEAN_OR_HIGHER) {
mChoreographer = getChoreographer();
} else {
mHandler = new Handler(Looper.getMainLooper());
}
mChoreographer = getChoreographer();
}
public void postFrameCallback(FrameCallback callbackWrapper) {
if (IS_JELLYBEAN_OR_HIGHER) {
choreographerPostFrameCallback(callbackWrapper.getFrameCallback());
} else {
mHandler.postDelayed(callbackWrapper.getRunnable(), 0);
}
choreographerPostFrameCallback(callbackWrapper.getFrameCallback());
}
public void postFrameCallbackDelayed(FrameCallback callbackWrapper, long delayMillis) {
if (IS_JELLYBEAN_OR_HIGHER) {
choreographerPostFrameCallbackDelayed(callbackWrapper.getFrameCallback(), delayMillis);
} else {
mHandler.postDelayed(callbackWrapper.getRunnable(), delayMillis + ONE_FRAME_MILLIS);
}
choreographerPostFrameCallbackDelayed(callbackWrapper.getFrameCallback(), delayMillis);
}
public void removeFrameCallback(FrameCallback callbackWrapper) {
if (IS_JELLYBEAN_OR_HIGHER) {
choreographerRemoveFrameCallback(callbackWrapper.getFrameCallback());
} else {
mHandler.removeCallbacks(callbackWrapper.getRunnable());
}
choreographerRemoveFrameCallback(callbackWrapper.getFrameCallback());
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private Choreographer getChoreographer() {
return Choreographer.getInstance();
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallback(Choreographer.FrameCallback frameCallback) {
mChoreographer.postFrameCallback(frameCallback);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerPostFrameCallbackDelayed(
Choreographer.FrameCallback frameCallback,
long delayMillis) {
mChoreographer.postFrameCallbackDelayed(frameCallback, delayMillis);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void choreographerRemoveFrameCallback(Choreographer.FrameCallback frameCallback) {
mChoreographer.removeFrameCallback(frameCallback);
}
@@ -101,7 +76,6 @@ public class ChoreographerCompat {
private Runnable mRunnable;
private Choreographer.FrameCallback mFrameCallback;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Choreographer.FrameCallback getFrameCallback() {
if (mFrameCallback == null) {
mFrameCallback = new Choreographer.FrameCallback() {

View File

@@ -5,7 +5,6 @@
package com.facebook.react.views.modal;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -34,7 +33,6 @@ import com.facebook.infer.annotation.Assertions;
* and landscape on tablets.
* This should only be called on the native modules/shadow nodes thread.
*/
@TargetApi(16)
public static Point getModalHostSize(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = Assertions.assertNotNull(wm).getDefaultDisplay();

View File

@@ -7,7 +7,6 @@
package com.facebook.react.views.scroll;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -42,7 +41,6 @@ import javax.annotation.Nullable;
/**
* Similar to {@link ReactScrollView} but only supports horizontal scrolling.
*/
@TargetApi(16)
public class ReactHorizontalScrollView extends HorizontalScrollView implements
ReactClippingViewGroup {

View File

@@ -7,7 +7,6 @@
package com.facebook.react.views.scroll;
import android.annotation.TargetApi;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
@@ -42,7 +41,6 @@ import javax.annotation.Nullable;
* <p>ReactScrollView only supports vertical scrolling. For horizontal scrolling,
* use {@link ReactHorizontalScrollView}.
*/
@TargetApi(11)
public class ReactScrollView extends ScrollView implements ReactClippingViewGroup, ViewGroup.OnHierarchyChangeListener, View.OnLayoutChangeListener {
private static @Nullable Field sScrollerField;

View File

@@ -7,7 +7,6 @@
package com.facebook.react.views.scroll;
import android.annotation.TargetApi;
import android.graphics.Color;
import android.support.v4.view.ViewCompat;
import android.util.DisplayMetrics;
@@ -37,7 +36,6 @@ import javax.annotation.Nullable;
* <p>Note that {@link ReactScrollView} and {@link ReactScrollView} are exposed to JS
* as a single ScrollView component, configured via the {@code horizontal} boolean property.
*/
@TargetApi(11)
@ReactModule(name = ReactScrollViewManager.REACT_CLASS)
public class ReactScrollViewManager
extends ViewGroupManager<ReactScrollView>

View File

@@ -7,6 +7,7 @@
package com.facebook.react.views.view;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
@@ -149,6 +150,7 @@ public class ReactViewGroup extends ViewGroup implements
}
@Override
@SuppressLint("MissingSuperCall")
public void requestLayout() {
// No-op, terminate `requestLayout` here, UIManagerModule handles laying out children and
// `layout` is called on all RN-managed views by `NativeViewHierarchyManager`
@@ -672,11 +674,7 @@ public class ReactViewGroup extends ViewGroup implements
* background
*/
private void updateBackgroundDrawable(Drawable drawable) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
super.setBackground(drawable);
} else {
super.setBackgroundDrawable(drawable);
}
super.setBackground(drawable);
}
@Override

View File

@@ -78,7 +78,6 @@ import org.json.JSONObject;
* page - canGoBack - boolean, whether there is anything on a history stack to go back -
* canGoForward - boolean, whether it is possible to request GO_FORWARD command
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@ReactModule(name = ReactWebViewManager.REACT_CLASS)
public class ReactWebViewManager extends SimpleViewManager<WebView> {
@@ -447,10 +446,8 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
settings.setAllowFileAccess(false);
settings.setAllowContentAccess(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
settings.setAllowFileAccessFromFileURLs(false);
setAllowUniversalAccessFromFileURLs(webView, false);
}
settings.setAllowFileAccessFromFileURLs(false);
setAllowUniversalAccessFromFileURLs(webView, false);
setMixedContentMode(webView, "never");
// Fixes broken full-screen modals/galleries due to body height being 0.