Switch TurboModules over to generated getName method

Summary:
Apply the codegen improvements from D41615387

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D41687534

fbshipit-source-id: 1d56f8fcb8d8b546291350785172a3b02abb0873
This commit is contained in:
Pieter De Baets
2022-12-07 06:35:01 -08:00
committed by Facebook GitHub Bot
parent 90538909f9
commit c2a4654d37
35 changed files with 35 additions and 264 deletions
@@ -33,7 +33,7 @@ public class DebugCorePackage extends TurboReactPackage {
@Override
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
switch (name) {
case JSCHeapCapture.TAG:
case JSCHeapCapture.NAME:
return new JSCHeapCapture(reactContext);
default:
throw new IllegalArgumentException(
@@ -85,11 +85,10 @@ import java.util.concurrent.atomic.AtomicReference;
* This isolates us from the problems that may be caused by concurrent updates of animated graph
* while UI thread is "executing" the animation loop.
*/
@ReactModule(name = NativeAnimatedModule.NAME)
@ReactModule(name = NativeAnimatedModuleSpec.NAME)
public class NativeAnimatedModule extends NativeAnimatedModuleSpec
implements LifecycleEventListener, UIManagerListener {
public static final String NAME = "NativeAnimatedModule";
public static final boolean ANIMATED_MODULE_DEBUG = false;
// For `queueAndExecuteBatchedOperations`
@@ -377,11 +376,6 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
clearFrameCallback();
}
@Override
public String getName() {
return NAME;
}
/**
* Returns a {@link NativeAnimatedNodesManager}, either the existing instance or a new one. Will
* return null if and only if the {@link ReactApplicationContext} is also null.
@@ -16,10 +16,8 @@ import java.io.File;
// This module is being called only by Java via the static method "captureHeap" that
// requires it to already be initialized, thus we eagerly initialize this module
@ReactModule(name = JSCHeapCapture.TAG, needsEagerInit = true)
@ReactModule(name = NativeJSCHeapCaptureSpec.NAME, needsEagerInit = true)
public class JSCHeapCapture extends NativeJSCHeapCaptureSpec {
public static final String TAG = "JSCHeapCapture";
public interface HeapCapture extends JavaScriptModule {
void captureHeap(String path);
}
@@ -79,9 +77,4 @@ public class JSCHeapCapture extends NativeJSCHeapCaptureSpec {
mCaptureInProgress = null;
}
}
@Override
public String getName() {
return "JSCHeapCapture";
}
}
@@ -15,7 +15,7 @@ import com.facebook.react.common.SurfaceDelegate;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = LogBoxModule.NAME)
@ReactModule(name = NativeLogBoxSpec.NAME)
public class LogBoxModule extends NativeLogBoxSpec {
public static final String NAME = "LogBox";
@@ -49,11 +49,6 @@ public class LogBoxModule extends NativeLogBoxSpec {
});
}
@Override
public String getName() {
return NAME;
}
@Override
public void show() {
if (!mSurfaceDelegate.isContentViewReady()) {
@@ -30,12 +30,10 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
* Module that monitors and provides information about the state of Touch Exploration service on the
* device. For API >= 19.
*/
@ReactModule(name = AccessibilityInfoModule.NAME)
@ReactModule(name = NativeAccessibilityInfoSpec.NAME)
public class AccessibilityInfoModule extends NativeAccessibilityInfoSpec
implements LifecycleEventListener {
public static final String NAME = "AccessibilityInfo";
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private class ReactTouchExplorationStateChangeListener
implements AccessibilityManager.TouchExplorationStateChangeListener {
@@ -101,11 +99,6 @@ public class AccessibilityInfoModule extends NativeAccessibilityInfoSpec
mAccessibilityServiceChangeListener = new ReactAccessibilityServiceChangeListener();
}
@Override
public String getName() {
return "AccessibilityInfo";
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private boolean getIsReduceMotionEnabledValue() {
String value =
@@ -19,11 +19,9 @@ import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
/** Module that exposes the user's preferred color scheme. */
@ReactModule(name = AppearanceModule.NAME)
@ReactModule(name = NativeAppearanceSpec.NAME)
public class AppearanceModule extends NativeAppearanceSpec {
public static final String NAME = "Appearance";
private static final String APPEARANCE_CHANGED_EVENT_NAME = "appearanceChanged";
private String mColorScheme = "light";
@@ -68,11 +66,6 @@ public class AppearanceModule extends NativeAppearanceSpec {
return "light";
}
@Override
public String getName() {
return NAME;
}
@Override
public String getColorScheme() {
// Attempt to use the Activity context first in order to get the most up to date
@@ -21,13 +21,11 @@ import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
@ReactModule(name = AppStateModule.NAME)
@ReactModule(name = NativeAppStateSpec.NAME)
public class AppStateModule extends NativeAppStateSpec
implements LifecycleEventListener, WindowFocusChangeListener {
public static final String TAG = AppStateModule.class.getSimpleName();
public static final String NAME = "AppState";
public static final String APP_STATE_ACTIVE = "active";
public static final String APP_STATE_BACKGROUND = "background";
@@ -45,11 +43,6 @@ public class AppStateModule extends NativeAppStateSpec
: APP_STATE_BACKGROUND);
}
@Override
public String getName() {
return NAME;
}
@Override
public Map<String, Object> getTypedExportedConstants() {
HashMap<String, Object> constants = new HashMap<>();
@@ -41,11 +41,9 @@ import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okio.ByteString;
@ReactModule(name = BlobModule.NAME)
@ReactModule(name = NativeBlobModuleSpec.NAME)
public class BlobModule extends NativeBlobModuleSpec {
public static final String NAME = "BlobModule";
private final Map<String, byte[]> mBlobs = new HashMap<>();
private final WebSocketModule.ContentHandler mWebSocketContentHandler =
@@ -149,11 +147,6 @@ public class BlobModule extends NativeBlobModuleSpec {
BlobCollector.install(getReactApplicationContext(), this);
}
@Override
public String getName() {
return NAME;
}
@Override
public @Nullable Map<String, Object> getTypedExportedConstants() {
// The application can register BlobProvider as a ContentProvider so that blobs are resolvable.
@@ -14,21 +14,15 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = FileReaderModule.NAME)
@ReactModule(name = NativeFileReaderModuleSpec.NAME)
public class FileReaderModule extends NativeFileReaderModuleSpec {
public static final String NAME = "FileReaderModule";
private static final String ERROR_INVALID_BLOB = "ERROR_INVALID_BLOB";
public FileReaderModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
private BlobModule getBlobModule(String reason) {
ReactApplicationContext reactApplicationContext = getReactApplicationContextIfActiveOrWarn();
@@ -7,7 +7,6 @@
package com.facebook.react.modules.bundleloader;
import androidx.annotation.NonNull;
import com.facebook.fbreact.specs.NativeDevSplitBundleLoaderSpec;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
@@ -16,9 +15,8 @@ import com.facebook.react.devsupport.interfaces.DevSplitBundleCallback;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = NativeDevSplitBundleLoaderModule.NAME)
@ReactModule(name = NativeDevSplitBundleLoaderSpec.NAME)
public class NativeDevSplitBundleLoaderModule extends NativeDevSplitBundleLoaderSpec {
public static final String NAME = "DevSplitBundleLoader";
private static final String REJECTION_CODE = "E_BUNDLE_LOAD_ERROR";
private final DevSupportManager mDevSupportManager;
@@ -49,10 +47,4 @@ public class NativeDevSplitBundleLoaderModule extends NativeDevSplitBundleLoader
}
});
}
@NonNull
@Override
public String getName() {
return NAME;
}
}
@@ -24,21 +24,15 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@ReactModule(name = ImageStoreManager.NAME)
@ReactModule(name = NativeImageStoreAndroidSpec.NAME)
public class ImageStoreManager extends NativeImageStoreAndroidSpec {
public static final String NAME = "ImageStoreManager";
private static final int BUFFER_SIZE = 8192;
public ImageStoreManager(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
/**
* Calculate the base64 representation for an image. The "tag" comes from iOS naming.
*
@@ -15,20 +15,13 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.annotations.ReactModule;
/** A module that allows JS to get/set clipboard contents. */
@ReactModule(name = ClipboardModule.NAME)
@ReactModule(name = NativeClipboardSpec.NAME)
public class ClipboardModule extends NativeClipboardSpec {
public ClipboardModule(ReactApplicationContext context) {
super(context);
}
public static final String NAME = "Clipboard";
@Override
public String getName() {
return ClipboardModule.NAME;
}
private ClipboardManager getClipboardService() {
return (ClipboardManager)
getReactApplicationContext()
@@ -20,10 +20,8 @@ import com.facebook.react.bridge.WritableMap;
import com.facebook.react.module.annotations.ReactModule;
/** Native module that handles device hardware events like hardware back presses. */
@ReactModule(name = DeviceEventManagerModule.NAME)
@ReactModule(name = NativeDeviceEventManagerSpec.NAME)
public class DeviceEventManagerModule extends NativeDeviceEventManagerSpec {
public static final String NAME = "DeviceEventManager";
@DoNotStrip
public interface RCTDeviceEventEmitter extends JavaScriptModule {
void emit(@NonNull String eventName, @Nullable Object data);
@@ -77,9 +75,4 @@ public class DeviceEventManagerModule extends NativeDeviceEventManagerSpec {
// teardown is a noop.
getReactApplicationContext().runOnUiQueueThread(mInvokeDefaultBackPressRunnable);
}
@Override
public String getName() {
return "DeviceEventManager";
}
}
@@ -20,11 +20,9 @@ import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.util.ExceptionDataHelper;
import com.facebook.react.util.JSStackTrace;
@ReactModule(name = ExceptionsManagerModule.NAME)
@ReactModule(name = NativeExceptionsManagerSpec.NAME)
public class ExceptionsManagerModule extends NativeExceptionsManagerSpec {
public static final String NAME = "ExceptionsManager";
private final DevSupportManager mDevSupportManager;
public ExceptionsManagerModule(DevSupportManager devSupportManager) {
@@ -32,11 +30,6 @@ public class ExceptionsManagerModule extends NativeExceptionsManagerSpec {
mDevSupportManager = devSupportManager;
}
@Override
public String getName() {
return NAME;
}
@Override
public void reportFatalException(String message, ReadableArray stack, double idDouble) {
int id = (int) idDouble;
@@ -18,20 +18,13 @@ import com.facebook.react.module.annotations.ReactModule;
* Simple native module that allows JS to notify native of having completed some task work, so that
* it can e.g. release any resources, stop timers etc.
*/
@ReactModule(name = HeadlessJsTaskSupportModule.NAME)
@ReactModule(name = NativeHeadlessJsTaskSupportSpec.NAME)
public class HeadlessJsTaskSupportModule extends NativeHeadlessJsTaskSupportSpec {
public static final String NAME = "HeadlessJsTaskSupport";
public HeadlessJsTaskSupportModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
@Override
public void notifyTaskRetry(double taskIdDouble, Promise promise) {
int taskId = (int) taskIdDouble;
@@ -18,7 +18,7 @@ import com.facebook.react.jstasks.HeadlessJsTaskEventListener;
import com.facebook.react.module.annotations.ReactModule;
/** Native module for JS timer execution. Timers fire on frame boundaries. */
@ReactModule(name = TimingModule.NAME)
@ReactModule(name = NativeTimingSpec.NAME)
public final class TimingModule extends NativeTimingSpec
implements LifecycleEventListener, HeadlessJsTaskEventListener {
@@ -51,8 +51,6 @@ public final class TimingModule extends NativeTimingSpec
}
}
public static final String NAME = "Timing";
private final JavaTimerManager mJavaTimerManager;
public TimingModule(ReactApplicationContext reactContext, DevSupportManager devSupportManager) {
@@ -74,11 +72,6 @@ public final class TimingModule extends NativeTimingSpec
headlessJsTaskContext.addTaskEventListener(this);
}
@Override
public String getName() {
return NAME;
}
@Override
public void createTimer(
final double callbackIDDouble,
@@ -22,11 +22,9 @@ import java.util.Locale;
* Module that records debug information during transitions (animated navigation events such as
* going from one screen to another).
*/
@ReactModule(name = AnimationsDebugModule.NAME)
@ReactModule(name = NativeAnimationsDebugModuleSpec.NAME)
public class AnimationsDebugModule extends NativeAnimationsDebugModuleSpec {
protected static final String NAME = "AnimationsDebugModule";
private @Nullable FpsDebugFrameCallback mFrameCallback;
private @Nullable final DeveloperSettings mCatalystSettings;
@@ -36,11 +34,6 @@ public class AnimationsDebugModule extends NativeAnimationsDebugModuleSpec {
mCatalystSettings = catalystSettings;
}
@Override
public String getName() {
return NAME;
}
@Override
public void startRecordingFps() {
if (mCatalystSettings == null || !mCatalystSettings.isAnimationFpsDebugEnabled()) {
@@ -20,11 +20,9 @@ import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEm
/**
* Module that exposes the URL to the source code map (used for exception stack trace parsing) to JS
*/
@ReactModule(name = DevSettingsModule.NAME)
@ReactModule(name = NativeDevSettingsSpec.NAME)
public class DevSettingsModule extends NativeDevSettingsSpec {
public static final String NAME = "DevSettings";
private final DevSupportManager mDevSupportManager;
public DevSettingsModule(
@@ -34,11 +32,6 @@ public class DevSettingsModule extends NativeDevSettingsSpec {
mDevSupportManager = devSupportManager;
}
@Override
public String getName() {
return NAME;
}
@Override
public void reload() {
if (mDevSupportManager.getDevSupportEnabled()) {
@@ -17,20 +17,13 @@ import java.util.Map;
/**
* Module that exposes the URL to the source code map (used for exception stack trace parsing) to JS
*/
@ReactModule(name = SourceCodeModule.NAME)
@ReactModule(name = NativeSourceCodeSpec.NAME)
public class SourceCodeModule extends NativeSourceCodeSpec {
public static final String NAME = "SourceCode";
public SourceCodeModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
@Override
protected Map<String, Object> getTypedExportedConstants() {
HashMap<String, Object> constants = new HashMap<>();
@@ -23,11 +23,9 @@ import java.util.HashMap;
import java.util.Map;
/** Module that exposes Android Constants to JS. */
@ReactModule(name = DeviceInfoModule.NAME)
@ReactModule(name = NativeDeviceInfoSpec.NAME)
public class DeviceInfoModule extends NativeDeviceInfoSpec implements LifecycleEventListener {
public static final String NAME = "DeviceInfo";
private @Nullable ReactApplicationContext mReactApplicationContext;
private float mFontScale;
private @Nullable ReadableMap mPreviousDisplayMetrics;
@@ -47,11 +45,6 @@ public class DeviceInfoModule extends NativeDeviceInfoSpec implements LifecycleE
mFontScale = context.getResources().getConfiguration().fontScale;
}
@Override
public String getName() {
return NAME;
}
@Override
public @Nullable Map<String, Object> getTypedExportedConstants() {
WritableMap displayMetrics = DisplayMetricsHolder.getDisplayMetricsWritableMap(mFontScale);
@@ -15,10 +15,8 @@ import com.facebook.fbreact.specs.NativeDevToolsSettingsManagerSpec;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.annotations.ReactModule;
@ReactModule(name = DevToolsSettingsManagerModule.NAME)
@ReactModule(name = NativeDevToolsSettingsManagerSpec.NAME)
public class DevToolsSettingsManagerModule extends NativeDevToolsSettingsManagerSpec {
public static final String NAME = "DevToolsSettingsManager";
private static final String SHARED_PREFERENCES_PREFIX = "ReactNative__DevToolsSettings";
private static final String KEY_CONSOLE_PATCH_SETTINGS = "ConsolePatchSettings";
private static final String KEY_PROFILING_SETTINGS = "ProfilingSettings";
@@ -31,11 +29,6 @@ public class DevToolsSettingsManagerModule extends NativeDevToolsSettingsManager
reactContext.getSharedPreferences(SHARED_PREFERENCES_PREFIX, Context.MODE_PRIVATE);
}
@Override
public String getName() {
return NAME;
}
@Override
public @Nullable String getConsolePatchSettings() {
return mSharedPreferences.getString(KEY_CONSOLE_PATCH_SETTINGS, null);
@@ -10,17 +10,13 @@ rn_android_library(
language = "JAVA",
provided_deps = [
react_native_dep("third-party/android/androidx:annotation"),
react_native_dep("third-party/android/androidx:core"),
react_native_dep("third-party/android/androidx:fragment"),
react_native_dep("third-party/android/androidx:legacy-support-core-ui"),
react_native_dep("third-party/android/androidx:legacy-support-core-utils"),
],
visibility = [
"PUBLIC",
],
deps = [
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
@@ -29,14 +29,12 @@ import com.facebook.react.common.MapBuilder;
import com.facebook.react.module.annotations.ReactModule;
import java.util.Map;
@ReactModule(name = DialogModule.NAME)
@ReactModule(name = NativeDialogManagerAndroidSpec.NAME)
public class DialogModule extends NativeDialogManagerAndroidSpec implements LifecycleEventListener {
/* package */ static final String FRAGMENT_TAG =
"com.facebook.catalyst.react.dialog.DialogModule";
public 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";
@@ -61,11 +59,6 @@ public class DialogModule extends NativeDialogManagerAndroidSpec implements Life
super(reactContext);
}
@Override
public @NonNull String getName() {
return NAME;
}
private class FragmentManagerHelper {
private final @NonNull FragmentManager mFragmentManager;
@@ -18,22 +18,14 @@ import java.util.Locale;
import java.util.Map;
/** {@link NativeModule} that allows JS to set allowRTL and get isRTL status. */
@ReactModule(name = I18nManagerModule.NAME)
@ReactModule(name = NativeI18nManagerSpec.NAME)
public class I18nManagerModule extends NativeI18nManagerSpec {
public static final String NAME = "I18nManager";
private final I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
public I18nManagerModule(ReactApplicationContext context) {
super(context);
}
@Override
public String getName() {
return NAME;
}
@Override
public Map<String, Object> getTypedExportedConstants() {
final Context context = getReactApplicationContext();
@@ -10,7 +10,6 @@ package com.facebook.react.modules.image;
import android.net.Uri;
import android.text.TextUtils;
import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.common.executors.CallerThreadExecutor;
import com.facebook.common.references.CloseableReference;
@@ -37,14 +36,13 @@ import com.facebook.react.modules.fresco.ReactNetworkImageRequest;
import com.facebook.react.views.image.ReactCallerContextFactory;
import com.facebook.react.views.imagehelper.ImageSource;
@ReactModule(name = ImageLoaderModule.NAME)
@ReactModule(name = NativeImageLoaderAndroidSpec.NAME)
public class ImageLoaderModule extends NativeImageLoaderAndroidSpec
implements LifecycleEventListener {
private static final String ERROR_INVALID_URI = "E_INVALID_URI";
private static final String ERROR_PREFETCH_FAILURE = "E_PREFETCH_FAILURE";
private static final String ERROR_GET_SIZE_FAILURE = "E_GET_SIZE_FAILURE";
public static final String NAME = "ImageLoader";
private @Nullable final Object mCallerContext;
private final Object mEnqueuedRequestMonitor = new Object();
@@ -78,12 +76,6 @@ public class ImageLoaderModule extends NativeImageLoaderAndroidSpec
: mCallerContext;
}
@Override
@NonNull
public String getName() {
return NAME;
}
private ImagePipeline getImagePipeline() {
return mImagePipeline != null ? mImagePipeline : Fresco.getImagePipeline();
}
@@ -26,11 +26,9 @@ import com.facebook.react.bridge.ReadableType;
import com.facebook.react.module.annotations.ReactModule;
/** Intent module. Launch other activities or open URLs. */
@ReactModule(name = IntentModule.NAME)
@ReactModule(name = NativeIntentAndroidSpec.NAME)
public class IntentModule extends NativeIntentAndroidSpec {
public static final String NAME = "IntentAndroid";
private @Nullable LifecycleEventListener mInitialURLListener = null;
private static final String EXTRA_MAP_KEY_FOR_VALUE = "value";
@@ -39,11 +37,6 @@ public class IntentModule extends NativeIntentAndroidSpec {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
@Override
public void invalidate() {
if (mInitialURLListener != null) {
@@ -51,7 +51,7 @@ import okio.GzipSource;
import okio.Okio;
/** Implements the XMLHttpRequest JavaScript interface. */
@ReactModule(name = NetworkingModule.NAME)
@ReactModule(name = NativeNetworkingAndroidSpec.NAME)
public final class NetworkingModule extends NativeNetworkingAndroidSpec {
/**
@@ -84,9 +84,7 @@ public final class NetworkingModule extends NativeNetworkingAndroidSpec {
WritableMap toResponseData(ResponseBody body) throws IOException;
}
public static final String NAME = "Networking";
private static final String TAG = "NetworkingModule";
private static final String TAG = NativeNetworkingAndroidSpec.NAME;
private static final String CONTENT_ENCODING_HEADER_NAME = "content-encoding";
private static final String CONTENT_TYPE_HEADER_NAME = "content-type";
private static final String REQUEST_BODY_KEY_STRING = "string";
@@ -185,11 +183,6 @@ public final class NetworkingModule extends NativeNetworkingAndroidSpec {
mCookieJarContainer.setCookieJar(new JavaNetCookieJar(mCookieHandler));
}
@Override
public String getName() {
return NAME;
}
@Override
public void invalidate() {
mShuttingDown = true;
@@ -26,11 +26,10 @@ import com.facebook.react.modules.core.PermissionListener;
import java.util.ArrayList;
/** Module that exposes the Android M Permission system to JS. */
@ReactModule(name = PermissionsModule.NAME)
@ReactModule(name = NativePermissionsAndroidSpec.NAME)
public class PermissionsModule extends NativePermissionsAndroidSpec implements PermissionListener {
private static final String ERROR_INVALID_ACTIVITY = "E_INVALID_ACTIVITY";
public static final String NAME = "PermissionsAndroid";
private final SparseArray<Callback> mCallbacks;
private int mRequestCode = 0;
private final String GRANTED = "granted";
@@ -42,11 +41,6 @@ public class PermissionsModule extends NativePermissionsAndroidSpec implements P
mCallbacks = new SparseArray<Callback>();
}
@Override
public String getName() {
return NAME;
}
/**
* 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}.
@@ -18,10 +18,9 @@ import com.facebook.react.bridge.WritableMap;
import com.facebook.react.module.annotations.ReactModule;
/** Intent module. Launch other activities or open URLs. */
@ReactModule(name = ShareModule.NAME)
@ReactModule(name = NativeShareModuleSpec.NAME)
public class ShareModule extends NativeShareModuleSpec {
public static final String NAME = "ShareModule";
/* package */ static final String ACTION_SHARED = "sharedAction";
/* package */ static final String ERROR_INVALID_CONTENT = "E_INVALID_CONTENT";
/* package */ static final String ERROR_UNABLE_TO_OPEN_DIALOG = "E_UNABLE_TO_OPEN_DIALOG";
@@ -30,11 +29,6 @@ public class ShareModule extends NativeShareModuleSpec {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
/**
* Open a chooser dialog to send text content to other apps.
*
@@ -15,20 +15,13 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.annotations.ReactModule;
/** {@link NativeModule} that allows Playing device sounds from JS. */
@ReactModule(name = SoundManagerModule.NAME)
@ReactModule(name = NativeSoundManagerSpec.NAME)
public class SoundManagerModule extends NativeSoundManagerSpec {
public static final String NAME = "SoundManager";
public SoundManagerModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
@Override
public void playTouchSound() {
AudioManager audioManager =
@@ -32,7 +32,7 @@ import com.facebook.react.uimanager.PixelUtil;
import java.util.Map;
/** {@link NativeModule} that allows changing the appearance of the status bar. */
@ReactModule(name = StatusBarModule.NAME)
@ReactModule(name = NativeStatusBarManagerAndroidSpec.NAME)
public class StatusBarModule extends NativeStatusBarManagerAndroidSpec {
private static final String HEIGHT_KEY = "HEIGHT";
@@ -43,11 +43,6 @@ public class StatusBarModule extends NativeStatusBarManagerAndroidSpec {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
@Override
public @Nullable Map<String, Object> getTypedExportedConstants() {
final Context context = getReactApplicationContext();
@@ -24,10 +24,9 @@ import java.util.HashMap;
import java.util.Map;
/** Module that exposes Android Constants to JS. */
@ReactModule(name = AndroidInfoModule.NAME)
@ReactModule(name = NativePlatformConstantsAndroidSpec.NAME)
@SuppressLint("HardwareIds")
public class AndroidInfoModule extends NativePlatformConstantsAndroidSpec implements TurboModule {
public static final String NAME = "PlatformConstants";
private static final String IS_TESTING = "IS_TESTING";
public AndroidInfoModule(ReactApplicationContext reactContext) {
@@ -59,11 +58,6 @@ public class AndroidInfoModule extends NativePlatformConstantsAndroidSpec implem
}
}
@Override
public String getName() {
return "PlatformConstants";
}
@Override
public @Nullable Map<String, Object> getTypedExportedConstants() {
HashMap<String, Object> constants = new HashMap<>();
@@ -18,7 +18,7 @@ import com.facebook.react.module.annotations.ReactModule;
import java.util.Map;
/** {@link NativeModule} that allows JS to show an Android Toast. */
@ReactModule(name = ToastModule.NAME)
@ReactModule(name = NativeToastAndroidSpec.NAME)
public class ToastModule extends NativeToastAndroidSpec {
private static final String DURATION_SHORT_KEY = "SHORT";
@@ -27,17 +27,11 @@ public class ToastModule extends NativeToastAndroidSpec {
private static final String GRAVITY_TOP_KEY = "TOP";
private static final String GRAVITY_BOTTOM_KEY = "BOTTOM";
private static final String GRAVITY_CENTER = "CENTER";
public static final String NAME = "ToastAndroid";
public ToastModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
@Override
public Map<String, Object> getTypedExportedConstants() {
final Map<String, Object> constants = MapBuilder.newHashMap();
@@ -18,20 +18,13 @@ import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.module.annotations.ReactModule;
@SuppressLint("MissingPermission")
@ReactModule(name = VibrationModule.NAME)
@ReactModule(name = NativeVibrationSpec.NAME)
public class VibrationModule extends NativeVibrationSpec {
public static final String NAME = "Vibration";
public VibrationModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return NAME;
}
@Override
public void vibrate(double durationDouble) {
int duration = (int) durationDouble;
@@ -36,12 +36,8 @@ import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import okio.ByteString;
@ReactModule(name = WebSocketModule.NAME, hasConstants = false)
@ReactModule(name = NativeWebSocketModuleSpec.NAME, hasConstants = false)
public final class WebSocketModule extends NativeWebSocketModuleSpec {
public static final String TAG = WebSocketModule.class.getSimpleName();
public static final String NAME = "WebSocketModule";
public interface ContentHandler {
void onMessage(String text, WritableMap params);
@@ -76,11 +72,6 @@ public final class WebSocketModule extends NativeWebSocketModuleSpec {
}
}
@Override
public String getName() {
return NAME;
}
public void setContentHandler(final int id, final ContentHandler contentHandler) {
if (contentHandler != null) {
mContentHandlers.put(id, contentHandler);