-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
f2eecae
commit 652cb54
Showing
14 changed files
with
288 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
ReactAndroid/src/main/java/com/facebook/react/common/SurfaceDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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.common; | ||
|
||
/** | ||
* Interface for handling a surface in React Native. In mobile platform a surface can be any | ||
* container that holds some {@link View}. For example, a Dialog can be a surface to wrap content | ||
* view object as needed. In VR platform, a surface is provided by Shell panel app sdk, which | ||
* requires custom logic to show/hide. NativeModules requires a surface will delegate interactions | ||
* with the surface to a SurfaceDelegate. | ||
*/ | ||
public interface SurfaceDelegate { | ||
/** | ||
* Create the React content view that uses the appKey as the React application name | ||
* | ||
* @param appKey | ||
*/ | ||
void createContentView(String appKey); | ||
|
||
/** | ||
* Check if the content view is created and ready to be shown | ||
* | ||
* @return true if the content view is ready to be shown | ||
*/ | ||
boolean isContentViewReady(); | ||
|
||
/** Destroy the React content view to avoid memory leak */ | ||
void destroyContentView(); | ||
|
||
/** Show the surface containing the React content view */ | ||
void show(); | ||
|
||
/** Hide the surface containing the React content view */ | ||
void hide(); | ||
} |
24 changes: 24 additions & 0 deletions
24
ReactAndroid/src/main/java/com/facebook/react/common/SurfaceDelegateFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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.common; | ||
|
||
/** | ||
* Factory to create a {@link SurfaceDelegate}. The moduleName is needed to help the factory decide | ||
* which surface to return {@link SurfaceDelegate} that the given module should use to interact | ||
* with. | ||
*/ | ||
public interface SurfaceDelegateFactory { | ||
/** | ||
* Create a {@link SurfaceDelegate} instance which is used to interact with a surface of platform | ||
* the app is running in. | ||
* | ||
* @param moduleName the module name that will be using the surface | ||
* @return {@link SurfaceDelegate} instance | ||
*/ | ||
SurfaceDelegate createSurfaceDelegate(String moduleName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.