Skip to content

Commit

Permalink
remove redundant targetApi and version checks (#23302)
Browse files Browse the repository at this point in the history
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: #23302

Differential Revision: D13970434

Pulled By: mdvacca

fbshipit-source-id: 096b5ee6c8f076b0365e7dda0e77940290077ea2
  • Loading branch information
dulmandakh authored and facebook-github-bot committed Feb 6, 2019
1 parent b6318ac commit a4840e7
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static Object makeNativeObject(Object object) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,7 +94,6 @@
* {@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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import java.util.Locale;

import android.annotation.TargetApi;
import android.widget.FrameLayout;
import android.widget.TextView;

Expand All @@ -26,7 +25,6 @@
*
* NB: Requires API 16 for use of FpsDebugFrameCallback.
*/
@TargetApi(16)
public class FpsView extends FrameLayout {

private static final int UPDATE_INTERVAL_MS = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -22,8 +19,6 @@
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;
Expand All @@ -38,55 +33,35 @@ public static ChoreographerCompat getInstance() {
}

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);
}
Expand All @@ -101,7 +76,6 @@ public static abstract class FrameCallback {
private Runnable mRunnable;
private Choreographer.FrameCallback mFrameCallback;

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
Choreographer.FrameCallback getFrameCallback() {
if (mFrameCallback == null) {
mFrameCallback = new Choreographer.FrameCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -34,7 +33,6 @@
* 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,7 +41,6 @@
/**
* Similar to {@link ReactScrollView} but only supports horizontal scrolling.
*/
@TargetApi(16)
public class ReactHorizontalScrollView extends HorizontalScrollView implements
ReactClippingViewGroup {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -42,7 +41,6 @@
* <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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -37,7 +36,6 @@
* <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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -149,6 +150,7 @@ public void onRtlPropertiesChanged(int layoutDirection) {
}

@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`
Expand Down Expand Up @@ -672,11 +674,7 @@ public void setOverflow(String overflow) {
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
* 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> {

Expand Down Expand Up @@ -447,10 +446,8 @@ public void onGeolocationPermissionsShowPrompt(

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.
Expand Down

0 comments on commit a4840e7

Please sign in to comment.