From df112615a7cd4762570805133eb185c65df8dd33 Mon Sep 17 00:00:00 2001 From: Arushi Kesarwani Date: Thu, 24 Aug 2023 09:45:16 -0700 Subject: [PATCH] Kotlinfy ReactNativeConfig (#39142) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39142 X-link: https://github.com/facebookresearch/playtorch/pull/227 `ReactNativeConfig.java` -> `ReactNativeConfig.kt` changelog: [internal] internal Reviewed By: rshest Differential Revision: D48585508 fbshipit-source-id: 61899f761d7de62f7ec7179b0ee5eb0aa2ed9860 --- ...NativeConfig.java => ReactNativeConfig.kt} | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/{ReactNativeConfig.java => ReactNativeConfig.kt} (62%) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ReactNativeConfig.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ReactNativeConfig.kt similarity index 62% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ReactNativeConfig.java rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ReactNativeConfig.kt index 1c6704b3d88db7..37e0db6ac52126 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ReactNativeConfig.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/ReactNativeConfig.kt @@ -5,55 +5,50 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.fabric; +package com.facebook.react.fabric -import androidx.annotation.NonNull; -import com.facebook.proguard.annotations.DoNotStrip; +import com.facebook.proguard.annotations.DoNotStrip /** * ReactNative Configuration that allows to customize the behavior of key/value pairs used by the * framework to enable/disable capabilities. * - *

The hosting app should provide an implementation of this interface to allow specific - * customization of single keys. An empty implementation is available as {@link - * EmptyReactNativeConfig}. + * The hosting app should provide an implementation of this interface to allow specific + * customization of single keys. An empty implementation is available as [EmptyReactNativeConfig]. * - *

This is a wrapper for the ReactNativeConfig object in C++ + * This is a wrapper for the ReactNativeConfig object in C++ */ @DoNotStrip -public interface ReactNativeConfig { - - ReactNativeConfig DEFAULT_CONFIG = new EmptyReactNativeConfig(); - +interface ReactNativeConfig { /** * Get a boolean param by string name. Default should be false. * * @param param The string name of the parameter being requested. */ - @DoNotStrip - boolean getBool(@NonNull String param); + @DoNotStrip fun getBool(param: String): Boolean /** * Get a Long param by string name. Default should be 0. * * @param param The string name of the parameter being requested. */ - @DoNotStrip - long getInt64(@NonNull String param); + @DoNotStrip fun getInt64(param: String): Long /** * Get a string param by string name. Default should be "", empty string. * * @param param The string name of the parameter being requested. */ - @DoNotStrip - String getString(@NonNull String param); + @DoNotStrip fun getString(param: String): String /** * Get a double param by string name. Default should be 0. * * @param param The string name of the parameter being requested. */ - @DoNotStrip - double getDouble(@NonNull String param); + @DoNotStrip fun getDouble(param: String): Double + + companion object { + @JvmField val DEFAULT_CONFIG: ReactNativeConfig = EmptyReactNativeConfig() + } }