Introduce EmptyReactNativeConfig inside Java

Summary:
I'm adding a `EmptyReactNativeConfig` for Java as we had a similar class in C++.
Ideally inside the Playbook we can allow users to use this class rather than having to
create an anonymous inner class.

Changelog:
[Internal] [Added] - Introduce EmptyReactNativeConfig inside Java

Reviewed By: ShikaSD

Differential Revision: D32277916

fbshipit-source-id: f6bbeb0477681d536dfd89930b732609add7c43a
This commit is contained in:
Nicola Corti 2021-11-11 07:39:37 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 5050e7eaa1
Коммит e6fc9b6f29
3 изменённых файлов: 47 добавлений и 23 удалений

Просмотреть файл

@ -0,0 +1,35 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.fabric;
/**
* An empty {@link ReactNativeConfig} that is returning empty responses and false for all the
* requested keys.
*/
public class EmptyReactNativeConfig implements ReactNativeConfig {
@Override
public boolean getBool(final String s) {
return false;
}
@Override
public int getInt64(final String s) {
return 0;
}
@Override
public String getString(final String s) {
return "";
}
@Override
public double getDouble(final String s) {
return 0;
}
}

Просмотреть файл

@ -10,7 +10,16 @@ package com.facebook.react.fabric;
import androidx.annotation.NonNull;
import com.facebook.proguard.annotations.DoNotStrip;
// This is a wrapper for the ReactNativeConfig object in C++
/**
* ReactNative Configuration that allows to customize the behavior of key/value pairs used by the
* framework to enable/disable capabilities.
*
* <p>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}.
*
* <p>This is a wrapper for the ReactNativeConfig object in C++
*/
@DoNotStrip
public interface ReactNativeConfig {
/**

Просмотреть файл

@ -28,8 +28,8 @@ import com.facebook.react.bridge.UIManager;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.fabric.ComponentFactory;
import com.facebook.react.fabric.CoreComponentsRegistry;
import com.facebook.react.fabric.EmptyReactNativeConfig;
import com.facebook.react.fabric.FabricJSIModuleProvider;
import com.facebook.react.fabric.ReactNativeConfig;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.shell.MainReactPackage;
@ -152,27 +152,7 @@ public class RNTesterApplication extends Application implements ReactApplication
reactApplicationContext,
componentFactory,
// TODO: T71362667 add ReactNativeConfig's support in RNTester
new ReactNativeConfig() {
@Override
public boolean getBool(final String s) {
return false;
}
@Override
public int getInt64(final String s) {
return 0;
}
@Override
public String getString(final String s) {
return "";
}
@Override
public double getDouble(final String s) {
return 0;
}
},
new EmptyReactNativeConfig(),
viewManagerRegistry);
}
});