Skip to content

Commit

Permalink
Migrate MainReactPackage to Kotlin (#47070)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #47070

For the sake of Stable API, I'd like to get this class converted to Kotlin

The class is becoming `final` so could be breaking for some users if they subclass `MainReactPackage` which I believe this should not be a valid usage of this API.

Changelog:
[Android] [Changed] - Migrate MainReactPackage to Kotlin (and make it final)

Reviewed By: tdn120

Differential Revision: D64479418

fbshipit-source-id: 24a07de4e5796a7b82ba34c9b36511b8fc526f1a
  • Loading branch information
cortinico authored and facebook-github-bot committed Oct 17, 2024
1 parent 2d2bb9c commit 7bbac8e
Show file tree
Hide file tree
Showing 12 changed files with 335 additions and 343 deletions.
42 changes: 40 additions & 2 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -3028,6 +3028,8 @@ public abstract interface class com/facebook/react/module/model/ReactModuleInfoP
}

public final class com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule : com/facebook/fbreact/specs/NativeAccessibilityInfoSpec, com/facebook/react/bridge/LifecycleEventListener {
public static final field Companion Lcom/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun announceForAccessibility (Ljava/lang/String;)V
public fun getRecommendedTimeoutMillis (DLcom/facebook/react/bridge/Callback;)V
Expand All @@ -3043,6 +3045,9 @@ public final class com/facebook/react/modules/accessibilityinfo/AccessibilityInf
public fun setAccessibilityFocus (D)V
}

public final class com/facebook/react/modules/accessibilityinfo/AccessibilityInfoModule$Companion {
}

public final class com/facebook/react/modules/appearance/AppearanceModule : com/facebook/fbreact/specs/NativeAppearanceSpec {
public static final field Companion Lcom/facebook/react/modules/appearance/AppearanceModule$Companion;
public static final field NAME Ljava/lang/String;
Expand Down Expand Up @@ -3387,11 +3392,16 @@ public final class com/facebook/react/modules/devloading/DevLoadingModule$Compan
}

public final class com/facebook/react/modules/devtoolsruntimesettings/ReactDevToolsRuntimeSettingsModule : com/facebook/fbreact/specs/NativeReactDevToolsRuntimeSettingsModuleSpec {
public static final field Companion Lcom/facebook/react/modules/devtoolsruntimesettings/ReactDevToolsRuntimeSettingsModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun getReloadAndProfileConfig ()Lcom/facebook/react/bridge/WritableMap;
public fun setReloadAndProfileConfig (Lcom/facebook/react/bridge/ReadableMap;)V
}

public final class com/facebook/react/modules/devtoolsruntimesettings/ReactDevToolsRuntimeSettingsModule$Companion {
}

public class com/facebook/react/modules/dialog/AlertFragment : androidx/fragment/app/DialogFragment, android/content/DialogInterface$OnClickListener {
public fun <init> ()V
public fun <init> (Lcom/facebook/react/modules/dialog/DialogModule$AlertFragmentListener;Landroid/os/Bundle;)V
Expand All @@ -3414,6 +3424,7 @@ public class com/facebook/react/modules/dialog/DialogModule : com/facebook/fbrea

public class com/facebook/react/modules/fresco/FrescoModule : com/facebook/react/bridge/ReactContextBaseJavaModule, com/facebook/react/bridge/LifecycleEventListener, com/facebook/react/modules/common/ModuleDataCleaner$Cleanable, com/facebook/react/turbomodule/core/interfaces/TurboModule {
public static final field Companion Lcom/facebook/react/modules/fresco/FrescoModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/imagepipeline/core/ImagePipeline;)V
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/imagepipeline/core/ImagePipeline;Z)V
Expand Down Expand Up @@ -3469,13 +3480,18 @@ public final class com/facebook/react/modules/fresco/XmlFormat {
}

public final class com/facebook/react/modules/i18nmanager/I18nManagerModule : com/facebook/fbreact/specs/NativeI18nManagerSpec {
public static final field Companion Lcom/facebook/react/modules/i18nmanager/I18nManagerModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun allowRTL (Z)V
public fun forceRTL (Z)V
public fun getTypedExportedConstants ()Ljava/util/Map;
public fun swapLeftAndRightInRTL (Z)V
}

