From 506f92083806e91a90d9a213bcdd05ab3b2ba888 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 26 Jun 2018 23:44:57 -0700 Subject: [PATCH] Remove UIImplementationProvider class and refactor UIManagerModule Summary: @public This diff deprecates and deletes the UIImplementationProvider class. It is not required to create an UIImplementation provider anymore, from now on the UIImplementation is created inside the UIManagerModule. If you are using the UIImplementationProvider to create a ReactInstanceManager e.g.: ``` ReactInstanceManager = getReactInstanceManagerBuilder() ... .setUIImplementationProvider(...) ... .build(); ``` Then you should just remove that line: ``` ReactInstanceManager = getReactInstanceManagerBuilder() .set..... .build(); ``` Reviewed By: achen1 Differential Revision: D8650376 fbshipit-source-id: 8d883295d8bf6578a99685edf6a2a84c6d0df0cf --- .../react/testing/ReactAppTestActivity.java | 37 +++-------------- ...alystNativeJSToJavaParametersTestCase.java | 3 +- ...talystNativeJavaToJSArgumentsTestCase.java | 3 +- ...ystNativeJavaToJSReturnValuesTestCase.java | 3 +- .../tests/CatalystUIManagerTestCase.java | 3 +- .../facebook/react/tests/JSLocaleTest.java | 15 +++---- .../react/tests/ProgressBarTestCase.java | 3 +- .../react/tests/ViewRenderingTestCase.java | 3 +- .../facebook/react/CoreModulesPackage.java | 6 --- .../facebook/react/ReactInstanceManager.java | 4 -- .../react/ReactInstanceManagerBuilder.java | 22 +--------- .../com/facebook/react/ReactNativeHost.java | 21 ++-------- .../uimanager/UIImplementationProvider.java | 40 ------------------- .../react/uimanager/UIManagerModule.java | 6 +-- .../uimanager/ReactPropConstantsTest.java | 2 +- .../UIManagerModuleConstantsTest.java | 23 +++-------- .../react/uimanager/UIManagerModuleTest.java | 2 +- .../react/views/text/ReactTextTest.java | 3 +- .../react/views/textinput/TextInputTest.java | 3 +- 19 files changed, 35 insertions(+), 167 deletions(-) delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java index 77b211217..5ca48fcf6 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactAppTestActivity.java @@ -37,11 +37,10 @@ import com.facebook.react.modules.core.PermissionListener; import com.facebook.react.shell.MainReactPackage; import com.facebook.react.testing.idledetection.ReactBridgeIdleSignaler; import com.facebook.react.testing.idledetection.ReactIdleDetectionUtil; -import com.facebook.react.uimanager.events.EventDispatcher; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManagerRegistry; +import com.facebook.react.uimanager.events.EventDispatcher; import java.util.Arrays; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -139,16 +138,11 @@ public class ReactAppTestActivity extends FragmentActivity loadApp(appKey, spec, null, DEFAULT_BUNDLE_NAME, enableDevSupport); } - public void loadApp(String appKey, ReactInstanceSpecForTest spec, String bundleName) { - loadApp(appKey, spec, null, bundleName, false /* = useDevSupport */); - } - public void loadApp( String appKey, ReactInstanceSpecForTest spec, - String bundleName, - UIImplementationProvider uiImplementationProvider) { - loadApp(appKey, spec, null, bundleName, false /* = useDevSupport */, uiImplementationProvider); + String bundleName) { + loadApp(appKey, spec, null, bundleName, false /* = useDevSupport */); } public void resetRootViewForScreenshotTests() { @@ -165,23 +159,13 @@ public class ReactAppTestActivity extends FragmentActivity mScreenshotingFrameLayout.addView(mReactRootView); } - public void loadApp( - String appKey, - ReactInstanceSpecForTest spec, - @Nullable Bundle initialProps, - String bundleName, - boolean useDevSupport) { - loadApp(appKey, spec, initialProps, bundleName, useDevSupport, null); - } - public void loadApp( String appKey, ReactInstanceSpecForTest spec, @Nullable Bundle initialProps, String bundleName, - boolean useDevSupport, - UIImplementationProvider uiImplementationProvider) { - loadBundle(spec, bundleName, useDevSupport, uiImplementationProvider); + boolean useDevSupport) { + loadBundle(spec, bundleName, useDevSupport); renderComponent(appKey, initialProps); } @@ -217,14 +201,6 @@ public class ReactAppTestActivity extends FragmentActivity ReactInstanceSpecForTest spec, String bundleName, boolean useDevSupport) { - loadBundle(spec, bundleName, useDevSupport, null); - } - - public void loadBundle( - ReactInstanceSpecForTest spec, - String bundleName, - boolean useDevSupport, - UIImplementationProvider uiImplementationProvider) { mBridgeIdleSignaler = new ReactBridgeIdleSignaler(); @@ -277,8 +253,7 @@ public class ReactAppTestActivity extends FragmentActivity }; } }); - }}) - .setUIImplementationProvider(uiImplementationProvider); + }}); final CountDownLatch latch = new CountDownLatch(1); runOnUiThread(new Runnable() { 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 00dee97df..a2d42bb1a 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.modules.systeminfo.AndroidInfoModule; import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.views.view.ReactViewManager; @@ -85,7 +84,7 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe List viewManagers = Arrays.asList( new ReactViewManager()); final UIManagerModule mUIManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); + new UIManagerModule(getContext(), viewManagers, 0); UiThreadUtil.runOnUiThread( new Runnable() { @Override diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java index dec91a4ea..3ba5bc198 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java @@ -21,7 +21,6 @@ import com.facebook.react.testing.AssertModule; import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.views.view.ReactViewManager; @@ -62,7 +61,7 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes List viewManagers = Arrays.asList( new ReactViewManager()); final UIManagerModule mUIManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); + new UIManagerModule(getContext(), viewManagers, 0); UiThreadUtil.runOnUiThread( new Runnable() { @Override diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java index 0430858c6..63a2ff0a7 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java @@ -22,7 +22,6 @@ import com.facebook.react.testing.AssertModule; import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import java.util.ArrayList; @@ -112,7 +111,7 @@ public class CatalystNativeJavaToJSReturnValuesTestCase extends ReactIntegration final UIManagerModule mUIManager = new UIManagerModule( - getContext(), new ArrayList(), new UIImplementationProvider(), 0); + getContext(), new ArrayList(), 0); mAssertModule = new AssertModule(); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java index 4d58d5791..895b1df15 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java @@ -22,7 +22,6 @@ import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; import com.facebook.react.uimanager.PixelUtil; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.views.text.ReactRawTextManager; @@ -77,7 +76,7 @@ public class CatalystUIManagerTestCase extends ReactIntegrationTestCase { new ReactTextViewManager(), new ReactRawTextManager()); uiManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); + new UIManagerModule(getContext(), viewManagers, 0); UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java index 5e0b9ff62..85eeb6c58 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java @@ -7,22 +7,20 @@ package com.facebook.react.tests; -import java.util.Arrays; -import java.util.List; - -import com.facebook.react.testing.FakeWebSocketModule; -import com.facebook.react.testing.ReactIntegrationTestCase; -import com.facebook.react.testing.ReactTestHelper; -import com.facebook.react.testing.StringRecordingModule; import com.facebook.react.bridge.CatalystInstance; import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.modules.appstate.AppStateModule; import com.facebook.react.modules.deviceinfo.DeviceInfoModule; -import com.facebook.react.uimanager.UIImplementationProvider; +import com.facebook.react.testing.FakeWebSocketModule; +import com.facebook.react.testing.ReactIntegrationTestCase; +import com.facebook.react.testing.ReactTestHelper; +import com.facebook.react.testing.StringRecordingModule; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.views.view.ReactViewManager; +import java.util.Arrays; +import java.util.List; /** * Test locale-based functionality of JS VM @@ -47,7 +45,6 @@ public class JSLocaleTest extends ReactIntegrationTestCase { final UIManagerModule mUIManager = new UIManagerModule( getContext(), viewManagers, - new UIImplementationProvider(), 0); UiThreadUtil.runOnUiThread( new Runnable() { diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java index 70dd28716..eae423344 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java @@ -24,7 +24,6 @@ import com.facebook.react.modules.systeminfo.AndroidInfoModule; import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.views.progressbar.ReactProgressBarViewManager; @@ -68,7 +67,7 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase { new ReactViewManager(), new ReactProgressBarViewManager()); mUIManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); + new UIManagerModule(getContext(), viewManagers, 0); UiThreadUtil.runOnUiThread( new Runnable() { @Override diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java index 73412bc21..1b28762be 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java @@ -21,7 +21,6 @@ import com.facebook.react.testing.FakeWebSocketModule; import com.facebook.react.testing.ReactIntegrationTestCase; import com.facebook.react.testing.ReactTestHelper; import com.facebook.react.uimanager.PixelUtil; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.views.view.ReactViewGroup; @@ -49,7 +48,7 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase { List viewManagers = Arrays.asList(new ReactViewManager()); final UIManagerModule uiManager = - new UIManagerModule(getContext(), viewManagers, new UIImplementationProvider(), 0); + new UIManagerModule(getContext(), viewManagers, 0); UiThreadUtil.runOnUiThread( new Runnable() { @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java index c6a778a67..1b3d4c10f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java @@ -26,7 +26,6 @@ import com.facebook.react.modules.core.Timing; import com.facebook.react.modules.debug.SourceCodeModule; import com.facebook.react.modules.deviceinfo.DeviceInfoModule; import com.facebook.react.modules.systeminfo.AndroidInfoModule; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.systrace.Systrace; @@ -54,19 +53,16 @@ import javax.inject.Provider; private final ReactInstanceManager mReactInstanceManager; private final DefaultHardwareBackBtnHandler mHardwareBackBtnHandler; - private final UIImplementationProvider mUIImplementationProvider; private final boolean mLazyViewManagersEnabled; private final int mMinTimeLeftInFrameForNonBatchedOperationMs; CoreModulesPackage( ReactInstanceManager reactInstanceManager, DefaultHardwareBackBtnHandler hardwareBackBtnHandler, - UIImplementationProvider uiImplementationProvider, boolean lazyViewManagersEnabled, int minTimeLeftInFrameForNonBatchedOperationMs) { mReactInstanceManager = reactInstanceManager; mHardwareBackBtnHandler = hardwareBackBtnHandler; - mUIImplementationProvider = uiImplementationProvider; mLazyViewManagersEnabled = lazyViewManagersEnabled; mMinTimeLeftInFrameForNonBatchedOperationMs = minTimeLeftInFrameForNonBatchedOperationMs; } @@ -165,13 +161,11 @@ import javax.inject.Provider; return new UIManagerModule( reactContext, resolver, - mUIImplementationProvider, mMinTimeLeftInFrameForNonBatchedOperationMs); } else { return new UIManagerModule( reactContext, mReactInstanceManager.getOrCreateViewManagers(reactContext), - mUIImplementationProvider, mMinTimeLeftInFrameForNonBatchedOperationMs); } } finally { diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 35c188eb7..680abe831 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -79,10 +79,8 @@ import com.facebook.react.modules.core.ReactChoreographer; import com.facebook.react.modules.debug.interfaces.DeveloperSettings; import com.facebook.react.modules.fabric.ReactFabric; import com.facebook.react.uimanager.DisplayMetricsHolder; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerHelper; import com.facebook.react.uimanager.ViewManager; -import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper; import com.facebook.soloader.SoLoader; import com.facebook.systrace.Systrace; @@ -200,7 +198,6 @@ public class ReactInstanceManager { boolean useDeveloperSupport, @Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener, LifecycleState initialLifecycleState, - UIImplementationProvider uiImplementationProvider, NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler, @Nullable RedBoxHandler redBoxHandler, boolean lazyNativeModulesEnabled, @@ -248,7 +245,6 @@ public class ReactInstanceManager { ReactInstanceManager.this.invokeDefaultOnBackPressed(); } }, - uiImplementationProvider, lazyViewManagersEnabled, minTimeLeftInFrameForNonBatchedOperationMs)); if (mUseDeveloperSupport) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java index d90f08f75..e57d5d809 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java @@ -10,9 +10,9 @@ import static com.facebook.react.modules.systeminfo.AndroidInfoHelpers.getFriend import android.app.Activity; import android.app.Application; import com.facebook.infer.annotation.Assertions; -import com.facebook.react.bridge.JSIModulePackage; import com.facebook.react.bridge.JSBundleLoader; import com.facebook.react.bridge.JSCJavaScriptExecutorFactory; +import com.facebook.react.bridge.JSIModulePackage; import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.bridge.NativeModuleCallExceptionHandler; import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener; @@ -21,7 +21,6 @@ import com.facebook.react.devsupport.RedBoxHandler; import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; import com.facebook.react.devsupport.interfaces.DevSupportManager; import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; -import com.facebook.react.uimanager.UIImplementationProvider; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; @@ -40,7 +39,6 @@ public class ReactInstanceManagerBuilder { private @Nullable Application mApplication; private boolean mUseDeveloperSupport; private @Nullable LifecycleState mInitialLifecycleState; - private @Nullable UIImplementationProvider mUIImplementationProvider; private @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler; private @Nullable Activity mCurrentActivity; private @Nullable DefaultHardwareBackBtnHandler mDefaultHardwareBackBtnHandler; @@ -56,16 +54,6 @@ public class ReactInstanceManagerBuilder { /* package protected */ ReactInstanceManagerBuilder() { } - /** - * Sets a provider of {@link UIImplementation}. - * Uses default provider if null is passed. - */ - public ReactInstanceManagerBuilder setUIImplementationProvider( - @Nullable UIImplementationProvider uiImplementationProvider) { - mUIImplementationProvider = uiImplementationProvider; - return this; - } - public ReactInstanceManagerBuilder setJSIModulesPackage( @Nullable JSIModulePackage jsiModulePackage) { mJSIModulesPackage = jsiModulePackage; @@ -251,11 +239,6 @@ public class ReactInstanceManagerBuilder { mJSMainModulePath != null || mJSBundleAssetUrl != null || mJSBundleLoader != null, "Either MainModulePath or JS Bundle File needs to be provided"); - if (mUIImplementationProvider == null) { - // create default UIImplementationProvider if the provided one is null. - mUIImplementationProvider = new UIImplementationProvider(); - } - // We use the name of the device and the app for debugging & metrics String appName = mApplication.getPackageName(); String deviceName = getFriendlyDeviceName(); @@ -276,7 +259,6 @@ public class ReactInstanceManagerBuilder { mUseDeveloperSupport, mBridgeIdleDebugListener, Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"), - mUIImplementationProvider, mNativeModuleCallExceptionHandler, mRedBoxHandler, mLazyNativeModulesEnabled, @@ -284,6 +266,6 @@ public class ReactInstanceManagerBuilder { mDevBundleDownloadListener, mMinNumShakes, mMinTimeLeftInFrameForNonBatchedOperationMs, - mJSIModulesPackage); + mJSIModulesPackage); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java b/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java index 2efa28daa..b408d9e2e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java @@ -7,20 +7,16 @@ package com.facebook.react; -import com.facebook.react.bridge.JSIModulePackage; -import javax.annotation.Nullable; - -import java.util.List; - import android.app.Application; - import com.facebook.infer.annotation.Assertions; +import com.facebook.react.bridge.JSIModulePackage; import com.facebook.react.bridge.JavaScriptExecutorFactory; import com.facebook.react.bridge.ReactMarker; import com.facebook.react.bridge.ReactMarkerConstants; import com.facebook.react.common.LifecycleState; import com.facebook.react.devsupport.RedBoxHandler; -import com.facebook.react.uimanager.UIImplementationProvider; +import java.util.List; +import javax.annotation.Nullable; /** * Simple class that holds an instance of {@link ReactInstanceManager}. This can be used in your @@ -74,7 +70,6 @@ public abstract class ReactNativeHost { .setUseDeveloperSupport(getUseDeveloperSupport()) .setRedBoxHandler(getRedBoxHandler()) .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory()) - .setUIImplementationProvider(getUIImplementationProvider()) .setJSIModulesPackage(getJSIModulePackage()) .setInitialLifecycleState(LifecycleState.BEFORE_CREATE); @@ -112,16 +107,6 @@ public abstract class ReactNativeHost { return mApplication; } - /** - * Get the {@link UIImplementationProvider} to use. Override this method if you want to use a - * custom UI implementation. - * - * Note: this is very advanced functionality, in 99% of cases you don't need to override this. - */ - protected UIImplementationProvider getUIImplementationProvider() { - return new UIImplementationProvider(); - } - protected @Nullable JSIModulePackage getJSIModulePackage() { return null; diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java deleted file mode 100644 index 51e0d66e9..000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementationProvider.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * - * 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.uimanager; - -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.uimanager.events.EventDispatcher; -import java.util.List; - -/** - * Provides UIImplementation to use in {@link UIManagerModule}. - */ -public class UIImplementationProvider { - public UIImplementation createUIImplementation( - ReactApplicationContext reactContext, - UIManagerModule.ViewManagerResolver viewManagerResolver, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - return new UIImplementation( - reactContext, - viewManagerResolver, - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); - } - - public UIImplementation createUIImplementation( - ReactApplicationContext reactContext, - List viewManagerList, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - return new UIImplementation( - reactContext, - viewManagerList, - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); - } -} 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 7c03ec96b..6be73b4e9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -124,7 +124,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements public UIManagerModule( ReactApplicationContext reactContext, ViewManagerResolver viewManagerResolver, - UIImplementationProvider uiImplementationProvider, int minTimeLeftInFrameForNonBatchedOperationMs) { super(reactContext); DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext); @@ -132,7 +131,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements mModuleConstants = createConstants(viewManagerResolver); mCustomDirectEvents = UIManagerModuleConstants.getDirectEventTypeConstants(); mUIImplementation = - uiImplementationProvider.createUIImplementation( + new UIImplementation( reactContext, viewManagerResolver, mEventDispatcher, @@ -144,7 +143,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements public UIManagerModule( ReactApplicationContext reactContext, List viewManagersList, - UIImplementationProvider uiImplementationProvider, int minTimeLeftInFrameForNonBatchedOperationMs) { super(reactContext); DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext); @@ -152,7 +150,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements mCustomDirectEvents = MapBuilder.newHashMap(); mModuleConstants = createConstants(viewManagersList, null, mCustomDirectEvents); mUIImplementation = - uiImplementationProvider.createUIImplementation( + new UIImplementation( reactContext, viewManagersList, mEventDispatcher, diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java index a4ee1a390..1b84c06d9 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactPropConstantsTest.java @@ -141,7 +141,7 @@ public class ReactPropConstantsTest { List viewManagers = Arrays.asList(new ViewManagerUnderTest()); ReactApplicationContext reactContext = new ReactApplicationContext(RuntimeEnvironment.application); UIManagerModule uiManagerModule = - new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0); + new UIManagerModule(reactContext, viewManagers, 0); Map constants = (Map) valueAtPath(uiManagerModule.getConstants(), "SomeView", "NativeProps"); assertThat(constants).isEqualTo( diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java index 40a8c68b4..143587565 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleConstantsTest.java @@ -8,14 +8,11 @@ package com.facebook.react.uimanager; import static org.fest.assertions.api.Assertions.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.common.MapBuilder; -import com.facebook.react.uimanager.events.EventDispatcher; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -49,25 +46,17 @@ public class UIManagerModuleConstantsTest { private static final Map TWIRL_DIRECT_EVENT_MAP = MapBuilder.of("registrationName", "onTwirl"); private ReactApplicationContext mReactContext; - private UIImplementationProvider mUIImplementationProvider; @Before public void setUp() { mReactContext = new ReactApplicationContext(RuntimeEnvironment.application); - mUIImplementationProvider = mock(UIImplementationProvider.class); - when(mUIImplementationProvider.createUIImplementation( - any(ReactApplicationContext.class), - any(List.class), - any(EventDispatcher.class), - anyInt())) - .thenReturn(mock(UIImplementation.class)); } @Test public void testNoCustomConstants() { List viewManagers = Arrays.asList(mock(ViewManager.class)); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); + new UIManagerModule(mReactContext, viewManagers, 0); Map constants = uiManagerModule.getConstants(); assertThat(constants) .containsKey(CUSTOM_BUBBLING_EVENT_TYPES) @@ -82,7 +71,7 @@ public class UIManagerModuleConstantsTest { when(mockViewManager.getExportedCustomBubblingEventTypeConstants()) .thenReturn(MapBuilder.of("onTwirl", TWIRL_BUBBLING_EVENT_MAP)); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); + new UIManagerModule(mReactContext, viewManagers, 0); Map constants = uiManagerModule.getConstants(); assertThat((Map) constants.get(CUSTOM_BUBBLING_EVENT_TYPES)) .contains(MapEntry.entry("onTwirl", TWIRL_BUBBLING_EVENT_MAP)) @@ -96,7 +85,7 @@ public class UIManagerModuleConstantsTest { when(mockViewManager.getExportedCustomDirectEventTypeConstants()) .thenReturn(MapBuilder.of("onTwirl", TWIRL_DIRECT_EVENT_MAP)); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); + new UIManagerModule(mReactContext, viewManagers, 0); Map constants = uiManagerModule.getConstants(); assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)) .contains(MapEntry.entry("onTwirl", TWIRL_DIRECT_EVENT_MAP)) @@ -111,7 +100,7 @@ public class UIManagerModuleConstantsTest { when(mockViewManager.getExportedViewConstants()) .thenReturn(MapBuilder.of("PhotoSizeType", MapBuilder.of("Small", 1, "Large", 2))); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); + new UIManagerModule(mReactContext, viewManagers, 0); Map constants = uiManagerModule.getConstants(); assertThat(constants).containsKey("RedPandaPhotoOfTheDayView"); assertThat((Map) constants.get("RedPandaPhotoOfTheDayView")).containsKey("Constants"); @@ -127,7 +116,7 @@ public class UIManagerModuleConstantsTest { when(mockViewManager.getNativeProps()) .thenReturn(MapBuilder.of("fooProp", "number")); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); + new UIManagerModule(mReactContext, viewManagers, 0); Map constants = uiManagerModule.getConstants(); assertThat((String) valueAtPath(constants, "SomeView", "NativeProps", "fooProp")) .isEqualTo("number"); @@ -159,7 +148,7 @@ public class UIManagerModuleConstantsTest { List viewManagers = Arrays.asList(managerX, managerY); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, mUIImplementationProvider, 0); + new UIManagerModule(mReactContext, viewManagers, 0); Map constants = uiManagerModule.getConstants(); assertThat((Map) constants.get(CUSTOM_DIRECT_EVENT_TYPES)).containsKey("onTwirl"); diff --git a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java index 6a90e84b6..b38ca784d 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/uimanager/UIManagerModuleTest.java @@ -814,7 +814,7 @@ public class UIManagerModuleTest { new ReactTextViewManager(), new ReactRawTextManager()); UIManagerModule uiManagerModule = - new UIManagerModule(mReactContext, viewManagers, new UIImplementationProvider(), 0); + new UIManagerModule(mReactContext, viewManagers, 0); uiManagerModule.onHostResume(); return uiManagerModule; } diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java index 2c14111e4..cb1136373 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java @@ -31,7 +31,6 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactTestHelper; import com.facebook.react.modules.core.ChoreographerCompat; import com.facebook.react.modules.core.ReactChoreographer; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewProps; @@ -428,7 +427,7 @@ public class ReactTextTest { new ReactRawTextManager(), }); UIManagerModule uiManagerModule = - new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0); + new UIManagerModule(reactContext, viewManagers, 0); uiManagerModule.onHostResume(); return uiManagerModule; } diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java index 988482eea..c9794d7d0 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/TextInputTest.java @@ -21,7 +21,6 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactTestHelper; import com.facebook.react.modules.core.ChoreographerCompat; import com.facebook.react.modules.core.ReactChoreographer; -import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewProps; @@ -178,7 +177,7 @@ public class TextInputTest { new ReactTextInputManager(), }); UIManagerModule uiManagerModule = - new UIManagerModule(reactContext, viewManagers, new UIImplementationProvider(), 0); + new UIManagerModule(reactContext, viewManagers, 0); uiManagerModule.onHostResume(); return uiManagerModule; }