From e15a7610840a3c7f91d153d86f631c1d2debbd0b Mon Sep 17 00:00:00 2001 From: David Vacca Date: Sun, 17 Jun 2018 11:41:12 -0700 Subject: [PATCH] Add noop support for setJSResponder / clearJSReponder API methods Reviewed By: fkgozali Differential Revision: D8458980 fbshipit-source-id: 2411fb8106288f65cabdef12917d0f5086d1723a --- .../java/com/facebook/react/bridge/UIManager.java | 5 +++++ .../com/facebook/react/fabric/FabricUIManager.java | 14 ++++++++++++++ .../facebook/react/uimanager/UIManagerModule.java | 11 +++++++++++ 3 files changed, 30 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java index e1f778b8c..e08133ded 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.java @@ -27,4 +27,9 @@ public interface UIManager extends JSIModule, PerformanceCounter { * @param commandArgs {@link ReadableArray} parameters associated with the command */ void dispatchCommand(int reactTag, int commandId, @Nullable ReadableArray commandArgs); + + void setJSResponder(int reactTag, boolean blockNativeResponder); + + void clearJSResponder(); + } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 4cb25a51c..d72e6cc8b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -10,6 +10,7 @@ package com.facebook.react.fabric; import static android.view.View.MeasureSpec.AT_MOST; import static android.view.View.MeasureSpec.EXACTLY; import static android.view.View.MeasureSpec.UNSPECIFIED; +import static com.facebook.react.uimanager.common.UIManagerType.DEFAULT; import static com.facebook.react.uimanager.common.UIManagerType.FABRIC; import android.os.SystemClock; @@ -21,6 +22,7 @@ import com.facebook.infer.annotation.Assertions; import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.JavaScriptContextHolder; import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableNativeMap; @@ -39,11 +41,13 @@ import com.facebook.react.uimanager.ReactShadowNode; import com.facebook.react.uimanager.ReactShadowNodeImpl; import com.facebook.react.uimanager.ReactStylesDiffMap; import com.facebook.react.uimanager.ThemedReactContext; +import com.facebook.react.uimanager.UIManagerHelper; import com.facebook.react.uimanager.UIViewOperationQueue; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.react.uimanager.common.MeasureSpecProvider; import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.systrace.Systrace; import com.facebook.systrace.SystraceMessage; @@ -645,6 +649,16 @@ public class FabricUIManager implements UIManager, JSHandler { mBinding.dispatchEventToTarget(mJSContext.get(), mEventHandlerPointer, eventTarget, name, (WritableNativeMap) params); } + @Override + public void setJSResponder(int reactTag, boolean blockNativeResponder) { + // TODO: Do nothing for now + } + + @Override + public void clearJSResponder() { + // TODO: Do nothing for now + } + @Override public void initialize() { FabricEventEmitter eventEmitter = 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 f35511c33..1ac393b06 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -10,6 +10,7 @@ package com.facebook.react.uimanager; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_CONSTANTS_END; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_CONSTANTS_START; import static com.facebook.react.uimanager.common.UIManagerType.DEFAULT; +import static com.facebook.react.uimanager.common.UIManagerType.FABRIC; import android.content.ComponentCallbacks2; import android.content.Context; @@ -39,6 +40,7 @@ import com.facebook.react.common.ReactConstants; import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.uimanager.common.MeasureSpecProvider; import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout; +import com.facebook.react.uimanager.common.UIManagerType; import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.react.uimanager.events.EventDispatcher; @@ -585,11 +587,20 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements mUIImplementation.removeAnimation(reactTag, animationID); } + @Override @ReactMethod public void setJSResponder(int reactTag, boolean blockNativeResponder) { + //TODO: this is a temporary approach to support ViewManagerCommands in Fabric until + // the dispatchViewManagerCommand() method is supported by Fabric JS API. + int uiManagerType = ViewUtil.getUIManagerType(reactTag); + if (uiManagerType != DEFAULT) { + UIManagerHelper.getUIManager(getReactApplicationContext(), uiManagerType).setJSResponder(reactTag, blockNativeResponder); + } + mUIImplementation.setJSResponder(reactTag, blockNativeResponder); } + @Override @ReactMethod public void clearJSResponder() { mUIImplementation.clearJSResponder();