diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index 782ec78a3..064d6481c 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -93,6 +93,11 @@ class Modal extends React.Component { * The `transparent` prop determines whether your modal will fill the entire view. Setting this to `true` will render the modal over a transparent background. */ transparent: PropTypes.bool, + /** + * The `hardwareAccelerated` prop controls whether to force hardware acceleration for the underlying window. + * @platform android + */ + hardwareAccelerated: PropTypes.bool, /** * The `visible` prop determines whether your modal is visible. */ @@ -126,6 +131,7 @@ class Modal extends React.Component { static defaultProps = { visible: true, + hardwareAccelerated: false, }; static contextTypes = { @@ -160,6 +166,7 @@ class Modal extends React.Component { view.setTransparent(transparent); } + @ReactProp(name = "hardwareAccelerated") + public void setHardwareAccelerated(ReactModalHostView view, boolean hardwareAccelerated) { + view.setHardwareAccelerated(hardwareAccelerated); + } + @Override protected void addEventEmitters( ThemedReactContext reactContext, diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java index c2a5c933d..98ad5e0d6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java @@ -61,6 +61,7 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe private @Nullable Dialog mDialog; private boolean mTransparent; private String mAnimationType; + private boolean mHardwareAccelerated; // Set this flag to true if changing a particular property on the view requires a new Dialog to // be created. For instance, animation does since it affects Dialog creation through the theme // but transparency does not since we can access the window to update the property. @@ -153,6 +154,11 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe mPropertyRequiresNewDialog = true; } + protected void setHardwareAccelerated(boolean hardwareAccelerated) { + mHardwareAccelerated = hardwareAccelerated; + mPropertyRequiresNewDialog = true; + } + @Override public void onHostResume() { // We show the dialog again when the host resumes @@ -237,6 +243,9 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe }); mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); + if (mHardwareAccelerated) { + mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); + } mDialog.show(); }