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 4dc76619bbcacf..afdf4bc903d551 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 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 @@ protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { } // 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 @@ protected static class ScrollListenerModule extends BaseJavaModule { 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 b9b7060e14a392..4379470164fc54 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 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 @@ /** * 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 a5daaa34e5a3f3..e62d09ecb0c14a 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.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 5ceddde42372b7..5cf7e4373ef600 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 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 acc2f39b4caf1c..1ddf186c90de2f 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 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 @@ * 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 JSIntegrationTestChecker() { 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 dcf9d1c278d361..4c0b68b6d0176b 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.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 void setRequestListener(RequestListener requestListener) { 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 ae61480276db3a..8caa3b8f7117b1 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 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 a91c9ceb4bb2b7..06ff91a0cfa626 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.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 @@ private void mapGetByType(ReadableMap map, String key, String typeToAskFor) { } } - @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 8d00897bc19104..951c593533e453 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.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 c243eebc48d7b7..a8824fd7923553 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.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 synchronized void captureComplete(String path, String error) { } } + @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 fd58cc2f65caed..a3daa95a78bc0a 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.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 AppStateModule(ReactApplicationContext reactContext) { 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 073a01bc11ad44..c103f445ae4879 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.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 @@ * {@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 CameraRollManager(ReactApplicationContext reactContext) { super(reactContext); } + @Override + public String getName() { + return "RKCameraRollManager"; + } + @Override public Map getConstants() { return Collections.emptyMap(); @@ -437,4 +440,5 @@ private static void putLocationInfo( 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 0bf9e56ff0773a..952d923224adb8 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.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 @@ protected void doInBackgroundGuarded(Void... params) { } 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 3c140005e2eb63..68329f42a10556 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.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 ImageStoreManager(ReactApplicationContext reactContext) { 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 597c545c92fd5f..a51f93e7ccc8d3 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.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 void getString(Promise promise) { } 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 4e440aac64137d..d28cf84f17b98f 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.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 void emitNewIntentReceived(Uri uri) { 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 b3d1ef8ee5679d..c5ad60e59929c0 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.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 ExceptionsManagerModule(DevSupportManager 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 // 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 8bc771ac3ef41e..2fc348e8d5c4b5 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.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 @@ /** * 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 void run() { 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 @@ private void clearChoreographerIdleCallback() { } } + @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 00130efd435f9b..6f76ea7e409827 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.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 DatePickerDialogModule(ReactApplicationContext reactContext) { super(reactContext); } + @Override + public String getName() { + return "DatePickerAndroid"; + } + private class DatePickerDialogListener implements OnDateSetListener, OnDismissListener { private final Promise mPromise; @@ -126,7 +129,7 @@ public void open(@Nullable final ReadableMap options, Promise promise) { 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 void open(@Nullable final ReadableMap options, Promise promise) { 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 58af96935eed6c..dc96645815cf22 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.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 AnimationsDebugModule( 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 9eb10252778bf9..71aba3511c488b 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 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 SourceCodeModule(String sourceUrl) { 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 f58303d225badc..a9bbedc1474ab2 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.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.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 DialogModule(ReactApplicationContext reactContext) { 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 be2c48e27c2c23..210f89e35bf147 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.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 @@ * *

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 void initialize() { 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 1f9f1d2d9f9632..feefb593cd63dd 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 @@ 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 I18nManagerModule(ReactApplicationContext reactContext) { 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 Map getConstants() { 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 999dda97a3ee08..54730146d2d6d9 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.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 ImageLoaderModule(ReactApplicationContext reactContext, Object callerCont 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 efeb88bd264b48..8139797ae63346 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.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 005ca5b5cf9e20..9aa887b503e435 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.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 LocationModule(ReactApplicationContext reactContext) { 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 c2424c48713696..1b8b93cbe30f72 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.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 void initialize() { 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 f82e9e073e8618..50f31239ca413a 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.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 @@ /** * 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 void initialize() { 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 4264c6bd0706bf..fd09476b6fbadb 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.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 PermissionsModule(ReactApplicationContext reactContext) { 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 5b170ed5874159..eee2a42ca8f5c7 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 @@ 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 ShareModule(ReactApplicationContext reactContext) { super(reactContext); } + @Override + public String getName() { + return "ShareModule"; + } + /** * Open a chooser dialog to send text content to other apps. * @@ -74,9 +80,11 @@ public void share(ReadableMap content, String dialogTitle, Promise promise) { 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 1a9430e8b891f6..76554b7e438505 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.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 StatusBarModule(ReactApplicationContext reactContext) { super(reactContext); } + @Override + public String getName() { + return "StatusBarManager"; + } + @Override public @Nullable Map getConstants() { final Context context = getReactApplicationContext(); @@ -58,7 +61,8 @@ public StatusBarModule(ReactApplicationContext reactContext) { 0; return MapBuilder.of( - HEIGHT_KEY, height); + HEIGHT_KEY, height + ); } @ReactMethod @@ -95,7 +99,8 @@ public void onAnimationUpdate(ValueAnimator animator) { } res.resolve(null); } - }); + } + ); } else { res.resolve(null); } @@ -138,7 +143,8 @@ public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { ViewCompat.requestApplyInsets(decorView); res.resolve(null); } - }); + } + ); } } @@ -163,6 +169,7 @@ public void run() { 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 98dc47c9dd0b36..35b615066c8801 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.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.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 AsyncStorageModule(ReactApplicationContext reactContext) { 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 3353c48c1941a3..7ef7dee0122884 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 @@ 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 @@ /** * 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 6046c88ac6b32b..7d627b5833a548 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 @@ 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.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 TimePickerDialogModule(ReactApplicationContext reactContext) { super(reactContext); } + @Override + public String getName() { + return "TimePickerAndroid"; + } + private class TimePickerDialogListener implements OnTimeSetListener, OnDismissListener { private final Promise mPromise; @@ -102,7 +106,7 @@ public void open(@Nullable final ReadableMap options, Promise promise) { 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 db2b3bd4b55e80..243c917a6fe207 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.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 @@ /** * {@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 ToastModule(ReactApplicationContext reactContext) { 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 b0a15115ccd98e..21c54a188ab73c 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.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 5ad075c6e9947a..3c6799efa467e8 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.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 okio.Buffer; import okio.ByteString; -@ReactModule(name = "WebSocketModule") public class WebSocketModule extends ReactContextBaseJavaModule { private Map mWebSocketConnections = new HashMap<>(); @@ -65,6 +63,11 @@ private void sendEvent(String eventName, WritableMap params) { .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 @@ private static String setDefaultOrigin(String uri) { } 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 7f6001a083c3fa..033ea83e051e79 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.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 @@ * 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 UIImplementation getUIImplementation() { 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 a129275130ebe6..3500d64f915ffd 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.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 synchronized void loadComponentOwnerHierarchy(int tag, OwnerHierarchyCall mRequestIdToCallback.put(requestId, callback); Assertions.assertNotNull(mRCTDebugComponentOwnership).getOwnerHierarchy(requestId, tag); } + + @Override + public String getName() { + return "DebugComponentOwnershipModule"; + } }