From 705daabbb1fa8725e20e4fea0ec7174d5fc6aebc Mon Sep 17 00:00:00 2001 From: Aaron Chiu Date: Fri, 12 Aug 2016 15:49:13 -0700 Subject: [PATCH] Reverted commit D3334273 Reviewed By: astreet Differential Revision: D3334273 fbshipit-source-id: a3849604ea89db74900850c294685e7da9aeeacc --- .../testing/AbstractScrollViewTestCase.java | 9 ++++++--- .../facebook/react/testing/AssertModule.java | 7 +++++-- .../react/testing/FakeAsyncLocalStorage.java | 7 +++++-- .../react/testing/IntRecordingModule.java | 7 +++++-- .../testing/JSIntegrationTestChecker.java | 7 +++++-- .../testing/NetworkRecordingModuleMock.java | 7 +++++-- .../react/testing/StringRecordingModule.java | 7 +++++-- ...alystNativeJSToJavaParametersTestCase.java | 7 +++++-- .../react/tests/InitialPropsTestCase.java | 11 ++++++---- .../react/devsupport/JSCHeapCapture.java | 7 +++++-- .../modules/appstate/AppStateModule.java | 7 +++++-- .../modules/camera/CameraRollManager.java | 8 ++++++-- .../modules/camera/ImageEditingManager.java | 9 +++++++-- .../modules/camera/ImageStoreManager.java | 7 +++++-- .../modules/clipboard/ClipboardModule.java | 20 +++++++++++++++---- .../core/DeviceEventManagerModule.java | 7 +++++-- .../modules/core/ExceptionsManagerModule.java | 7 +++++-- .../facebook/react/modules/core/Timing.java | 9 ++++++--- .../datepicker/DatePickerDialogModule.java | 11 ++++++---- .../modules/debug/AnimationsDebugModule.java | 7 +++++-- .../react/modules/debug/SourceCodeModule.java | 11 ++++++++-- .../react/modules/dialog/DialogModule.java | 10 ++++++++-- .../react/modules/fresco/FrescoModule.java | 7 +++++-- .../i18nmanager/I18nManagerModule.java | 19 +++++++++++------- .../modules/image/ImageLoaderModule.java | 11 ++++++---- .../react/modules/intent/IntentModule.java | 7 +++++-- .../modules/location/LocationModule.java | 7 +++++-- .../react/modules/netinfo/NetInfoModule.java | 7 +++++-- .../modules/network/NetworkingModule.java | 7 +++++-- .../permissions/PermissionsModule.java | 7 +++++-- .../react/modules/share/ShareModule.java | 14 ++++++++++--- .../modules/statusbar/StatusBarModule.java | 19 ++++++++++++------ .../modules/storage/AsyncStorageModule.java | 7 +++++-- .../modules/systeminfo/AndroidInfoModule.java | 7 +++++-- .../timepicker/TimePickerDialogModule.java | 10 +++++++--- .../react/modules/toast/ToastModule.java | 7 +++++-- .../modules/vibration/VibrationModule.java | 7 +++++-- .../modules/websocket/WebSocketModule.java | 11 +++++++--- .../react/uimanager/UIManagerModule.java | 8 +++++--- .../debug/DebugComponentOwnershipModule.java | 7 +++++-- 40 files changed, 255 insertions(+), 103 deletions(-) diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AbstractScrollViewTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AbstractScrollViewTestCase.java index 4dc76619b..afdf4bc90 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AbstractScrollViewTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AbstractScrollViewTestCase.java @@ -15,7 +15,6 @@ import java.util.concurrent.TimeUnit; import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.JavaScriptModule; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.testing.ReactInstanceSpecForTest; import com.facebook.react.testing.ReactAppInstrumentationTestCase; @@ -46,8 +45,6 @@ public abstract class AbstractScrollViewTestCase extends ReactAppInstrumentation } // See ScrollViewListenerModule.js - // Matches ScrollViewListenerModule.js - @ReactModule(name = "ScrollListener") protected static class ScrollListenerModule extends BaseJavaModule { private final ArrayList mXOffsets = new ArrayList(); @@ -57,6 +54,12 @@ public abstract class AbstractScrollViewTestCase extends ReactAppInstrumentation private boolean mScrollBeginDragCalled; private boolean mScrollEndDragCalled; + // Matches ScrollViewListenerModule.js + @Override + public String getName() { + return "ScrollListener"; + } + @ReactMethod public void onScroll(double x, double y) { mXOffsets.add(x); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AssertModule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AssertModule.java index b9b7060e1..437947016 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AssertModule.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AssertModule.java @@ -12,7 +12,6 @@ import javax.annotation.Nullable; import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.annotations.ReactModule; import static junit.framework.Assert.assertFalse; 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. */ -@ReactModule(name = "Assert") public class AssertModule extends BaseJavaModule { private boolean mGotSuccess; private boolean mGotFailure; private @Nullable String mFirstFailureStackTrace; + @Override + public String getName() { + return "Assert"; + } + @ReactMethod public void fail(String stackTrace) { if (!mGotFailure) { diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeAsyncLocalStorage.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeAsyncLocalStorage.java index a5daaa34e..e62d09ecb 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeAsyncLocalStorage.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/FakeAsyncLocalStorage.java @@ -14,12 +14,10 @@ import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.annotations.ReactModule; /** * Dummy implementation of storage module, used for testing */ -@ReactModule(name = "AsyncSQLiteDBStorage") public final class FakeAsyncLocalStorage extends BaseJavaModule { private static WritableMap errorMessage; @@ -28,6 +26,11 @@ public final class FakeAsyncLocalStorage extends BaseJavaModule { errorMessage.putString("message", "Fake Async Local Storage"); } + @Override + public String getName() { + return "AsyncSQLiteDBStorage"; + } + @ReactMethod public void multiGet(final ReadableArray keys, final Callback callback) { callback.invoke(errorMessage, null); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/IntRecordingModule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/IntRecordingModule.java index 5ceddde42..5cf7e4373 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/IntRecordingModule.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/IntRecordingModule.java @@ -15,18 +15,21 @@ import java.util.concurrent.TimeUnit; import com.facebook.react.bridge.BaseJavaModule; 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 * in calls array */ -@ReactModule(name = "Recording") public class IntRecordingModule extends BaseJavaModule { private final List mCalls = new ArrayList<>(); private final CountDownLatch mCountDownLatch = new CountDownLatch(1); + @Override + public String getName() { + return "Recording"; + } + @ReactMethod public void record(int i) { mCalls.add(i); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/JSIntegrationTestChecker.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/JSIntegrationTestChecker.java index acc2f39b4..1ddf186c9 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/JSIntegrationTestChecker.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/JSIntegrationTestChecker.java @@ -14,7 +14,6 @@ import java.util.concurrent.TimeUnit; import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.Callback; 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. @@ -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 * completed successfully. */ -@ReactModule(name = "TestModule") public class JSIntegrationTestChecker extends BaseJavaModule { private final CountDownLatch mLatch; @@ -33,6 +31,11 @@ public class JSIntegrationTestChecker extends BaseJavaModule { mLatch = new CountDownLatch(1); } + @Override + public String getName() { + return "TestModule"; + } + @ReactMethod public void markTestCompleted() { mLatch.countDown(); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/NetworkRecordingModuleMock.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/NetworkRecordingModuleMock.java index dcf9d1c27..4c0b68b6d 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/NetworkRecordingModuleMock.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/NetworkRecordingModuleMock.java @@ -19,14 +19,12 @@ import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.modules.core.DeviceEventManagerModule; /** * 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} */ -@ReactModule(name = "RCTNetworking") public class NetworkRecordingModuleMock extends ReactContextBaseJavaModule { public int mRequestCount = 0; @@ -65,6 +63,11 @@ public class NetworkRecordingModuleMock extends ReactContextBaseJavaModule { mRequestListener = requestListener; } + @Override + public final String getName() { + return "RCTNetworking"; + } + private void fireReactCallback( Callback callback, int status, diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/StringRecordingModule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/StringRecordingModule.java index ae6148027..8caa3b8f7 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/StringRecordingModule.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/StringRecordingModule.java @@ -13,17 +13,20 @@ import java.util.List; import com.facebook.react.bridge.BaseJavaModule; 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 * in calls array */ -@ReactModule(name = "Recording") public class StringRecordingModule extends BaseJavaModule { private final List mCalls = new ArrayList(); + @Override + public String getName() { + return "Recording"; + } + @ReactMethod public void record(String text) { mCalls.add(text); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java index a91c9ceb4..06ff91a0c 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java @@ -29,7 +29,6 @@ import com.facebook.react.bridge.UnexpectedNativeTypeException; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.modules.systeminfo.AndroidInfoModule; import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; @@ -669,13 +668,17 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe } } - @ReactModule(name = "Recording") private class RecordingTestModule extends BaseJavaModule { private final List mBasicTypesCalls = new ArrayList(); private final List mArrayCalls = new ArrayList(); private final List mMapCalls = new ArrayList(); + @Override + public String getName() { + return "Recording"; + } + @ReactMethod public void receiveBasicTypes(String s, double d, boolean b, String nullableString) { mBasicTypesCalls.add(new Object[]{s, d, b, nullableString}); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java index 8d00897bc..951c59353 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/InitialPropsTestCase.java @@ -12,13 +12,12 @@ import android.os.Bundle; import android.test.ActivityInstrumentationTestCase2; 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.ReadableArray; import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactAppTestActivity; -import com.facebook.react.testing.ReactInstanceSpecForTest; /** * 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"; - @ReactModule(name = "InitialPropsRecordingModule") private static class RecordingModule extends BaseJavaModule { private int mCount = 0; private ReadableMap mProps; + @Override + public String getName() { + return "InitialPropsRecordingModule"; + } + @ReactMethod public void recordProps(ReadableMap props) { mProps = props; diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java index c243eebc4..a8824fd79 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java @@ -20,9 +20,7 @@ import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.annotations.ReactModule; -@ReactModule(name = "JSCHeapCapture") public class JSCHeapCapture extends ReactContextBaseJavaModule { public interface HeapCapture extends JavaScriptModule { void captureHeap(String path); @@ -134,6 +132,11 @@ public class JSCHeapCapture extends ReactContextBaseJavaModule { } } + @Override + public String getName() { + return "JSCHeapCapture"; + } + @Override public void initialize() { super.initialize(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/AppStateModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/AppStateModule.java index fd58cc2f6..a3daa95a7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/AppStateModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/appstate/AppStateModule.java @@ -16,10 +16,8 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter; -@ReactModule(name = "AppState") public class AppStateModule extends ReactContextBaseJavaModule implements LifecycleEventListener { @@ -32,6 +30,11 @@ public class AppStateModule extends ReactContextBaseJavaModule super(reactContext); } + @Override + public String getName() { + return "AppState"; + } + @Override public void initialize() { getReactApplicationContext().addLifecycleEventListener(this); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java index 073a01bc1..c103f445a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/CameraRollManager.java @@ -50,7 +50,6 @@ import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeArray; import com.facebook.react.bridge.WritableNativeMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.ReactConstants; // 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 MediaStore.Images}). */ -@ReactModule(name = "RKCameraRollManager") public class CameraRollManager extends ReactContextBaseJavaModule { private static final String ERROR_UNABLE_TO_LOAD = "E_UNABLE_TO_LOAD"; @@ -100,6 +98,11 @@ public class CameraRollManager extends ReactContextBaseJavaModule { super(reactContext); } + @Override + public String getName() { + return "RKCameraRollManager"; + } + @Override public Map getConstants() { return Collections.emptyMap(); @@ -437,4 +440,5 @@ public class CameraRollManager extends ReactContextBaseJavaModule { node.putMap("location", location); } } + } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/ImageEditingManager.java b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/ImageEditingManager.java index 0bf9e56ff..952d92322 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/ImageEditingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/ImageEditingManager.java @@ -46,13 +46,11 @@ import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReadableMap; import com.facebook.infer.annotation.Assertions; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.ReactConstants; /** * Native module that provides image cropping functionality. */ -@ReactModule(name = "RKImageEditingManager") public class ImageEditingManager extends ReactContextBaseJavaModule { private static final List LOCAL_URI_PREFIXES = Arrays.asList( @@ -91,11 +89,17 @@ public class ImageEditingManager extends ReactContextBaseJavaModule { ExifInterface.TAG_WHITE_BALANCE }; + public ImageEditingManager(ReactApplicationContext reactContext) { super(reactContext); new CleanTask(getReactApplicationContext()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } + @Override + public String getName() { + return "RKImageEditingManager"; + } + @Override public Map getConstants() { return Collections.emptyMap(); @@ -278,6 +282,7 @@ public class ImageEditingManager extends ReactContextBaseJavaModule { } mSuccess.invoke(Uri.fromFile(tempFile).toString()); + } catch (Exception e) { mError.invoke(e.getMessage()); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/ImageStoreManager.java b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/ImageStoreManager.java index 3c140005e..68329f42a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/camera/ImageStoreManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/camera/ImageStoreManager.java @@ -27,9 +27,7 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.annotations.ReactModule; -@ReactModule(name = "ImageStoreManager") public class ImageStoreManager extends ReactContextBaseJavaModule { private static final int BUFFER_SIZE = 8192; @@ -38,6 +36,11 @@ public class ImageStoreManager extends ReactContextBaseJavaModule { super(reactContext); } + @Override + public String getName() { + return "ImageStoreManager"; + } + /** * Calculate the base64 representation for an image. The "tag" comes from iOS naming. * diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.java index 597c545c9..a51f93e7c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.java @@ -14,29 +14,41 @@ import android.content.ClipboardManager; import android.content.ClipData; 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.ReactContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; 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. */ -@ReactModule(name = "Clipboard") public class ClipboardModule extends ReactContextBaseJavaModule { public ClipboardModule(ReactApplicationContext reactContext) { super(reactContext); } + @Override + public String getName() { + return "Clipboard"; + } + private ClipboardManager getClipboardService() { return (ClipboardManager) getReactApplicationContext().getSystemService(getReactApplicationContext().CLIPBOARD_SERVICE); } @ReactMethod - public void getString(Promise promise) { + public void getString(Promise promise){ try { ClipboardManager clipboard = getClipboardService(); ClipData clipData = clipboard.getPrimaryClip(); @@ -48,7 +60,7 @@ public class ClipboardModule extends ReactContextBaseJavaModule { } else { promise.resolve(""); } - } catch (Exception e) { + } catch(Exception e) { promise.reject(e); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.java index 4e440aac6..d28cf84f1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.java @@ -21,12 +21,10 @@ import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.SupportsWebWorkers; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.annotations.ReactModule; /** * Native module that handles device hardware events like hardware back presses. */ -@ReactModule(name = "DeviceEventManager") public class DeviceEventManagerModule extends ReactContextBaseJavaModule { @SupportsWebWorkers @@ -77,4 +75,9 @@ public class DeviceEventManagerModule extends ReactContextBaseJavaModule { public void invokeDefaultBackPressHandler() { getReactApplicationContext().runOnUiQueueThread(mInvokeDefaultBackPressRunnable); } + + @Override + public String getName() { + return "DeviceEventManager"; + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java index b3d1ef8ee..c5ad60e59 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java @@ -18,12 +18,10 @@ import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableType; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.devsupport.DevSupportManager; import com.facebook.react.common.JavascriptException; import com.facebook.react.common.ReactConstants; -@ReactModule(name = "RKExceptionsManager") public class ExceptionsManagerModule extends BaseJavaModule { static private final Pattern mJsModuleIdPattern = Pattern.compile("(?:^|[/\\\\])(\\d+\\.js)$"); @@ -33,6 +31,11 @@ public class ExceptionsManagerModule extends BaseJavaModule { 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 // 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. diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java index 8bc771ac3..2fc348e8d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java @@ -22,7 +22,6 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.WritableArray; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.SystemClock; import com.facebook.react.devsupport.DevSupportManager; 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. */ -@ReactModule(name = "RKTiming") public final class Timing extends ReactContextBaseJavaModule implements LifecycleEventListener, OnExecutorUnregisteredListener { @@ -164,7 +162,7 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl long time = SystemClock.currentTimeMillis(); 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; } @@ -301,6 +299,11 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl } } + @Override + public String getName() { + return "RCTTiming"; + } + @Override public boolean supportsWebWorkers() { return true; diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java index 00130efd4..6f76ea7e4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java @@ -30,14 +30,12 @@ import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.annotations.VisibleForTesting; /** * {@link NativeModule} that allows JS to show a native date picker dialog and get called back when * the user selects a date. */ -@ReactModule(name = "DatePickerAndroid") public class DatePickerDialogModule extends ReactContextBaseJavaModule { @VisibleForTesting @@ -56,6 +54,11 @@ public class DatePickerDialogModule extends ReactContextBaseJavaModule { super(reactContext); } + @Override + public String getName() { + return "DatePickerAndroid"; + } + private class DatePickerDialogListener implements OnDateSetListener, OnDismissListener { private final Promise mPromise; @@ -126,7 +129,7 @@ public class DatePickerDialogModule extends ReactContextBaseJavaModule { android.support.v4.app.FragmentManager fragmentManager = ((android.support.v4.app.FragmentActivity) activity).getSupportFragmentManager(); 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) { oldFragment.dismiss(); } @@ -141,7 +144,7 @@ public class DatePickerDialogModule extends ReactContextBaseJavaModule { fragment.show(fragmentManager, FRAGMENT_TAG); } else { FragmentManager fragmentManager = activity.getFragmentManager(); - DialogFragment oldFragment = (DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG); + DialogFragment oldFragment = (DialogFragment)fragmentManager.findFragmentByTag(FRAGMENT_TAG); if (oldFragment != null) { oldFragment.dismiss(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/AnimationsDebugModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/AnimationsDebugModule.java index 58af96935..dc9664581 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/AnimationsDebugModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/AnimationsDebugModule.java @@ -22,14 +22,12 @@ import com.facebook.react.bridge.JSApplicationCausedNativeException; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.ReactConstants; /** * Module that records debug information during transitions (animated navigation events such as * going from one screen to another). */ -@ReactModule(name = "AnimationsDebugModule") public class AnimationsDebugModule extends ReactContextBaseJavaModule { private @Nullable FpsDebugFrameCallback mFrameCallback; @@ -42,6 +40,11 @@ public class AnimationsDebugModule extends ReactContextBaseJavaModule { mCatalystSettings = catalystSettings; } + @Override + public String getName() { + return "AnimationsDebugModule"; + } + @ReactMethod public void startRecordingFps() { if (mCatalystSettings == null || diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.java index 9eb102527..71aba3511 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/SourceCodeModule.java @@ -14,13 +14,15 @@ import javax.annotation.Nullable; import java.util.HashMap; import java.util.Map; +import com.facebook.react.bridge.Promise; 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 */ -@ReactModule(name = "RCTSourceCode") public class SourceCodeModule extends BaseJavaModule { private final String mSourceUrl; @@ -29,6 +31,11 @@ public class SourceCodeModule extends BaseJavaModule { mSourceUrl = sourceUrl; } + @Override + public String getName() { + return "RCTSourceCode"; + } + @Override public @Nullable Map getConstants() { HashMap constants = new HashMap(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java index f58303d22..a9bbedc14 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java @@ -21,6 +21,7 @@ import android.os.Bundle; import android.support.v4.app.FragmentActivity; import com.facebook.common.logging.FLog; +import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.LifecycleEventListener; 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.ReadableArray; import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.MapBuilder; -@ReactModule(name = "DialogManagerAndroid") public class DialogModule extends ReactContextBaseJavaModule implements LifecycleEventListener { /* package */ static final String FRAGMENT_TAG = "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_DISMISSED = "dismissed"; /* package */ static final String KEY_TITLE = "title"; @@ -60,6 +61,11 @@ public class DialogModule extends ReactContextBaseJavaModule implements Lifecycl super(reactContext); } + @Override + public String getName() { + return NAME; + } + /** * 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). diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/FrescoModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/FrescoModule.java index be2c48e27..210f89e35 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/FrescoModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/fresco/FrescoModule.java @@ -25,7 +25,6 @@ import com.facebook.imagepipeline.core.ImagePipelineFactory; import com.facebook.imagepipeline.listener.RequestListener; import com.facebook.react.bridge.ReactApplicationContext; 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.network.OkHttpClientProvider; import com.facebook.soloader.SoLoader; @@ -37,7 +36,6 @@ import okhttp3.OkHttpClient; * *