public final class com/facebook/react/modules/i18nmanager/I18nManagerModule$Companion {
}

public final class com/facebook/react/modules/i18nmanager/I18nUtil {
public static final field Companion Lcom/facebook/react/modules/i18nmanager/I18nUtil$Companion;
public final fun allowRTL (Landroid/content/Context;Z)V
Expand Down Expand Up @@ -3647,6 +3663,8 @@ public class com/facebook/react/modules/network/TLSSocketFactory : javax/net/ssl
}

public final class com/facebook/react/modules/permissions/PermissionsModule : com/facebook/fbreact/specs/NativePermissionsAndroidSpec, com/facebook/react/modules/core/PermissionListener {
public static final field Companion Lcom/facebook/react/modules/permissions/PermissionsModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun checkPermission (Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V
public fun onRequestPermissionsResult (I[Ljava/lang/String;[I)Z
Expand All @@ -3655,15 +3673,24 @@ public final class com/facebook/react/modules/permissions/PermissionsModule : co
public fun shouldShowRequestPermissionRationale (Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V
}

public final class com/facebook/react/modules/permissions/PermissionsModule$Companion {
}

public final class com/facebook/react/modules/reactdevtoolssettings/ReactDevToolsSettingsManagerModule : com/facebook/fbreact/specs/NativeReactDevToolsSettingsManagerSpec {
public static final field Companion Lcom/facebook/react/modules/reactdevtoolssettings/ReactDevToolsSettingsManagerModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun getGlobalHookSettings ()Ljava/lang/String;
public fun setGlobalHookSettings (Ljava/lang/String;)V
}

public final class com/facebook/react/modules/reactdevtoolssettings/ReactDevToolsSettingsManagerModule$Companion {
}

public final class com/facebook/react/modules/share/ShareModule : com/facebook/fbreact/specs/NativeShareModuleSpec {
public static final field Companion Lcom/facebook/react/modules/share/ShareModule$Companion;
public static final field ERROR_INVALID_CONTENT Ljava/lang/String;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun share (Lcom/facebook/react/bridge/ReadableMap;Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V
}
Expand All @@ -3672,10 +3699,15 @@ public final class com/facebook/react/modules/share/ShareModule$Companion {
}

public final class com/facebook/react/modules/sound/SoundManagerModule : com/facebook/fbreact/specs/NativeSoundManagerSpec {
public static final field Companion Lcom/facebook/react/modules/sound/SoundManagerModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun playTouchSound ()V
}

public final class com/facebook/react/modules/sound/SoundManagerModule$Companion {
}

public final class com/facebook/react/modules/statusbar/StatusBarModule : com/facebook/fbreact/specs/NativeStatusBarManagerAndroidSpec {
public static final field Companion Lcom/facebook/react/modules/statusbar/StatusBarModule$Companion;
public static final field NAME Ljava/lang/String;
Expand Down Expand Up @@ -3729,12 +3761,17 @@ public final class com/facebook/react/modules/toast/ToastModule$Companion {
}

public final class com/facebook/react/modules/vibration/VibrationModule : com/facebook/fbreact/specs/NativeVibrationSpec {
public static final field Companion Lcom/facebook/react/modules/vibration/VibrationModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun cancel ()V
public fun vibrate (D)V
public fun vibrateByPattern (Lcom/facebook/react/bridge/ReadableArray;D)V
}

public final class com/facebook/react/modules/vibration/VibrationModule$Companion {
}

public final class com/facebook/react/modules/websocket/WebSocketModule : com/facebook/fbreact/specs/NativeWebSocketModuleSpec {
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun addListener (Ljava/lang/String;)V
Expand Down Expand Up @@ -4022,16 +4059,17 @@ public final class com/facebook/react/shell/MainPackageConfig {
public final fun getFrescoConfig ()Lcom/facebook/imagepipeline/core/ImagePipelineConfig;
}

public class com/facebook/react/shell/MainReactPackage : com/facebook/react/BaseReactPackage, com/facebook/react/ViewManagerOnDemandReactPackage {
public final class com/facebook/react/shell/MainReactPackage : com/facebook/react/BaseReactPackage, com/facebook/react/ViewManagerOnDemandReactPackage {
public fun <init> ()V
public fun <init> (Lcom/facebook/react/shell/MainPackageConfig;)V
public synthetic fun <init> (Lcom/facebook/react/shell/MainPackageConfig;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun createViewManager (Lcom/facebook/react/bridge/ReactApplicationContext;Ljava/lang/String;)Lcom/facebook/react/uimanager/ViewManager;
public fun createViewManagers (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List;
public fun getModule (Ljava/lang/String;Lcom/facebook/react/bridge/ReactApplicationContext;)Lcom/facebook/react/bridge/NativeModule;
public fun getReactModuleInfoProvider ()Lcom/facebook/react/module/model/ReactModuleInfoProvider;
public fun getViewManagerNames (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/Collection;
public fun getViewManagers (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List;
public fun getViewManagersMap ()Ljava/util/Map;
public final fun getViewManagersMap ()Ljava/util/Map;
}

public class com/facebook/react/shell/MainReactPackage$$ReactModuleInfoProvider : com/facebook/react/module/model/ReactModuleInfoProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ public class AccessibilityInfoModule(context: ReactApplicationContext) :
successCallback.invoke(recommendedTimeout)
}

private companion object {
public companion object {
public const val NAME: String = NativeAccessibilityInfoSpec.NAME
private const val REDUCE_MOTION_EVENT_NAME = "reduceMotionDidChange"
private const val HIGH_TEXT_CONTRAST_EVENT_NAME = "highTextContrastDidChange"
private const val TOUCH_EXPLORATION_EVENT_NAME = "touchExplorationDidChange"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ private class Settings {
public class ReactDevToolsRuntimeSettingsModule(reactContext: ReactApplicationContext?) :
NativeReactDevToolsRuntimeSettingsModuleSpec(reactContext) {

// static to persist across Turbo Module reloads
private companion object {
public companion object {
// static to persist across Turbo Module reloads
private val settings = Settings()
public const val NAME: String = NativeReactDevToolsRuntimeSettingsModuleSpec.NAME
}

override fun setReloadAndProfileConfig(map: ReadableMap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ constructor(
}

public companion object {
internal const val NAME = "FrescoModule"
public const val NAME: String = "FrescoModule"
private var hasBeenInitialized = false

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ public class I18nManagerModule(context: ReactApplicationContext?) : NativeI18nMa
override fun swapLeftAndRightInRTL(value: Boolean) {
I18nUtil.instance.swapLeftAndRightInRTL(getReactApplicationContext(), value)
}

public companion object {
public const val NAME: String = NativeI18nManagerSpec.NAME
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ public class PermissionsModule(reactContext: ReactApplicationContext?) :
return activity
}

private companion object {
public companion object {
public const val NAME: String = NativePermissionsAndroidSpec.NAME
private const val ERROR_INVALID_ACTIVITY = "E_INVALID_ACTIVITY"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class ReactDevToolsSettingsManagerModule(reactContext: ReactApplicationCo
public override fun getGlobalHookSettings(): String? =
sharedPreferences.getString(KEY_HOOK_SETTINGS, null)

private companion object {
public companion object {
public const val NAME: String = NativeReactDevToolsSettingsManagerSpec.NAME
private const val SHARED_PREFERENCES_PREFIX = "ReactNative__DevToolsSettings"
private const val KEY_HOOK_SETTINGS = "HookSettings"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class ShareModule(reactContext: ReactApplicationContext) :
}

public companion object {
public const val NAME: String = NativeShareModuleSpec.NAME
const private val ACTION_SHARED: String = "sharedAction"
const public val ERROR_INVALID_CONTENT: String = "E_INVALID_CONTENT"
const private val ERROR_UNABLE_TO_OPEN_DIALOG: String = "E_UNABLE_TO_OPEN_DIALOG"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ public class SoundManagerModule(reactContext: ReactApplicationContext?) :
getReactApplicationContext().getSystemService(Context.AUDIO_SERVICE) as AudioManager
audioManager.playSoundEffect(AudioManager.FX_KEY_CLICK)
}

public companion object {
public const val NAME: String = NativeSoundManagerSpec.NAME
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ public class VibrationModule(reactContext: ReactApplicationContext) :
@Suppress("DEPRECATION")
getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE) as Vibrator?
}

public companion object {
public const val NAME: String = NativeVibrationSpec.NAME
}
}
Loading

0 comments on commit 7bbac8e

Please sign in to comment.