Reverted commit D3334273

Reviewed By: astreet

Differential Revision: D3334273

fbshipit-source-id: a3849604ea89db74900850c294685e7da9aeeacc
This commit is contained in:
Aaron Chiu 2016-08-12 15:49:13 -07:00 committed by Facebook Github Bot 7
parent 757ab0b936
commit 705daabbb1
40 changed files with 255 additions and 103 deletions

View File

@ -15,7 +15,6 @@ import java.util.concurrent.TimeUnit;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.testing.ReactInstanceSpecForTest; import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.testing.ReactAppInstrumentationTestCase; import com.facebook.react.testing.ReactAppInstrumentationTestCase;
@ -46,8 +45,6 @@ public abstract class AbstractScrollViewTestCase extends ReactAppInstrumentation
} }
// See ScrollViewListenerModule.js // See ScrollViewListenerModule.js
// Matches ScrollViewListenerModule.js
@ReactModule(name = "ScrollListener")
protected static class ScrollListenerModule extends BaseJavaModule { protected static class ScrollListenerModule extends BaseJavaModule {
private final ArrayList<Double> mXOffsets = new ArrayList<Double>(); private final ArrayList<Double> mXOffsets = new ArrayList<Double>();
@ -57,6 +54,12 @@ public abstract class AbstractScrollViewTestCase extends ReactAppInstrumentation
private boolean mScrollBeginDragCalled; private boolean mScrollBeginDragCalled;
private boolean mScrollEndDragCalled; private boolean mScrollEndDragCalled;
// Matches ScrollViewListenerModule.js
@Override
public String getName() {
return "ScrollListener";
}
@ReactMethod @ReactMethod
public void onScroll(double x, double y) { public void onScroll(double x, double y) {
mXOffsets.add(x); mXOffsets.add(x);

View File

@ -12,7 +12,6 @@ import javax.annotation.Nullable;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.assertTrue;
@ -20,13 +19,17 @@ import static junit.framework.Assert.assertTrue;
/** /**
* NativeModule for tests that allows assertions from JS to propagate to Java. * NativeModule for tests that allows assertions from JS to propagate to Java.
*/ */
@ReactModule(name = "Assert")
public class AssertModule extends BaseJavaModule { public class AssertModule extends BaseJavaModule {
private boolean mGotSuccess; private boolean mGotSuccess;
private boolean mGotFailure; private boolean mGotFailure;
private @Nullable String mFirstFailureStackTrace; private @Nullable String mFirstFailureStackTrace;
@Override
public String getName() {
return "Assert";
}
@ReactMethod @ReactMethod
public void fail(String stackTrace) { public void fail(String stackTrace) {
if (!mGotFailure) { if (!mGotFailure) {

View File

@ -14,12 +14,10 @@ import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule;
/** /**
* Dummy implementation of storage module, used for testing * Dummy implementation of storage module, used for testing
*/ */
@ReactModule(name = "AsyncSQLiteDBStorage")
public final class FakeAsyncLocalStorage extends BaseJavaModule { public final class FakeAsyncLocalStorage extends BaseJavaModule {
private static WritableMap errorMessage; private static WritableMap errorMessage;
@ -28,6 +26,11 @@ public final class FakeAsyncLocalStorage extends BaseJavaModule {
errorMessage.putString("message", "Fake Async Local Storage"); errorMessage.putString("message", "Fake Async Local Storage");
} }
@Override
public String getName() {
return "AsyncSQLiteDBStorage";
}
@ReactMethod @ReactMethod
public void multiGet(final ReadableArray keys, final Callback callback) { public void multiGet(final ReadableArray keys, final Callback callback) {
callback.invoke(errorMessage, null); callback.invoke(errorMessage, null);

View File

@ -15,18 +15,21 @@ import java.util.concurrent.TimeUnit;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
/** /**
* Native module provides single method {@link #record} which records its single int argument * Native module provides single method {@link #record} which records its single int argument
* in calls array * in calls array
*/ */
@ReactModule(name = "Recording")
public class IntRecordingModule extends BaseJavaModule { public class IntRecordingModule extends BaseJavaModule {
private final List<Integer> mCalls = new ArrayList<>(); private final List<Integer> mCalls = new ArrayList<>();
private final CountDownLatch mCountDownLatch = new CountDownLatch(1); private final CountDownLatch mCountDownLatch = new CountDownLatch(1);
@Override
public String getName() {
return "Recording";
}
@ReactMethod @ReactMethod
public void record(int i) { public void record(int i) {
mCalls.add(i); mCalls.add(i);

View File

@ -14,7 +14,6 @@ import java.util.concurrent.TimeUnit;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
/** /**
* This class is used to verify that some JS integration tests have completed successfully. * This class is used to verify that some JS integration tests have completed successfully.
@ -24,7 +23,6 @@ import com.facebook.react.bridge.annotations.ReactModule;
* to wait for the test to run, and {#link JSIntegrationTestChecker#isTestDone()} to check if it * to wait for the test to run, and {#link JSIntegrationTestChecker#isTestDone()} to check if it
* completed successfully. * completed successfully.
*/ */
@ReactModule(name = "TestModule")
public class JSIntegrationTestChecker extends BaseJavaModule { public class JSIntegrationTestChecker extends BaseJavaModule {
private final CountDownLatch mLatch; private final CountDownLatch mLatch;
@ -33,6 +31,11 @@ public class JSIntegrationTestChecker extends BaseJavaModule {
mLatch = new CountDownLatch(1); mLatch = new CountDownLatch(1);
} }
@Override
public String getName() {
return "TestModule";
}
@ReactMethod @ReactMethod
public void markTestCompleted() { public void markTestCompleted() {
mLatch.countDown(); mLatch.countDown();

View File

@ -19,14 +19,12 @@ import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.modules.core.DeviceEventManagerModule;
/** /**
* Mock Networking module that records last request received by {@link #sendRequest} method and * Mock Networking module that records last request received by {@link #sendRequest} method and
* returns reponse code and body that should be set with {@link #setResponse} * returns reponse code and body that should be set with {@link #setResponse}
*/ */
@ReactModule(name = "RCTNetworking")
public class NetworkRecordingModuleMock extends ReactContextBaseJavaModule { public class NetworkRecordingModuleMock extends ReactContextBaseJavaModule {
public int mRequestCount = 0; public int mRequestCount = 0;
@ -65,6 +63,11 @@ public class NetworkRecordingModuleMock extends ReactContextBaseJavaModule {
mRequestListener = requestListener; mRequestListener = requestListener;
} }
@Override
public final String getName() {
return "RCTNetworking";
}
private void fireReactCallback( private void fireReactCallback(
Callback callback, Callback callback,
int status, int status,

View File

@ -13,17 +13,20 @@ import java.util.List;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
/** /**
* Native module provides single method {@link #record} which records its single string argument * Native module provides single method {@link #record} which records its single string argument
* in calls array * in calls array
*/ */
@ReactModule(name = "Recording")
public class StringRecordingModule extends BaseJavaModule { public class StringRecordingModule extends BaseJavaModule {
private final List<String> mCalls = new ArrayList<String>(); private final List<String> mCalls = new ArrayList<String>();
@Override
public String getName() {
return "Recording";
}
@ReactMethod @ReactMethod
public void record(String text) { public void record(String text) {
mCalls.add(text); mCalls.add(text);

View File

@ -29,7 +29,6 @@ import com.facebook.react.bridge.UnexpectedNativeTypeException;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.modules.systeminfo.AndroidInfoModule; import com.facebook.react.modules.systeminfo.AndroidInfoModule;
import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactIntegrationTestCase;
@ -669,13 +668,17 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe
} }
} }
@ReactModule(name = "Recording")
private class RecordingTestModule extends BaseJavaModule { private class RecordingTestModule extends BaseJavaModule {
private final List<Object[]> mBasicTypesCalls = new ArrayList<Object[]>(); private final List<Object[]> mBasicTypesCalls = new ArrayList<Object[]>();
private final List<ReadableArray> mArrayCalls = new ArrayList<ReadableArray>(); private final List<ReadableArray> mArrayCalls = new ArrayList<ReadableArray>();
private final List<ReadableMap> mMapCalls = new ArrayList<ReadableMap>(); private final List<ReadableMap> mMapCalls = new ArrayList<ReadableMap>();
@Override
public String getName() {
return "Recording";
}
@ReactMethod @ReactMethod
public void receiveBasicTypes(String s, double d, boolean b, String nullableString) { public void receiveBasicTypes(String s, double d, boolean b, String nullableString) {
mBasicTypesCalls.add(new Object[]{s, d, b, nullableString}); mBasicTypesCalls.add(new Object[]{s, d, b, nullableString});

View File

@ -12,13 +12,12 @@ import android.os.Bundle;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactInstanceSpecForTest;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.testing.FakeWebSocketModule;
import com.facebook.react.testing.ReactAppTestActivity; import com.facebook.react.testing.ReactAppTestActivity;
import com.facebook.react.testing.ReactInstanceSpecForTest;
/** /**
* Simple test case for passing initial props to the root React application. * Simple test case for passing initial props to the root React application.
@ -28,11 +27,15 @@ public class InitialPropsTestCase extends
public static final String DEFAULT_JS_BUNDLE = "AndroidTestBundle.js"; public static final String DEFAULT_JS_BUNDLE = "AndroidTestBundle.js";
@ReactModule(name = "InitialPropsRecordingModule")
private static class RecordingModule extends BaseJavaModule { private static class RecordingModule extends BaseJavaModule {
private int mCount = 0; private int mCount = 0;
private ReadableMap mProps; private ReadableMap mProps;
@Override
public String getName() {
return "InitialPropsRecordingModule";
}
@ReactMethod @ReactMethod
public void recordProps(ReadableMap props) { public void recordProps(ReadableMap props) {
mProps = props; mProps = props;

View File

@ -20,9 +20,7 @@ import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
@ReactModule(name = "JSCHeapCapture")
public class JSCHeapCapture extends ReactContextBaseJavaModule { public class JSCHeapCapture extends ReactContextBaseJavaModule {
public interface HeapCapture extends JavaScriptModule { public interface HeapCapture extends JavaScriptModule {
void captureHeap(String path); void captureHeap(String path);
@ -134,6 +132,11 @@ public class JSCHeapCapture extends ReactContextBaseJavaModule {
} }
} }
@Override
public String getName() {
return "JSCHeapCapture";
}
@Override @Override
public void initialize() { public void initialize() {
super.initialize(); super.initialize();

View File

@ -16,10 +16,8 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter; import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
@ReactModule(name = "AppState")
public class AppStateModule extends ReactContextBaseJavaModule public class AppStateModule extends ReactContextBaseJavaModule
implements LifecycleEventListener { implements LifecycleEventListener {
@ -32,6 +30,11 @@ public class AppStateModule extends ReactContextBaseJavaModule
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "AppState";
}
@Override @Override
public void initialize() { public void initialize() {
getReactApplicationContext().addLifecycleEventListener(this); getReactApplicationContext().addLifecycleEventListener(this);

View File

@ -50,7 +50,6 @@ import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray; import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
// TODO #6015104: rename to something less iOSish // TODO #6015104: rename to something less iOSish
@ -58,7 +57,6 @@ import com.facebook.react.common.ReactConstants;
* {@link NativeModule} that allows JS to interact with the photos on the device (i.e. * {@link NativeModule} that allows JS to interact with the photos on the device (i.e.
* {@link MediaStore.Images}). * {@link MediaStore.Images}).
*/ */
@ReactModule(name = "RKCameraRollManager")
public class CameraRollManager extends ReactContextBaseJavaModule { public class CameraRollManager extends ReactContextBaseJavaModule {
private static final String ERROR_UNABLE_TO_LOAD = "E_UNABLE_TO_LOAD"; private static final String ERROR_UNABLE_TO_LOAD = "E_UNABLE_TO_LOAD";
@ -100,6 +98,11 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "RKCameraRollManager";
}
@Override @Override
public Map<String, Object> getConstants() { public Map<String, Object> getConstants() {
return Collections.emptyMap(); return Collections.emptyMap();
@ -437,4 +440,5 @@ public class CameraRollManager extends ReactContextBaseJavaModule {
node.putMap("location", location); node.putMap("location", location);
} }
} }
} }

View File

@ -46,13 +46,11 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.infer.annotation.Assertions; import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
/** /**
* Native module that provides image cropping functionality. * Native module that provides image cropping functionality.
*/ */
@ReactModule(name = "RKImageEditingManager")
public class ImageEditingManager extends ReactContextBaseJavaModule { public class ImageEditingManager extends ReactContextBaseJavaModule {
private static final List<String> LOCAL_URI_PREFIXES = Arrays.asList( private static final List<String> LOCAL_URI_PREFIXES = Arrays.asList(
@ -91,11 +89,17 @@ public class ImageEditingManager extends ReactContextBaseJavaModule {
ExifInterface.TAG_WHITE_BALANCE ExifInterface.TAG_WHITE_BALANCE
}; };
public ImageEditingManager(ReactApplicationContext reactContext) { public ImageEditingManager(ReactApplicationContext reactContext) {
super(reactContext); super(reactContext);
new CleanTask(getReactApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new CleanTask(getReactApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
@Override
public String getName() {
return "RKImageEditingManager";
}
@Override @Override
public Map<String, Object> getConstants() { public Map<String, Object> getConstants() {
return Collections.emptyMap(); return Collections.emptyMap();
@ -278,6 +282,7 @@ public class ImageEditingManager extends ReactContextBaseJavaModule {
} }
mSuccess.invoke(Uri.fromFile(tempFile).toString()); mSuccess.invoke(Uri.fromFile(tempFile).toString());
} catch (Exception e) { } catch (Exception e) {
mError.invoke(e.getMessage()); mError.invoke(e.getMessage());
} }

View File

@ -27,9 +27,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
@ReactModule(name = "ImageStoreManager")
public class ImageStoreManager extends ReactContextBaseJavaModule { public class ImageStoreManager extends ReactContextBaseJavaModule {
private static final int BUFFER_SIZE = 8192; private static final int BUFFER_SIZE = 8192;
@ -38,6 +36,11 @@ public class ImageStoreManager extends ReactContextBaseJavaModule {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "ImageStoreManager";
}
/** /**
* Calculate the base64 representation for an image. The "tag" comes from iOS naming. * Calculate the base64 representation for an image. The "tag" comes from iOS naming.
* *

View File

@ -14,29 +14,41 @@ import android.content.ClipboardManager;
import android.content.ClipData; import android.content.ClipData;
import android.os.Build; import android.os.Build;
import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.ReactConstants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* A module that allows JS to get/set clipboard contents. * A module that allows JS to get/set clipboard contents.
*/ */
@ReactModule(name = "Clipboard")
public class ClipboardModule extends ReactContextBaseJavaModule { public class ClipboardModule extends ReactContextBaseJavaModule {
public ClipboardModule(ReactApplicationContext reactContext) { public ClipboardModule(ReactApplicationContext reactContext) {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "Clipboard";
}
private ClipboardManager getClipboardService() { private ClipboardManager getClipboardService() {
return (ClipboardManager) getReactApplicationContext().getSystemService(getReactApplicationContext().CLIPBOARD_SERVICE); return (ClipboardManager) getReactApplicationContext().getSystemService(getReactApplicationContext().CLIPBOARD_SERVICE);
} }
@ReactMethod @ReactMethod
public void getString(Promise promise) { public void getString(Promise promise){
try { try {
ClipboardManager clipboard = getClipboardService(); ClipboardManager clipboard = getClipboardService();
ClipData clipData = clipboard.getPrimaryClip(); ClipData clipData = clipboard.getPrimaryClip();
@ -48,7 +60,7 @@ public class ClipboardModule extends ReactContextBaseJavaModule {
} else { } else {
promise.resolve(""); promise.resolve("");
} }
} catch (Exception e) { } catch(Exception e) {
promise.reject(e); promise.reject(e);
} }
} }

View File

@ -21,12 +21,10 @@ import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.SupportsWebWorkers; import com.facebook.react.bridge.SupportsWebWorkers;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule;
/** /**
* Native module that handles device hardware events like hardware back presses. * Native module that handles device hardware events like hardware back presses.
*/ */
@ReactModule(name = "DeviceEventManager")
public class DeviceEventManagerModule extends ReactContextBaseJavaModule { public class DeviceEventManagerModule extends ReactContextBaseJavaModule {
@SupportsWebWorkers @SupportsWebWorkers
@ -77,4 +75,9 @@ public class DeviceEventManagerModule extends ReactContextBaseJavaModule {
public void invokeDefaultBackPressHandler() { public void invokeDefaultBackPressHandler() {
getReactApplicationContext().runOnUiQueueThread(mInvokeDefaultBackPressRunnable); getReactApplicationContext().runOnUiQueueThread(mInvokeDefaultBackPressRunnable);
} }
@Override
public String getName() {
return "DeviceEventManager";
}
} }

View File

@ -18,12 +18,10 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableType; import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.devsupport.DevSupportManager; import com.facebook.react.devsupport.DevSupportManager;
import com.facebook.react.common.JavascriptException; import com.facebook.react.common.JavascriptException;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
@ReactModule(name = "RKExceptionsManager")
public class ExceptionsManagerModule extends BaseJavaModule { public class ExceptionsManagerModule extends BaseJavaModule {
static private final Pattern mJsModuleIdPattern = Pattern.compile("(?:^|[/\\\\])(\\d+\\.js)$"); static private final Pattern mJsModuleIdPattern = Pattern.compile("(?:^|[/\\\\])(\\d+\\.js)$");
@ -33,6 +31,11 @@ public class ExceptionsManagerModule extends BaseJavaModule {
mDevSupportManager = devSupportManager; mDevSupportManager = devSupportManager;
} }
@Override
public String getName() {
return "RKExceptionsManager";
}
// If the file name of a stack frame is numeric (+ ".js"), we assume it's a lazily injected module // If the file name of a stack frame is numeric (+ ".js"), we assume it's a lazily injected module
// coming from a "random access bundle". We are using special source maps for these bundles, so // coming from a "random access bundle". We are using special source maps for these bundles, so
// that we can symbolicate stack traces for multiple injected files with a single source map. // that we can symbolicate stack traces for multiple injected files with a single source map.

View File

@ -22,7 +22,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.SystemClock; import com.facebook.react.common.SystemClock;
import com.facebook.react.devsupport.DevSupportManager; import com.facebook.react.devsupport.DevSupportManager;
import com.facebook.react.uimanager.ReactChoreographer; import com.facebook.react.uimanager.ReactChoreographer;
@ -42,7 +41,6 @@ import javax.annotation.Nullable;
/** /**
* Native module for JS timer execution. Timers fire on frame boundaries. * Native module for JS timer execution. Timers fire on frame boundaries.
*/ */
@ReactModule(name = "RKTiming")
public final class Timing extends ReactContextBaseJavaModule implements LifecycleEventListener, public final class Timing extends ReactContextBaseJavaModule implements LifecycleEventListener,
OnExecutorUnregisteredListener { OnExecutorUnregisteredListener {
@ -164,7 +162,7 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl
long time = SystemClock.currentTimeMillis(); long time = SystemClock.currentTimeMillis();
long absoluteFrameStartTime = time - frameTimeElapsed; long absoluteFrameStartTime = time - frameTimeElapsed;
if (FRAME_DURATION_MS - (float) frameTimeElapsed < IDLE_CALLBACK_FRAME_DEADLINE_MS) { if (FRAME_DURATION_MS - (float)frameTimeElapsed < IDLE_CALLBACK_FRAME_DEADLINE_MS) {
return; return;
} }
@ -301,6 +299,11 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl
} }
} }
@Override
public String getName() {
return "RCTTiming";
}
@Override @Override
public boolean supportsWebWorkers() { public boolean supportsWebWorkers() {
return true; return true;

View File

@ -30,14 +30,12 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.common.annotations.VisibleForTesting;
/** /**
* {@link NativeModule} that allows JS to show a native date picker dialog and get called back when * {@link NativeModule} that allows JS to show a native date picker dialog and get called back when
* the user selects a date. * the user selects a date.
*/ */
@ReactModule(name = "DatePickerAndroid")
public class DatePickerDialogModule extends ReactContextBaseJavaModule { public class DatePickerDialogModule extends ReactContextBaseJavaModule {
@VisibleForTesting @VisibleForTesting
@ -56,6 +54,11 @@ public class DatePickerDialogModule extends ReactContextBaseJavaModule {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "DatePickerAndroid";
}
private class DatePickerDialogListener implements OnDateSetListener, OnDismissListener { private class DatePickerDialogListener implements OnDateSetListener, OnDismissListener {
private final Promise mPromise; private final Promise mPromise;
@ -126,7 +129,7 @@ public class DatePickerDialogModule extends ReactContextBaseJavaModule {
android.support.v4.app.FragmentManager fragmentManager = android.support.v4.app.FragmentManager fragmentManager =
((android.support.v4.app.FragmentActivity) activity).getSupportFragmentManager(); ((android.support.v4.app.FragmentActivity) activity).getSupportFragmentManager();
android.support.v4.app.DialogFragment oldFragment = android.support.v4.app.DialogFragment oldFragment =
(android.support.v4.app.DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG); (android.support.v4.app.DialogFragment)fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (oldFragment != null) { if (oldFragment != null) {
oldFragment.dismiss(); oldFragment.dismiss();
} }
@ -141,7 +144,7 @@ public class DatePickerDialogModule extends ReactContextBaseJavaModule {
fragment.show(fragmentManager, FRAGMENT_TAG); fragment.show(fragmentManager, FRAGMENT_TAG);
} else { } else {
FragmentManager fragmentManager = activity.getFragmentManager(); FragmentManager fragmentManager = activity.getFragmentManager();
DialogFragment oldFragment = (DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG); DialogFragment oldFragment = (DialogFragment)fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (oldFragment != null) { if (oldFragment != null) {
oldFragment.dismiss(); oldFragment.dismiss();
} }

View File

@ -22,14 +22,12 @@ import com.facebook.react.bridge.JSApplicationCausedNativeException;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
/** /**
* Module that records debug information during transitions (animated navigation events such as * Module that records debug information during transitions (animated navigation events such as
* going from one screen to another). * going from one screen to another).
*/ */
@ReactModule(name = "AnimationsDebugModule")
public class AnimationsDebugModule extends ReactContextBaseJavaModule { public class AnimationsDebugModule extends ReactContextBaseJavaModule {
private @Nullable FpsDebugFrameCallback mFrameCallback; private @Nullable FpsDebugFrameCallback mFrameCallback;
@ -42,6 +40,11 @@ public class AnimationsDebugModule extends ReactContextBaseJavaModule {
mCatalystSettings = catalystSettings; mCatalystSettings = catalystSettings;
} }
@Override
public String getName() {
return "AnimationsDebugModule";
}
@ReactMethod @ReactMethod
public void startRecordingFps() { public void startRecordingFps() {
if (mCatalystSettings == null || if (mCatalystSettings == null ||

View File

@ -14,13 +14,15 @@ import javax.annotation.Nullable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
/** /**
* Module that exposes the URL to the source code map (used for exception stack trace parsing) to JS * Module that exposes the URL to the source code map (used for exception stack trace parsing) to JS
*/ */
@ReactModule(name = "RCTSourceCode")
public class SourceCodeModule extends BaseJavaModule { public class SourceCodeModule extends BaseJavaModule {
private final String mSourceUrl; private final String mSourceUrl;
@ -29,6 +31,11 @@ public class SourceCodeModule extends BaseJavaModule {
mSourceUrl = sourceUrl; mSourceUrl = sourceUrl;
} }
@Override
public String getName() {
return "RCTSourceCode";
}
@Override @Override
public @Nullable Map<String, Object> getConstants() { public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>(); HashMap<String, Object> constants = new HashMap<String, Object>();

View File

@ -21,6 +21,7 @@ import android.os.Bundle;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import com.facebook.common.logging.FLog; import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener; import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
@ -28,15 +29,15 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
@ReactModule(name = "DialogManagerAndroid")
public class DialogModule extends ReactContextBaseJavaModule implements LifecycleEventListener { public class DialogModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
/* package */ static final String FRAGMENT_TAG = /* package */ static final String FRAGMENT_TAG =
"com.facebook.catalyst.react.dialog.DialogModule"; "com.facebook.catalyst.react.dialog.DialogModule";
/* package */ static final String NAME = "DialogManagerAndroid";
/* package */ static final String ACTION_BUTTON_CLICKED = "buttonClicked"; /* package */ static final String ACTION_BUTTON_CLICKED = "buttonClicked";
/* package */ static final String ACTION_DISMISSED = "dismissed"; /* package */ static final String ACTION_DISMISSED = "dismissed";
/* package */ static final String KEY_TITLE = "title"; /* package */ static final String KEY_TITLE = "title";
@ -60,6 +61,11 @@ public class DialogModule extends ReactContextBaseJavaModule implements Lifecycl
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return NAME;
}
/** /**
* Helper to allow this module to work with both the standard FragmentManager * Helper to allow this module to work with both the standard FragmentManager
* and the Support FragmentManager (for apps that need to use it for legacy reasons). * and the Support FragmentManager (for apps that need to use it for legacy reasons).

View File

@ -25,7 +25,6 @@ import com.facebook.imagepipeline.core.ImagePipelineFactory;
import com.facebook.imagepipeline.listener.RequestListener; import com.facebook.imagepipeline.listener.RequestListener;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.modules.common.ModuleDataCleaner; import com.facebook.react.modules.common.ModuleDataCleaner;
import com.facebook.react.modules.network.OkHttpClientProvider; import com.facebook.react.modules.network.OkHttpClientProvider;
import com.facebook.soloader.SoLoader; import com.facebook.soloader.SoLoader;
@ -37,7 +36,6 @@ import okhttp3.OkHttpClient;
* *
* <p>Does not expose any methods to JavaScript code. For initialization and cleanup only. * <p>Does not expose any methods to JavaScript code. For initialization and cleanup only.
*/ */
@ReactModule(name = "FrescoModule", needsEagerInit = true)
public class FrescoModule extends ReactContextBaseJavaModule implements public class FrescoModule extends ReactContextBaseJavaModule implements
ModuleDataCleaner.Cleanable { ModuleDataCleaner.Cleanable {
@ -75,6 +73,11 @@ public class FrescoModule extends ReactContextBaseJavaModule implements
mConfig = null; mConfig = null;
} }
@Override
public String getName() {
return "FrescoModule";
}
@Override @Override
public void clearSensitiveData() { public void clearSensitiveData() {
// Clear image cache. // Clear image cache.

View File

@ -11,17 +11,17 @@ package com.facebook.react.modules.i18nmanager;
import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
import java.util.Map; import java.util.Map;
/** /**
* {@link NativeModule} that allows JS to set allowRTL and get isRTL status. * {@link NativeModule} that allows JS to set allowRTL and get isRTL status.
*/ */
@ReactModule(name = "I18nManager")
public class I18nManagerModule extends ReactContextBaseJavaModule { public class I18nManagerModule extends ReactContextBaseJavaModule {
private final I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance(); private final I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
@ -30,12 +30,15 @@ public class I18nManagerModule extends ReactContextBaseJavaModule {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "I18nManager";
}
@Override @Override
public Map<String, Object> getConstants() { public Map<String, Object> getConstants() {
final Map<String, Object> constants = MapBuilder.newHashMap(); final Map<String, Object> constants = MapBuilder.newHashMap();
constants.put( constants.put("isRTL", sharedI18nUtilInstance.isRTL(
"isRTL",
sharedI18nUtilInstance.isRTL(
getReactApplicationContext() getReactApplicationContext()
)); ));
return constants; return constants;
@ -45,13 +48,15 @@ public class I18nManagerModule extends ReactContextBaseJavaModule {
public void allowRTL(boolean value) { public void allowRTL(boolean value) {
sharedI18nUtilInstance.allowRTL( sharedI18nUtilInstance.allowRTL(
getReactApplicationContext(), getReactApplicationContext(),
value); value
);
} }
@ReactMethod @ReactMethod
public void forceRTL(boolean value) { public void forceRTL(boolean value) {
sharedI18nUtilInstance.forceRTL( sharedI18nUtilInstance.forceRTL(
getReactApplicationContext(), getReactApplicationContext(),
value); value
);
} }
} }

View File

@ -30,11 +30,9 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule;
@ReactModule(name = "ImageLoader") public class ImageLoaderModule extends ReactContextBaseJavaModule implements
public class ImageLoaderModule extends ReactContextBaseJavaModule LifecycleEventListener {
implements LifecycleEventListener {
private static final String ERROR_INVALID_URI = "E_INVALID_URI"; private static final String ERROR_INVALID_URI = "E_INVALID_URI";
private static final String ERROR_PREFETCH_FAILURE = "E_PREFETCH_FAILURE"; private static final String ERROR_PREFETCH_FAILURE = "E_PREFETCH_FAILURE";
@ -54,6 +52,11 @@ public class ImageLoaderModule extends ReactContextBaseJavaModule
mCallerContext = callerContext; mCallerContext = callerContext;
} }
@Override
public String getName() {
return "ImageLoader";
}
/** /**
* Fetch the width and height of the given image. * Fetch the width and height of the given image.
* *

View File

@ -19,18 +19,21 @@ import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
/** /**
* Intent module. Launch other activities or open URLs. * Intent module. Launch other activities or open URLs.
*/ */
@ReactModule(name = "IntentAndroid")
public class IntentModule extends ReactContextBaseJavaModule { public class IntentModule extends ReactContextBaseJavaModule {
public IntentModule(ReactApplicationContext reactContext) { public IntentModule(ReactApplicationContext reactContext) {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "IntentAndroid";
}
/** /**
* Return the URL the activity was started with * Return the URL the activity was started with
* *

View File

@ -27,14 +27,12 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.SystemClock; import com.facebook.react.common.SystemClock;
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter; import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
/** /**
* Native module that exposes Geolocation to JS. * Native module that exposes Geolocation to JS.
*/ */
@ReactModule(name = "LocationObserver")
public class LocationModule extends ReactContextBaseJavaModule { public class LocationModule extends ReactContextBaseJavaModule {
private @Nullable String mWatchedProvider; private @Nullable String mWatchedProvider;
@ -67,6 +65,11 @@ public class LocationModule extends ReactContextBaseJavaModule {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "LocationObserver";
}
private static class LocationOptions { private static class LocationOptions {
private final long timeout; private final long timeout;
private final double maximumAge; private final double maximumAge;

View File

@ -24,14 +24,12 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.bridge.annotations.ReactModule;
import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter; import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
/** /**
* Module that monitors and provides information about the connectivity state of the device. * Module that monitors and provides information about the connectivity state of the device.
*/ */
@ReactModule(name = "NetInfo")
public class NetInfoModule extends ReactContextBaseJavaModule public class NetInfoModule extends ReactContextBaseJavaModule
implements LifecycleEventListener { implements LifecycleEventListener {
@ -75,6 +73,11 @@ public class NetInfoModule extends ReactContextBaseJavaModule
getReactApplicationContext().addLifecycleEventListener(this); getReactApplicationContext().addLifecycleEventListener(this);
} }
@Override
public String getName() {
return "NetInfo";
}
@ReactMethod @ReactMethod
public void getCurrentConnectivity(Promise promise) { public void getCurrentConnectivity(Promise promise) {
if (mNoNetworkPermission) { if (mNoNetworkPermission) {

View File

@ -30,7 +30,6 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.network.OkHttpCallUtil; import com.facebook.react.common.network.OkHttpCallUtil;
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter; import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
@ -50,7 +49,6 @@ import okhttp3.ResponseBody;
/** /**
* Implements the XMLHttpRequest JavaScript interface. * Implements the XMLHttpRequest JavaScript interface.
*/ */
@ReactModule(name = "RCTNetworking")
public final class NetworkingModule extends ReactContextBaseJavaModule { public final class NetworkingModule extends ReactContextBaseJavaModule {
private static final String CONTENT_ENCODING_HEADER_NAME = "content-encoding"; private static final String CONTENT_ENCODING_HEADER_NAME = "content-encoding";
@ -137,6 +135,11 @@ public final class NetworkingModule extends ReactContextBaseJavaModule {
mCookieJarContainer.setCookieJar(new JavaNetCookieJar(mCookieHandler)); mCookieJarContainer.setCookieJar(new JavaNetCookieJar(mCookieHandler));
} }
@Override
public String getName() {
return "RCTNetworking";
}
@Override @Override
public void onCatalystInstanceDestroy() { public void onCatalystInstanceDestroy() {
mShuttingDown = true; mShuttingDown = true;

View File

@ -19,14 +19,12 @@ import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.modules.core.PermissionAwareActivity; import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener; import com.facebook.react.modules.core.PermissionListener;
/** /**
* Module that exposes the Android M Permission system to JS. * Module that exposes the Android M Permission system to JS.
*/ */
@ReactModule(name = "AndroidPermissions")
public class PermissionsModule extends ReactContextBaseJavaModule implements PermissionListener { public class PermissionsModule extends ReactContextBaseJavaModule implements PermissionListener {
private final SparseArray<Callback> mCallbacks; private final SparseArray<Callback> mCallbacks;
@ -37,6 +35,11 @@ public class PermissionsModule extends ReactContextBaseJavaModule implements Per
mCallbacks = new SparseArray<Callback>(); mCallbacks = new SparseArray<Callback>();
} }
@Override
public String getName() {
return "AndroidPermissions";
}
/** /**
* Check if the app has the permission given. successCallback is called with true if the * Check if the app has the permission given. successCallback is called with true if the
* permission had been granted, false otherwise. See {@link Activity#checkSelfPermission}. * permission had been granted, false otherwise. See {@link Activity#checkSelfPermission}.

View File

@ -11,20 +11,21 @@ package com.facebook.react.modules.share;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.ReactConstants;
/** /**
* Intent module. Launch other activities or open URLs. * Intent module. Launch other activities or open URLs.
*/ */
@ReactModule(name = "ShareModule")
public class ShareModule extends ReactContextBaseJavaModule { public class ShareModule extends ReactContextBaseJavaModule {
/* package */ static final String ACTION_SHARED = "sharedAction"; /* package */ static final String ACTION_SHARED = "sharedAction";
@ -35,6 +36,11 @@ public class ShareModule extends ReactContextBaseJavaModule {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "ShareModule";
}
/** /**
* Open a chooser dialog to send text content to other apps. * Open a chooser dialog to send text content to other apps.
* *
@ -74,9 +80,11 @@ public class ShareModule extends ReactContextBaseJavaModule {
WritableMap result = Arguments.createMap(); WritableMap result = Arguments.createMap();
result.putString("action", ACTION_SHARED); result.putString("action", ACTION_SHARED);
promise.resolve(result); promise.resolve(result);
} catch (Exception e) { } catch (Exception e) {
promise.reject(ERROR_UNABLE_TO_OPEN_DIALOG, "Failed to open share dialog"); promise.reject(ERROR_UNABLE_TO_OPEN_DIALOG, "Failed to open share dialog");
} }
} }
} }

View File

@ -29,14 +29,12 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.PixelUtil;
/** /**
* {@link NativeModule} that allows changing the appearance of the status bar. * {@link NativeModule} that allows changing the appearance of the status bar.
*/ */
@ReactModule(name = "StatusBarManager")
public class StatusBarModule extends ReactContextBaseJavaModule { public class StatusBarModule extends ReactContextBaseJavaModule {
private static final String ERROR_NO_ACTIVITY = "E_NO_ACTIVITY"; private static final String ERROR_NO_ACTIVITY = "E_NO_ACTIVITY";
@ -49,6 +47,11 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "StatusBarManager";
}
@Override @Override
public @Nullable Map<String, Object> getConstants() { public @Nullable Map<String, Object> getConstants() {
final Context context = getReactApplicationContext(); final Context context = getReactApplicationContext();
@ -58,7 +61,8 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
0; 0;
return MapBuilder.<String, Object>of( return MapBuilder.<String, Object>of(
HEIGHT_KEY, height); HEIGHT_KEY, height
);
} }
@ReactMethod @ReactMethod
@ -95,7 +99,8 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
} }
res.resolve(null); res.resolve(null);
} }
}); }
);
} else { } else {
res.resolve(null); res.resolve(null);
} }
@ -138,7 +143,8 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
ViewCompat.requestApplyInsets(decorView); ViewCompat.requestApplyInsets(decorView);
res.resolve(null); res.resolve(null);
} }
}); }
);
} }
} }
@ -163,6 +169,7 @@ public class StatusBarModule extends ReactContextBaseJavaModule {
res.resolve(null); res.resolve(null);
} }
}); }
);
} }
} }

View File

@ -24,7 +24,6 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.SetBuilder; import com.facebook.react.common.SetBuilder;
import com.facebook.react.modules.common.ModuleDataCleaner; import com.facebook.react.modules.common.ModuleDataCleaner;
@ -33,7 +32,6 @@ import static com.facebook.react.modules.storage.ReactDatabaseSupplier.KEY_COLUM
import static com.facebook.react.modules.storage.ReactDatabaseSupplier.TABLE_CATALYST; import static com.facebook.react.modules.storage.ReactDatabaseSupplier.TABLE_CATALYST;
import static com.facebook.react.modules.storage.ReactDatabaseSupplier.VALUE_COLUMN; import static com.facebook.react.modules.storage.ReactDatabaseSupplier.VALUE_COLUMN;
@ReactModule(name = "AsyncSQLiteDBStorage")
public final class AsyncStorageModule public final class AsyncStorageModule
extends ReactContextBaseJavaModule implements ModuleDataCleaner.Cleanable { extends ReactContextBaseJavaModule implements ModuleDataCleaner.Cleanable {
@ -49,6 +47,11 @@ public final class AsyncStorageModule
mReactDatabaseSupplier = ReactDatabaseSupplier.getInstance(reactContext); mReactDatabaseSupplier = ReactDatabaseSupplier.getInstance(reactContext);
} }
@Override
public String getName() {
return "AsyncSQLiteDBStorage";
}
@Override @Override
public void initialize() { public void initialize() {
super.initialize(); super.initialize();

View File

@ -12,7 +12,6 @@ package com.facebook.react.modules.systeminfo;
import android.os.Build; import android.os.Build;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.annotations.ReactModule;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -22,9 +21,13 @@ import javax.annotation.Nullable;
/** /**
* Module that exposes Android Constants to JS. * Module that exposes Android Constants to JS.
*/ */
@ReactModule(name = "AndroidConstants")
public class AndroidInfoModule extends BaseJavaModule { public class AndroidInfoModule extends BaseJavaModule {
@Override
public String getName() {
return "AndroidConstants";
}
@Override @Override
public @Nullable Map<String, Object> getConstants() { public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>(); HashMap<String, Object> constants = new HashMap<String, Object>();

View File

@ -11,6 +11,7 @@ package com.facebook.react.modules.timepicker;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Map;
import android.app.Activity; import android.app.Activity;
import android.app.DialogFragment; import android.app.DialogFragment;
@ -29,14 +30,12 @@ import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.common.annotations.VisibleForTesting;
/** /**
* {@link NativeModule} that allows JS to show a native time picker dialog and get called back when * {@link NativeModule} that allows JS to show a native time picker dialog and get called back when
* the user selects a time. * the user selects a time.
*/ */
@ReactModule(name = "TimePickerAndroid")
public class TimePickerDialogModule extends ReactContextBaseJavaModule { public class TimePickerDialogModule extends ReactContextBaseJavaModule {
@VisibleForTesting @VisibleForTesting
@ -54,6 +53,11 @@ public class TimePickerDialogModule extends ReactContextBaseJavaModule {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "TimePickerAndroid";
}
private class TimePickerDialogListener implements OnTimeSetListener, OnDismissListener { private class TimePickerDialogListener implements OnTimeSetListener, OnDismissListener {
private final Promise mPromise; private final Promise mPromise;
@ -102,7 +106,7 @@ public class TimePickerDialogModule extends ReactContextBaseJavaModule {
android.support.v4.app.FragmentManager fragmentManager = android.support.v4.app.FragmentManager fragmentManager =
((android.support.v4.app.FragmentActivity) activity).getSupportFragmentManager(); ((android.support.v4.app.FragmentActivity) activity).getSupportFragmentManager();
android.support.v4.app.DialogFragment oldFragment = android.support.v4.app.DialogFragment oldFragment =
(android.support.v4.app.DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG); (android.support.v4.app.DialogFragment)fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (oldFragment != null) { if (oldFragment != null) {
oldFragment.dismiss(); oldFragment.dismiss();
} }

View File

@ -16,7 +16,6 @@ import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.MapBuilder; import com.facebook.react.common.MapBuilder;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
@ -25,7 +24,6 @@ import java.util.Map;
/** /**
* {@link NativeModule} that allows JS to show an Android Toast. * {@link NativeModule} that allows JS to show an Android Toast.
*/ */
@ReactModule(name = "ToastAndroid")
public class ToastModule extends ReactContextBaseJavaModule { public class ToastModule extends ReactContextBaseJavaModule {
private static final String DURATION_SHORT_KEY = "SHORT"; private static final String DURATION_SHORT_KEY = "SHORT";
@ -39,6 +37,11 @@ public class ToastModule extends ReactContextBaseJavaModule {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "ToastAndroid";
}
@Override @Override
public Map<String, Object> getConstants() { public Map<String, Object> getConstants() {
final Map<String, Object> constants = MapBuilder.newHashMap(); final Map<String, Object> constants = MapBuilder.newHashMap();

View File

@ -16,15 +16,18 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.annotations.ReactModule;
@ReactModule(name = "Vibration")
public class VibrationModule extends ReactContextBaseJavaModule { public class VibrationModule extends ReactContextBaseJavaModule {
public VibrationModule(ReactApplicationContext reactContext) { public VibrationModule(ReactApplicationContext reactContext) {
super(reactContext); super(reactContext);
} }
@Override
public String getName() {
return "Vibration";
}
@ReactMethod @ReactMethod
public void vibrate(int duration) { public void vibrate(int duration) {
Vibrator v = (Vibrator) getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); Vibrator v = (Vibrator) getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);

View File

@ -26,7 +26,6 @@ import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator; import com.facebook.react.bridge.ReadableMapKeySetIterator;
import com.facebook.react.bridge.ReadableType; import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.modules.core.DeviceEventManagerModule;
@ -48,7 +47,6 @@ import java.util.concurrent.TimeUnit;
import okio.Buffer; import okio.Buffer;
import okio.ByteString; import okio.ByteString;
@ReactModule(name = "WebSocketModule")
public class WebSocketModule extends ReactContextBaseJavaModule { public class WebSocketModule extends ReactContextBaseJavaModule {
private Map<Integer, WebSocket> mWebSocketConnections = new HashMap<>(); private Map<Integer, WebSocket> mWebSocketConnections = new HashMap<>();
@ -65,6 +63,11 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
.emit(eventName, params); .emit(eventName, params);
} }
@Override
public String getName() {
return "WebSocketModule";
}
@ReactMethod @ReactMethod
public void connect(final String url, @Nullable final ReadableArray protocols, @Nullable final ReadableMap headers, final int id) { public void connect(final String url, @Nullable final ReadableArray protocols, @Nullable final ReadableMap headers, final int id) {
OkHttpClient client = new OkHttpClient.Builder() OkHttpClient client = new OkHttpClient.Builder()
@ -270,8 +273,10 @@ public class WebSocketModule extends ReactContextBaseJavaModule {
} }
return defaultOrigin; return defaultOrigin;
} catch (URISyntaxException e) {
} catch(URISyntaxException e) {
throw new IllegalArgumentException("Unable to set " + uri + " as default origin header."); throw new IllegalArgumentException("Unable to set " + uri + " as default origin header.");
} }
} }
} }

View File

@ -24,9 +24,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.annotations.ReactModule;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
import com.facebook.react.uimanager.DisplayMetricsHolder;
import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace; import com.facebook.systrace.Systrace;
@ -61,7 +59,6 @@ import com.facebook.systrace.SystraceMessage;
* consider implementing a pool * consider implementing a pool
* TODO(5483063): Don't dispatch the view hierarchy at the end of a batch if no UI changes occurred * TODO(5483063): Don't dispatch the view hierarchy at the end of a batch if no UI changes occurred
*/ */
@ReactModule(name = "RKUIManager")
public class UIManagerModule extends ReactContextBaseJavaModule implements public class UIManagerModule extends ReactContextBaseJavaModule implements
OnBatchCompleteListener, LifecycleEventListener { OnBatchCompleteListener, LifecycleEventListener {
@ -98,6 +95,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
return mUIImplementation; return mUIImplementation;
} }
@Override
public String getName() {
return "RKUIManager";
}
@Override @Override
public Map<String, Object> getConstants() { public Map<String, Object> getConstants() {
return mModuleConstants; return mModuleConstants;

View File

@ -20,14 +20,12 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.annotations.ReactModule;
/** /**
* Native module that can asynchronously request the owners hierarchy of a react tag. * Native module that can asynchronously request the owners hierarchy of a react tag.
* *
* Example returned owner hierarchy: ['RootView', 'Dialog', 'TitleView', 'Text'] * Example returned owner hierarchy: ['RootView', 'Dialog', 'TitleView', 'Text']
*/ */
@ReactModule(name = "DebugComponentOwnershipModule")
public class DebugComponentOwnershipModule extends ReactContextBaseJavaModule { public class DebugComponentOwnershipModule extends ReactContextBaseJavaModule {
public interface RCTDebugComponentOwnership extends JavaScriptModule { public interface RCTDebugComponentOwnership extends JavaScriptModule {
@ -94,4 +92,9 @@ public class DebugComponentOwnershipModule extends ReactContextBaseJavaModule {
mRequestIdToCallback.put(requestId, callback); mRequestIdToCallback.put(requestId, callback);
Assertions.assertNotNull(mRCTDebugComponentOwnership).getOwnerHierarchy(requestId, tag); Assertions.assertNotNull(mRCTDebugComponentOwnership).getOwnerHierarchy(requestId, tag);
} }
@Override
public String getName() {
return "DebugComponentOwnershipModule";
}
} }