Does not expose any methods to JavaScript code. For initialization and cleanup only. */ -@ReactModule(name = "FrescoModule", needsEagerInit = true) public class FrescoModule extends ReactContextBaseJavaModule implements ModuleDataCleaner.Cleanable { @@ -75,6 +73,11 @@ public class FrescoModule extends ReactContextBaseJavaModule implements mConfig = null; } + @Override + public String getName() { + return "FrescoModule"; + } + @Override public void clearSensitiveData() { // Clear image cache. diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java index 1f9f1d2d9..feefb593c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nManagerModule.java @@ -11,17 +11,17 @@ package com.facebook.react.modules.i18nmanager; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.MapBuilder; import java.util.Map; + /** * {@link NativeModule} that allows JS to set allowRTL and get isRTL status. */ -@ReactModule(name = "I18nManager") public class I18nManagerModule extends ReactContextBaseJavaModule { private final I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance(); @@ -30,12 +30,15 @@ public class I18nManagerModule extends ReactContextBaseJavaModule { super(reactContext); } + @Override + public String getName() { + return "I18nManager"; + } + @Override public Map getConstants() { final Map constants = MapBuilder.newHashMap(); - constants.put( - "isRTL", - sharedI18nUtilInstance.isRTL( + constants.put("isRTL", sharedI18nUtilInstance.isRTL( getReactApplicationContext() )); return constants; @@ -45,13 +48,15 @@ public class I18nManagerModule extends ReactContextBaseJavaModule { public void allowRTL(boolean value) { sharedI18nUtilInstance.allowRTL( getReactApplicationContext(), - value); + value + ); } @ReactMethod public void forceRTL(boolean value) { sharedI18nUtilInstance.forceRTL( getReactApplicationContext(), - value); + value + ); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/image/ImageLoaderModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/image/ImageLoaderModule.java index 999dda97a..54730146d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/image/ImageLoaderModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/image/ImageLoaderModule.java @@ -30,11 +30,9 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.annotations.ReactModule; -@ReactModule(name = "ImageLoader") -public class ImageLoaderModule extends ReactContextBaseJavaModule - implements LifecycleEventListener { +public class ImageLoaderModule extends ReactContextBaseJavaModule implements + LifecycleEventListener { private static final String ERROR_INVALID_URI = "E_INVALID_URI"; private static final String ERROR_PREFETCH_FAILURE = "E_PREFETCH_FAILURE"; @@ -54,6 +52,11 @@ public class ImageLoaderModule extends ReactContextBaseJavaModule mCallerContext = callerContext; } + @Override + public String getName() { + return "ImageLoader"; + } + /** * Fetch the width and height of the given image. * diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java index efeb88bd2..8139797ae 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java @@ -19,18 +19,21 @@ import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.annotations.ReactModule; /** * Intent module. Launch other activities or open URLs. */ -@ReactModule(name = "IntentAndroid") public class IntentModule extends ReactContextBaseJavaModule { public IntentModule(ReactApplicationContext reactContext) { super(reactContext); } + @Override + public String getName() { + return "IntentAndroid"; + } + /** * Return the URL the activity was started with * diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java index 005ca5b5c..9aa887b50 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java @@ -27,14 +27,12 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.SystemClock; import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter; /** * Native module that exposes Geolocation to JS. */ -@ReactModule(name = "LocationObserver") public class LocationModule extends ReactContextBaseJavaModule { private @Nullable String mWatchedProvider; @@ -67,6 +65,11 @@ public class LocationModule extends ReactContextBaseJavaModule { super(reactContext); } + @Override + public String getName() { + return "LocationObserver"; + } + private static class LocationOptions { private final long timeout; private final double maximumAge; diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/netinfo/NetInfoModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/netinfo/NetInfoModule.java index c2424c487..1b8b93cbe 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/netinfo/NetInfoModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/netinfo/NetInfoModule.java @@ -24,14 +24,12 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeMap; -import com.facebook.react.bridge.annotations.ReactModule; import static com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter; /** * Module that monitors and provides information about the connectivity state of the device. */ -@ReactModule(name = "NetInfo") public class NetInfoModule extends ReactContextBaseJavaModule implements LifecycleEventListener { @@ -75,6 +73,11 @@ public class NetInfoModule extends ReactContextBaseJavaModule getReactApplicationContext().addLifecycleEventListener(this); } + @Override + public String getName() { + return "NetInfo"; + } + @ReactMethod public void getCurrentConnectivity(Promise promise) { if (mNoNetworkPermission) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java index f82e9e073..50f31239c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java @@ -30,7 +30,6 @@ import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.network.OkHttpCallUtil; import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter; @@ -50,7 +49,6 @@ import okhttp3.ResponseBody; /** * Implements the XMLHttpRequest JavaScript interface. */ -@ReactModule(name = "RCTNetworking") public final class NetworkingModule extends ReactContextBaseJavaModule { 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)); } + @Override + public String getName() { + return "RCTNetworking"; + } + @Override public void onCatalystInstanceDestroy() { mShuttingDown = true; diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.java index 4264c6bd0..fd09476b6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.java @@ -19,14 +19,12 @@ import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; 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.PermissionListener; /** * Module that exposes the Android M Permission system to JS. */ -@ReactModule(name = "AndroidPermissions") public class PermissionsModule extends ReactContextBaseJavaModule implements PermissionListener { private final SparseArray mCallbacks; @@ -37,6 +35,11 @@ public class PermissionsModule extends ReactContextBaseJavaModule implements Per mCallbacks = new SparseArray(); } + @Override + public String getName() { + return "AndroidPermissions"; + } + /** * 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}. diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/share/ShareModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/share/ShareModule.java index 5b170ed58..eee2a42ca 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/share/ShareModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/share/ShareModule.java @@ -11,20 +11,21 @@ package com.facebook.react.modules.share; import android.app.Activity; import android.content.Intent; +import android.net.Uri; import com.facebook.react.bridge.Arguments; +import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableMap; 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. */ -@ReactModule(name = "ShareModule") public class ShareModule extends ReactContextBaseJavaModule { /* package */ static final String ACTION_SHARED = "sharedAction"; @@ -35,6 +36,11 @@ public class ShareModule extends ReactContextBaseJavaModule { super(reactContext); } + @Override + public String getName() { + return "ShareModule"; + } + /** * Open a chooser dialog to send text content to other apps. * @@ -74,9 +80,11 @@ public class ShareModule extends ReactContextBaseJavaModule { WritableMap result = Arguments.createMap(); result.putString("action", ACTION_SHARED); promise.resolve(result); + } catch (Exception e) { promise.reject(ERROR_UNABLE_TO_OPEN_DIALOG, "Failed to open share dialog"); } + } -} +} \ No newline at end of file diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java index 1a9430e8b..76554b7e4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.java @@ -29,14 +29,12 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.UiThreadUtil; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.MapBuilder; import com.facebook.react.uimanager.PixelUtil; /** * {@link NativeModule} that allows changing the appearance of the status bar. */ -@ReactModule(name = "StatusBarManager") public class StatusBarModule extends ReactContextBaseJavaModule { private static final String ERROR_NO_ACTIVITY = "E_NO_ACTIVITY"; @@ -49,6 +47,11 @@ public class StatusBarModule extends ReactContextBaseJavaModule { super(reactContext); } + @Override + public String getName() { + return "StatusBarManager"; + } + @Override public @Nullable Map getConstants() { final Context context = getReactApplicationContext(); @@ -58,7 +61,8 @@ public class StatusBarModule extends ReactContextBaseJavaModule { 0; return MapBuilder.of( - HEIGHT_KEY, height); + HEIGHT_KEY, height + ); } @ReactMethod @@ -95,7 +99,8 @@ public class StatusBarModule extends ReactContextBaseJavaModule { } res.resolve(null); } - }); + } + ); } else { res.resolve(null); } @@ -138,7 +143,8 @@ public class StatusBarModule extends ReactContextBaseJavaModule { ViewCompat.requestApplyInsets(decorView); res.resolve(null); } - }); + } + ); } } @@ -163,6 +169,7 @@ public class StatusBarModule extends ReactContextBaseJavaModule { res.resolve(null); } - }); + } + ); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/storage/AsyncStorageModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/storage/AsyncStorageModule.java index 98dc47c9d..35b615066 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/storage/AsyncStorageModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/storage/AsyncStorageModule.java @@ -24,7 +24,6 @@ import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.ReactConstants; import com.facebook.react.common.SetBuilder; 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.VALUE_COLUMN; -@ReactModule(name = "AsyncSQLiteDBStorage") public final class AsyncStorageModule extends ReactContextBaseJavaModule implements ModuleDataCleaner.Cleanable { @@ -49,6 +47,11 @@ public final class AsyncStorageModule mReactDatabaseSupplier = ReactDatabaseSupplier.getInstance(reactContext); } + @Override + public String getName() { + return "AsyncSQLiteDBStorage"; + } + @Override public void initialize() { super.initialize(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java index 3353c48c1..7ef7dee01 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java @@ -12,7 +12,6 @@ package com.facebook.react.modules.systeminfo; import android.os.Build; import com.facebook.react.bridge.BaseJavaModule; -import com.facebook.react.bridge.annotations.ReactModule; import java.util.HashMap; import java.util.Map; @@ -22,9 +21,13 @@ import javax.annotation.Nullable; /** * Module that exposes Android Constants to JS. */ -@ReactModule(name = "AndroidConstants") public class AndroidInfoModule extends BaseJavaModule { + @Override + public String getName() { + return "AndroidConstants"; + } + @Override public @Nullable Map getConstants() { HashMap constants = new HashMap(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/timepicker/TimePickerDialogModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/timepicker/TimePickerDialogModule.java index 6046c88ac..7d627b583 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/timepicker/TimePickerDialogModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/timepicker/TimePickerDialogModule.java @@ -11,6 +11,7 @@ package com.facebook.react.modules.timepicker; import javax.annotation.Nullable; +import java.util.Map; import android.app.Activity; 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.WritableMap; import com.facebook.react.bridge.WritableNativeMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.annotations.VisibleForTesting; /** * {@link NativeModule} that allows JS to show a native time picker dialog and get called back when * the user selects a time. */ -@ReactModule(name = "TimePickerAndroid") public class TimePickerDialogModule extends ReactContextBaseJavaModule { @VisibleForTesting @@ -54,6 +53,11 @@ public class TimePickerDialogModule extends ReactContextBaseJavaModule { super(reactContext); } + @Override + public String getName() { + return "TimePickerAndroid"; + } + private class TimePickerDialogListener implements OnTimeSetListener, OnDismissListener { private final Promise mPromise; @@ -102,7 +106,7 @@ public class TimePickerDialogModule extends ReactContextBaseJavaModule { android.support.v4.app.FragmentManager fragmentManager = ((android.support.v4.app.FragmentActivity) activity).getSupportFragmentManager(); 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) { oldFragment.dismiss(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.java index db2b3bd4b..243c917a6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.java @@ -16,7 +16,6 @@ import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.MapBuilder; import com.facebook.react.bridge.UiThreadUtil; @@ -25,7 +24,6 @@ import java.util.Map; /** * {@link NativeModule} that allows JS to show an Android Toast. */ -@ReactModule(name = "ToastAndroid") public class ToastModule extends ReactContextBaseJavaModule { private static final String DURATION_SHORT_KEY = "SHORT"; @@ -39,6 +37,11 @@ public class ToastModule extends ReactContextBaseJavaModule { super(reactContext); } + @Override + public String getName() { + return "ToastAndroid"; + } + @Override public Map getConstants() { final Map constants = MapBuilder.newHashMap(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/VibrationModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/VibrationModule.java index b0a15115c..21c54a188 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/VibrationModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/vibration/VibrationModule.java @@ -16,15 +16,18 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.bridge.annotations.ReactModule; -@ReactModule(name = "Vibration") public class VibrationModule extends ReactContextBaseJavaModule { public VibrationModule(ReactApplicationContext reactContext) { super(reactContext); } + @Override + public String getName() { + return "Vibration"; + } + @ReactMethod public void vibrate(int duration) { Vibrator v = (Vibrator) getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java index 5ad075c6e..3c6799efa 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java @@ -26,7 +26,6 @@ import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableMapKeySetIterator; import com.facebook.react.bridge.ReadableType; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.ReactConstants; import com.facebook.react.modules.core.DeviceEventManagerModule; @@ -48,7 +47,6 @@ import java.util.concurrent.TimeUnit; import okio.Buffer; import okio.ByteString; -@ReactModule(name = "WebSocketModule") public class WebSocketModule extends ReactContextBaseJavaModule { private Map mWebSocketConnections = new HashMap<>(); @@ -65,6 +63,11 @@ public class WebSocketModule extends ReactContextBaseJavaModule { .emit(eventName, params); } + @Override + public String getName() { + return "WebSocketModule"; + } + @ReactMethod public void connect(final String url, @Nullable final ReadableArray protocols, @Nullable final ReadableMap headers, final int id) { OkHttpClient client = new OkHttpClient.Builder() @@ -270,8 +273,10 @@ public class WebSocketModule extends ReactContextBaseJavaModule { } return defaultOrigin; - } catch (URISyntaxException e) { + + } catch(URISyntaxException e) { throw new IllegalArgumentException("Unable to set " + uri + " as default origin header."); } } + } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 7f6001a08..033ea83e0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -24,9 +24,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.bridge.annotations.ReactModule; import com.facebook.react.common.ReactConstants; -import com.facebook.react.uimanager.DisplayMetricsHolder; import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.systrace.Systrace; @@ -61,7 +59,6 @@ import com.facebook.systrace.SystraceMessage; * consider implementing a pool * 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 OnBatchCompleteListener, LifecycleEventListener { @@ -98,6 +95,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements return mUIImplementation; } + @Override + public String getName() { + return "RKUIManager"; + } + @Override public Map getConstants() { return mModuleConstants; diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java index a12927513..3500d64f9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java @@ -20,14 +20,12 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; 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. * * Example returned owner hierarchy: ['RootView', 'Dialog', 'TitleView', 'Text'] */ -@ReactModule(name = "DebugComponentOwnershipModule") public class DebugComponentOwnershipModule extends ReactContextBaseJavaModule { public interface RCTDebugComponentOwnership extends JavaScriptModule { @@ -94,4 +92,9 @@ public class DebugComponentOwnershipModule extends ReactContextBaseJavaModule { mRequestIdToCallback.put(requestId, callback); Assertions.assertNotNull(mRCTDebugComponentOwnership).getOwnerHierarchy(requestId, tag); } + + @Override + public String getName() { + return "DebugComponentOwnershipModule"; + } }