diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java index 11e548ed9..730af183d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatARTSurfaceViewManager.java @@ -16,7 +16,7 @@ import com.facebook.react.uimanager.BaseViewManager; import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.views.art.ARTSurfaceView; -/* protected */ class FlatARTSurfaceViewManager extends +public class FlatARTSurfaceViewManager extends BaseViewManager { private static final String REACT_CLASS = "ARTSurfaceView"; diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUI.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUI.java new file mode 100644 index 000000000..ac3e8ea47 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUI.java @@ -0,0 +1,11 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +package com.facebook.react.flat; + +/** + * Holds global flag for enabling nodes. + */ +public class FlatUI { + + public static boolean sEnabled; +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java index 4afb6c4e6..3b9d6e9c7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java @@ -11,7 +11,6 @@ package com.facebook.react.flat; import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -52,18 +51,6 @@ public class FlatUIImplementation extends UIImplementation { TypefaceCache.setAssetManager(reactContext.getAssets()); - viewManagers = new ArrayList<>(viewManagers); - viewManagers.add(new RCTViewManager()); - viewManagers.add(new RCTTextManager()); - viewManagers.add(new RCTRawTextManager()); - viewManagers.add(new RCTVirtualTextManager()); - viewManagers.add(new RCTTextInlineImageManager()); - viewManagers.add(new RCTImageViewManager()); - viewManagers.add(new RCTTextInputManager()); - viewManagers.add(new RCTViewPagerManager()); - viewManagers.add(new FlatARTSurfaceViewManager()); - viewManagers.add(new RCTModalHostManager()); - ViewManagerRegistry viewManagerRegistry = new ViewManagerRegistry(viewManagers); FlatNativeViewHierarchyManager nativeViewHierarchyManager = new FlatNativeViewHierarchyManager( viewManagerRegistry); diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTImageViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTImageViewManager.java index b81fd6403..c697be207 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTImageViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTImageViewManager.java @@ -9,7 +9,7 @@ package com.facebook.react.flat; -/* package */ final class RCTImageViewManager extends FlatViewManager { +public final class RCTImageViewManager extends FlatViewManager { @Override public String getName() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTModalHostManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTModalHostManager.java index fee57feb5..37b9eab67 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTModalHostManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTModalHostManager.java @@ -12,7 +12,7 @@ package com.facebook.react.flat; import com.facebook.react.uimanager.LayoutShadowNode; import com.facebook.react.views.modal.ReactModalHostManager; -/* package */ class RCTModalHostManager extends ReactModalHostManager { +public class RCTModalHostManager extends ReactModalHostManager { @Override public LayoutShadowNode createShadowNodeInstance() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTRawTextManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTRawTextManager.java index ee2e557f4..6cc82f922 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTRawTextManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTRawTextManager.java @@ -12,7 +12,7 @@ package com.facebook.react.flat; /** * ViewManager that creates instances of RCTRawText. */ -/* package */ final class RCTRawTextManager extends VirtualViewManager { +public final class RCTRawTextManager extends VirtualViewManager { @Override public String getName() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInlineImageManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInlineImageManager.java index 5f422cefb..3bd0f9fe3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInlineImageManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInlineImageManager.java @@ -12,7 +12,7 @@ package com.facebook.react.flat; /** * ViewManager that creates instances of RCTTextInlineImage. */ -/* package */ final class RCTTextInlineImageManager extends VirtualViewManager { +public final class RCTTextInlineImageManager extends VirtualViewManager { @Override public String getName() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInputManager.java index 66eea3fd2..7ef8fb8e1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextInputManager.java @@ -11,7 +11,7 @@ package com.facebook.react.flat; import com.facebook.react.views.textinput.ReactTextInputManager; -/* package */ class RCTTextInputManager extends ReactTextInputManager { +public class RCTTextInputManager extends ReactTextInputManager { @Override public RCTTextInput createShadowNodeInstance() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextManager.java index feb5240d0..0563426c7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTTextManager.java @@ -12,7 +12,7 @@ package com.facebook.react.flat; /** * ViewManager that creates instances of RCTText. */ -/* package */ final class RCTTextManager extends FlatViewManager { +public final class RCTTextManager extends FlatViewManager { @Override public String getName() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewManager.java index dd1caade0..d27d32c75 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewManager.java @@ -30,7 +30,7 @@ import com.facebook.react.views.view.ReactDrawableHelper; /** * ViewManager that creates instances of RCTView. */ -/* package */ final class RCTViewManager extends FlatViewManager { +public final class RCTViewManager extends FlatViewManager { private static final int[] TMP_INT_ARRAY = new int[2]; @@ -39,7 +39,7 @@ import com.facebook.react.views.view.ReactDrawableHelper; @Override public String getName() { - return "RCTView"; + return ViewProps.VIEW_CLASS_NAME; } public Map getCommandsMap() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewPagerManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewPagerManager.java index a3210043d..5558b75ec 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewPagerManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTViewPagerManager.java @@ -16,7 +16,7 @@ import android.view.View; import com.facebook.react.views.viewpager.ReactViewPager; import com.facebook.react.views.viewpager.ReactViewPagerManager; -/* package */ class RCTViewPagerManager extends ReactViewPagerManager { +public class RCTViewPagerManager extends ReactViewPagerManager { @Override public void addViews(ReactViewPager parent, List views) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTVirtualTextManager.java b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTVirtualTextManager.java index 155ee9682..57d351610 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/RCTVirtualTextManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/RCTVirtualTextManager.java @@ -12,7 +12,7 @@ package com.facebook.react.flat; /** * ViewManager that creates instances of RCTVirtualText. */ -/* package */ final class RCTVirtualTextManager extends VirtualViewManager { +public final class RCTVirtualTextManager extends VirtualViewManager { @Override public String getName() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK b/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK index a52389383..577a832de 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK @@ -14,6 +14,7 @@ android_library( react_native_target('java/com/facebook/react/bridge:bridge'), react_native_target('java/com/facebook/react/common:common'), react_native_target('java/com/facebook/react/devsupport:devsupport'), + react_native_target('java/com/facebook/react/flat:flat'), react_native_target('java/com/facebook/react/module/model:model'), react_native_target('java/com/facebook/react/modules/appstate:appstate'), react_native_target('java/com/facebook/react/modules/camera:camera'), @@ -62,4 +63,3 @@ android_library( 'PUBLIC', ], ) - diff --git a/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java index 9bb4a0de5..94b535a39 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java @@ -11,16 +11,30 @@ package com.facebook.react.shell; import javax.inject.Provider; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; + import com.facebook.react.LazyReactPackage; import com.facebook.react.animated.NativeAnimatedModule; import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.ModuleSpec; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.flat.FlatARTSurfaceViewManager; +import com.facebook.react.flat.RCTImageViewManager; +import com.facebook.react.flat.RCTModalHostManager; +import com.facebook.react.flat.RCTRawTextManager; +import com.facebook.react.flat.RCTTextInlineImageManager; +import com.facebook.react.flat.RCTTextInputManager; +import com.facebook.react.flat.RCTTextManager; +import com.facebook.react.flat.RCTViewManager; +import com.facebook.react.flat.RCTViewPagerManager; +import com.facebook.react.flat.RCTVirtualTextManager; import com.facebook.react.module.model.ReactModuleInfoProvider; import com.facebook.react.modules.appstate.AppStateModule; import com.facebook.react.modules.camera.CameraRollManager; @@ -236,32 +250,50 @@ public class MainReactPackage extends LazyReactPackage { @Override public List createViewManagers(ReactApplicationContext reactContext) { - return Arrays.asList( - ARTRenderableViewManager.createARTGroupViewManager(), - ARTRenderableViewManager.createARTShapeViewManager(), - ARTRenderableViewManager.createARTTextViewManager(), - new ARTSurfaceViewManager(), - new ReactDialogPickerManager(), - new ReactDrawerLayoutManager(), - new ReactDropdownPickerManager(), - new ReactHorizontalScrollViewManager(), - new ReactImageManager(), - new ReactModalHostManager(), - new ReactProgressBarViewManager(), - new ReactRawTextManager(), - new ReactScrollViewManager(), - new ReactSliderManager(), - new ReactSwitchManager(), - new FrescoBasedReactTextInlineImageViewManager(), - new ReactTextInputManager(), - new ReactTextViewManager(), - new ReactToolbarManager(), - new ReactViewManager(), - new ReactViewPagerManager(), - new ReactVirtualTextViewManager(), - new ReactWebViewManager(), - new RecyclerViewBackedScrollViewManager(), - new SwipeRefreshLayoutManager()); + List viewManagers = new ArrayList<>(); + + viewManagers.add(ARTRenderableViewManager.createARTGroupViewManager()); + viewManagers.add(ARTRenderableViewManager.createARTShapeViewManager()); + viewManagers.add(ARTRenderableViewManager.createARTTextViewManager()); + viewManagers.add(new ARTSurfaceViewManager()); + viewManagers.add(new ReactDialogPickerManager()); + viewManagers.add(new ReactDrawerLayoutManager()); + viewManagers.add(new ReactDropdownPickerManager()); + viewManagers.add(new ReactHorizontalScrollViewManager()); + viewManagers.add(new ReactImageManager()); + viewManagers.add(new ReactModalHostManager()); + viewManagers.add(new ReactProgressBarViewManager()); + viewManagers.add(new ReactRawTextManager()); + viewManagers.add(new ReactScrollViewManager()); + viewManagers.add(new ReactSliderManager()); + viewManagers.add(new ReactSwitchManager()); + viewManagers.add(new FrescoBasedReactTextInlineImageViewManager()); + viewManagers.add(new ReactTextInputManager()); + viewManagers.add(new ReactTextViewManager()); + viewManagers.add(new ReactToolbarManager()); + viewManagers.add(new ReactViewManager()); + viewManagers.add(new ReactViewPagerManager()); + viewManagers.add(new ReactVirtualTextViewManager()); + viewManagers.add(new ReactWebViewManager()); + viewManagers.add(new RecyclerViewBackedScrollViewManager()); + viewManagers.add(new SwipeRefreshLayoutManager()); + + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(reactContext); + if (preferences.getBoolean("flat_uiimplementation", false)) { + viewManagers.addAll(Arrays.asList( + new RCTViewManager(), + new RCTTextManager(), + new RCTRawTextManager(), + new RCTVirtualTextManager(), + new RCTTextInlineImageManager(), + new RCTImageViewManager(), + new RCTTextInputManager(), + new RCTViewPagerManager(), + new FlatARTSurfaceViewManager(), + new RCTModalHostManager())); + } + + return viewManagers; } @Override