mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Adding interface to wrap surface interactions for LogBox
Summary: This diff introduces a new interface named `SurfaceDelegate`. The interface abstracts the API for interacting with a surface, which is required for platforms other than mobile to implement how it wants to show and hide a surface. For existing Mobile use cases, the `LogBoxDialogSurfaceDelegate` is provided as a fallback solution so everything still works. Changelog: [Android][Added] - Add SurfaceDelegate abstraction to support interaction in multiple platforms and provide default implementation in LogBoxModule Reviewed By: mdvacca Differential Revision: D31132285 fbshipit-source-id: 13315a8bc5b7bcaee9b5e53ef5c6f6cc8cb01f31
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f2eecae63d
commit
652cb541a5
@@ -22,6 +22,7 @@ import com.facebook.react.bridge.JavaScriptExecutorFactory;
|
||||
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
|
||||
import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
|
||||
import com.facebook.react.common.LifecycleState;
|
||||
import com.facebook.react.common.SurfaceDelegateFactory;
|
||||
import com.facebook.react.devsupport.DefaultDevSupportManagerFactory;
|
||||
import com.facebook.react.devsupport.DevSupportManagerFactory;
|
||||
import com.facebook.react.devsupport.RedBoxHandler;
|
||||
@@ -63,6 +64,7 @@ public class ReactInstanceManagerBuilder {
|
||||
private @Nullable JSIModulePackage mJSIModulesPackage;
|
||||
private @Nullable Map<String, RequestHandler> mCustomPackagerCommandHandlers;
|
||||
private @Nullable ReactPackageTurboModuleManagerDelegate.Builder mTMMDelegateBuilder;
|
||||
private @Nullable SurfaceDelegateFactory mSurfaceDelegateFactory;
|
||||
|
||||
/* package protected */ ReactInstanceManagerBuilder() {}
|
||||
|
||||
@@ -195,6 +197,20 @@ public class ReactInstanceManagerBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* When the {@link SurfaceDelegateFactory} is provided, it will be used for native modules to get
|
||||
* a {@link SurfaceDelegate} to interact with the platform specific surface that they that needs
|
||||
* to be rendered in. For mobile platform this is default to be null so that these modules will
|
||||
* need to provide a default surface delegate. One example of such native module is LogBoxModule,
|
||||
* which is rendered in mobile platform with LogBoxDialog, while in VR platform with custom layer
|
||||
* provided by runtime.
|
||||
*/
|
||||
public ReactInstanceManagerBuilder setSurfaceDelegateFactory(
|
||||
@Nullable final SurfaceDelegateFactory surfaceDelegateFactory) {
|
||||
mSurfaceDelegateFactory = surfaceDelegateFactory;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the initial lifecycle state of the host. For example, if the host is already resumed at
|
||||
* creation time, we wouldn't expect an onResume call until we get an onPause call.
|
||||
@@ -322,7 +338,8 @@ public class ReactInstanceManagerBuilder {
|
||||
mMinTimeLeftInFrameForNonBatchedOperationMs,
|
||||
mJSIModulesPackage,
|
||||
mCustomPackagerCommandHandlers,
|
||||
mTMMDelegateBuilder);
|
||||
mTMMDelegateBuilder,
|
||||
mSurfaceDelegateFactory);
|
||||
}
|
||||
|
||||
private JavaScriptExecutorFactory getDefaultJSExecutorFactory(
|
||||
|
||||
Reference in New Issue
Block a user