Java Code Examples for com.facebook.react.common.build.ReactBuildConfig#DEBUG

The following examples show how to use com.facebook.react.common.build.ReactBuildConfig#DEBUG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactWebViewManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
public void linkBridge() {
  if (messagingEnabled) {
    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      // See isNative in lodash
      String testPostMessageNative = "String(window.postMessage) === String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage')";
      evaluateJavascript(testPostMessageNative, new ValueCallback<String>() {
        @Override
        public void onReceiveValue(String value) {
          if (value.equals("true")) {
            FLog.w(ReactConstants.TAG, "Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined");
          }
        }
      });
    }

    evaluateJavascriptWithFallback("(" +
      "window.originalPostMessage = window.postMessage," +
      "window.postMessage = function(data) {" +
      BRIDGE_NAME + ".postMessage(String(data));" +
      "}" +
      ")");
  }
}
 
Example 2
Source File: JavaScriptModuleRegistry.java    From react-native-GPay with MIT License 6 votes vote down vote up
public JavaScriptModuleInvocationHandler(
    CatalystInstance catalystInstance,
    Class<? extends JavaScriptModule> moduleInterface) {
  mCatalystInstance = catalystInstance;
  mModuleInterface = moduleInterface;

  if (ReactBuildConfig.DEBUG) {
    Set<String> methodNames = new HashSet<>();
    for (Method method : mModuleInterface.getDeclaredMethods()) {
      if (!methodNames.add(method.getName())) {
        throw new AssertionError(
          "Method overloading is unsupported: " + mModuleInterface.getName() +
            "#" + method.getName());
      }
    }
  }
}
 
Example 3
Source File: RNX5WebViewManager.java    From react-native-x5 with MIT License 6 votes vote down vote up
public void linkBridge() {
    if (messagingEnabled) {
        if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // See isNative in lodash
            String testPostMessageNative = "String(window.postMessage) === String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage')";
            evaluateJavascript(testPostMessageNative, new ValueCallback<String>() {
                @Override
                public void onReceiveValue(String value) {
                    if (value.equals("true")) {
                        FLog.w(ReactConstants.TAG, "Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined");
                    }
                }
            });
        }

        loadUrl("javascript:(" +
                "window.originalPostMessage = window.postMessage," +
                "window.postMessage = function(data) {" +
                BRIDGE_NAME + ".postMessage(String(data));" +
                "}" +
                ")");
    }
}
 
Example 4
Source File: RNX5WebViewManager.java    From react-native-x5 with MIT License 6 votes vote down vote up
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
    X5WeView webView = new X5WeView(reactContext);

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
            callback.invoke(origin, true, false);
        }
    });
    reactContext.addLifecycleEventListener(webView);
    mWebViewConfig.configWebView(webView);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);

    // Fixes broken full-screen modals/galleries due to body height being 0.
    webView.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.MATCH_PARENT));

    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    return webView;
}
 
Example 5
Source File: ReactImageView.java    From react-native-GPay with MIT License 5 votes vote down vote up
private void warnImageSource(String uri) {
  if (ReactBuildConfig.DEBUG) {
    Toast.makeText(
      getContext(),
      "Warning: Image source \"" + uri + "\" doesn't exist",
      Toast.LENGTH_SHORT).show();
  }
}
 
Example 6
Source File: ModuleSpec.java    From react-native-GPay with MIT License 5 votes vote down vote up
public ConstructorProvider(Class<? extends NativeModule> type, Class[] signature) {
  if (ReactBuildConfig.DEBUG) {
    try {
      mConstructor = getConstructor(type, signature);
    } catch (NoSuchMethodException e) {
      throw new IllegalArgumentException("No such constructor", e);
    }
  }
}
 
Example 7
Source File: MagnetWebViewManager.java    From magnet-client with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
    MagnetWebView magnetWebView = new MagnetWebView(mContext);
    reactContext.addLifecycleEventListener(magnetWebView);

    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    return magnetWebView;
}
 
Example 8
Source File: ReactWebViewManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected WebView createViewInstance(ThemedReactContext reactContext) {
  ReactWebView webView = createReactWebViewInstance(reactContext);
  webView.setWebChromeClient(new WebChromeClient() {
    @Override
    public boolean onConsoleMessage(ConsoleMessage message) {
      if (ReactBuildConfig.DEBUG) {
        return super.onConsoleMessage(message);
      }
      // Ignore console logs in non debug builds.
      return true;
    }

    @Override
    public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
      callback.invoke(origin, true, false);
    }
  });
  reactContext.addLifecycleEventListener(webView);
  mWebViewConfig.configWebView(webView);
  WebSettings settings = webView.getSettings();
  settings.setBuiltInZoomControls(true);
  settings.setDisplayZoomControls(false);
  settings.setDomStorageEnabled(true);

  settings.setAllowFileAccess(false);
  settings.setAllowContentAccess(false);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    settings.setAllowFileAccessFromFileURLs(false);
    setAllowUniversalAccessFromFileURLs(webView, false);
  }
  setMixedContentMode(webView, "never");

  // Fixes broken full-screen modals/galleries due to body height being 0.
  webView.setLayoutParams(
    new LayoutParams(LayoutParams.MATCH_PARENT,
      LayoutParams.MATCH_PARENT));

  setGeolocationEnabled(webView, false);
  if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    WebView.setWebContentsDebuggingEnabled(true);
  }

  return webView;
}
 
Example 9
Source File: DevInternalSettings.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Override
public boolean isNuclideJSDebugEnabled() {
  return ReactBuildConfig.IS_INTERNAL_BUILD && ReactBuildConfig.DEBUG;
}