Do not bring app out of immersive mode when a modal is presented (#21078)

Summary:
This does fix the issue, however, another, perhaps related issue persists, the dialog/modal occasionally uses what would be the height of the app in non-immersive mode, in immersive mode. Meaning that the background, what ever it is set as, does not use the full available height.

See https://stackoverflow.com/a/23207365 for more info.

Known Problems:
---------
* [Date/time picker](https://facebook.github.io/react-native/docs/datepickerandroid) still brings app out of immersive mode - The date/time picker dialog needs the same treatment (this MR) as `RN Modal` using a wrapper.
* Focusing on text input, which brings up keyboard, also brings app out of immersive mode. Sometimes temporarily, sometimes permanently - Needs investigating. I have tried [this](https://stackoverflow.com/a/25129542), unfortunately it doesn't work. **Workaround I'm using for this, is to call a native module method to re-apply immersive mode flags after `keyboardDidHide` on JS side.**

Changelog:
----------

[Android] [Fixed] - Dialog (RN Modal) brings app permanently out of immersive mode
Pull Request resolved: https://github.com/facebook/react-native/pull/21078

Differential Revision: D14163127

Pulled By: cpojer

fbshipit-source-id: e0b67c91fa81880b19438a939bca26c128309799
This commit is contained in:
Rizwaan Bhikha 2019-02-20 23:18:02 -08:00 коммит произвёл Facebook Github Bot
Родитель ba0c3ffd5b
Коммит f8a4d281e2
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -224,6 +224,7 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
Activity currentActivity = getCurrentActivity();
Context context = currentActivity == null ? getContext() : currentActivity;
mDialog = new Dialog(context, theme);
mDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
mDialog.setContentView(getContentView());
updateProperties();
@ -263,6 +264,12 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
}
if (currentActivity != null && !currentActivity.isFinishing()) {
mDialog.show();
if (context instanceof Activity){
mDialog.getWindow().getDecorView().setSystemUiVisibility(
((Activity)context).getWindow().getDecorView().getSystemUiVisibility()
);
}
mDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
}
}