[RN] Fix full-screen mode when coming back from the background

On Android the status and navigation bars are shown again after coming back from
the background, so enter full-screen mode again if needed.
This commit is contained in:
Saúl Ibarra Corretgé 2017-02-08 17:25:49 +01:00 committed by Lyubomir Marinov
parent 4519f26adf
commit c57e713696
2 changed files with 14 additions and 5 deletions

View File

@ -1,2 +1,3 @@
export * from './actionTypes';
import './middleware';
import './reducer';

View File

@ -3,6 +3,7 @@
import { StatusBar } from 'react-native';
import { Immersive } from 'react-native-immersive';
import { APP_STATE_CHANGED } from '../background';
import {
CONFERENCE_FAILED,
CONFERENCE_LEFT,
@ -23,9 +24,20 @@ import { MiddlewareRegistry } from '../base/redux';
* @returns {Function}
*/
MiddlewareRegistry.register(store => next => action => {
let fullScreen;
let fullScreen = null;
switch (action.type) {
case APP_STATE_CHANGED: {
// Check if we just came back from the background and reenable full
// screen mode if necessary.
if (action.appState === 'active') {
const conference = store.getState()['features/base/conference'];
fullScreen = conference ? !conference.audioOnly : false;
}
break;
}
case CONFERENCE_WILL_JOIN: {
const conference = store.getState()['features/base/conference'];
@ -37,10 +49,6 @@ MiddlewareRegistry.register(store => next => action => {
case CONFERENCE_LEFT:
fullScreen = false;
break;
default:
fullScreen = null;
break;
}
if (fullScreen !== null) {