diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index 43c1b31135..2813436804 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -16,10 +16,9 @@ const Platform = require('Platform'); const PropTypes = require('react/lib/ReactPropTypes'); const React = require('React'); const StyleSheet = require('StyleSheet'); -const UIManager = require('UIManager'); const View = require('View'); -const deprecatedPropType = require('deprecatedPropType'); +const deprecatedPropType = require('deprecatedPropType'); const requireNativeComponent = require('requireNativeComponent'); const RCTModalHostView = requireNativeComponent('RCTModalHostView', null); @@ -136,7 +135,6 @@ class Modal extends React.Component { const containerStyles = { backgroundColor: this.props.transparent ? 'transparent' : 'white', - top: Platform.OS === 'android' && Platform.Version >= 19 ? UIManager.RCTModalHostView.Constants.StatusBarHeight : 0, }; let animationType = this.props.animationType; 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 af6c7449e2..c2a5c933db 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 @@ -17,13 +17,13 @@ import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; -import android.graphics.Point; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.view.accessibility.AccessibilityEvent; +import android.widget.FrameLayout; import com.facebook.infer.annotation.Assertions; import com.facebook.react.R; @@ -204,7 +204,7 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe } mDialog = new Dialog(getContext(), theme); - mDialog.setContentView(mHostView); + mDialog.setContentView(getContentView()); updateProperties(); mDialog.setOnShowListener(mOnShowListener); @@ -236,9 +236,23 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe } }); + mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); mDialog.show(); } + /** + * Returns the view that will be the root view of the dialog. We are wrapping this in a + * FrameLayout because this is the system's way of notifying us that the dialog size has changed. + * This has the pleasant side-effect of us not having to preface all Modals with + * "top: statusBarHeight", since that margin will be included in the FrameLayout. + */ + private View getContentView() { + FrameLayout frameLayout = new FrameLayout(getContext()); + frameLayout.addView(mHostView); + frameLayout.setFitsSystemWindows(true); + return frameLayout; + } + /** * updateProperties will update the properties that do not require us to recreate the dialog * Properties that do require us to recreate the dialog should set mPropertyRequiresNewDialog to @@ -284,9 +298,8 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe new Runnable() { @Override public void run() { - Point modalSize = ModalHostHelper.getModalHostSize(getContext()); ((ReactContext) getContext()).getNativeModule(UIManagerModule.class) - .updateNodeSize(getChildAt(0).getId(), modalSize.x, modalSize.y); + .updateNodeSize(getChildAt(0).getId(), w, h); } }); }