|
@@ -1,3 +1,5 @@
|
|
1
|
+/* @flow */
|
|
2
|
+
|
1
|
3
|
import { StatusBar } from 'react-native';
|
2
|
4
|
import { Immersive } from 'react-native-immersive';
|
3
|
5
|
|
|
@@ -11,7 +13,7 @@ import { MiddlewareRegistry } from '../base/redux';
|
11
|
13
|
|
12
|
14
|
/**
|
13
|
15
|
* Middleware that captures conference actions and activates or deactivates the
|
14
|
|
- * full screen mode. On iOS it hides the status bar, and on Android it uses the
|
|
16
|
+ * full screen mode. On iOS it hides the status bar, and on Android it uses the
|
15
|
17
|
* immersive mode:
|
16
|
18
|
* https://developer.android.com/training/system-ui/immersive.html
|
17
|
19
|
* In immersive mode the status and navigation bars are hidden and thus the
|
|
@@ -21,31 +23,30 @@ import { MiddlewareRegistry } from '../base/redux';
|
21
|
23
|
* @returns {Function}
|
22
|
24
|
*/
|
23
|
25
|
MiddlewareRegistry.register(store => next => action => {
|
24
|
|
- let useFullScreen;
|
|
26
|
+ let fullScreen;
|
25
|
27
|
|
26
|
28
|
switch (action.type) {
|
27
|
29
|
case CONFERENCE_WILL_JOIN: {
|
28
|
|
- const state = store.getState()['features/base/conference'];
|
|
30
|
+ const conference = store.getState()['features/base/conference'];
|
29
|
31
|
|
30
|
|
- useFullScreen = !state.audioOnly;
|
|
32
|
+ fullScreen = !conference.audioOnly;
|
31
|
33
|
break;
|
32
|
34
|
}
|
33
|
35
|
|
34
|
36
|
case CONFERENCE_FAILED:
|
35
|
37
|
case CONFERENCE_LEFT:
|
36
|
|
- useFullScreen = false;
|
|
38
|
+ fullScreen = false;
|
37
|
39
|
break;
|
38
|
40
|
|
39
|
41
|
default:
|
40
|
|
- useFullScreen = null;
|
|
42
|
+ fullScreen = null;
|
41
|
43
|
break;
|
42
|
44
|
}
|
43
|
45
|
|
44
|
|
- if (useFullScreen !== null) {
|
45
|
|
- setFullScreen(useFullScreen)
|
46
|
|
- .catch(err => {
|
47
|
|
- console.warn(`Error setting full screen mode: ${err}`);
|
48
|
|
- });
|
|
46
|
+ if (fullScreen !== null) {
|
|
47
|
+ _setFullScreen(fullScreen)
|
|
48
|
+ .catch(err =>
|
|
49
|
+ console.warn(`Failed to set full screen mode: ${err}`));
|
49
|
50
|
}
|
50
|
51
|
|
51
|
52
|
return next(action);
|
|
@@ -53,24 +54,23 @@ MiddlewareRegistry.register(store => next => action => {
|
53
|
54
|
|
54
|
55
|
/**
|
55
|
56
|
* Activates/deactivates the full screen mode. On iOS it will hide the status
|
56
|
|
- * bar and On Android this will turn on immersive mode.
|
|
57
|
+ * bar, and on Android it will turn immersive mode on.
|
57
|
58
|
*
|
58
|
|
- * @param {boolean} enabled - True to set full screen mode, false to
|
|
59
|
+ * @param {boolean} fullScreen - True to set full screen mode, false to
|
59
|
60
|
* deactivate it.
|
|
61
|
+ * @private
|
60
|
62
|
* @returns {Promise}
|
61
|
63
|
*/
|
62
|
|
-function setFullScreen(enabled) {
|
63
|
|
- // XXX The Immersive module is only implemented on Android and throws on
|
64
|
|
- // other platforms.
|
|
64
|
+function _setFullScreen(fullScreen: boolean) {
|
|
65
|
+ // XXX The React Native module Immersive is only implemented on Android and
|
|
66
|
+ // throws on other platforms.
|
65
|
67
|
if (Platform.OS === 'android') {
|
66
|
|
- if (enabled) {
|
67
|
|
- return Immersive.on();
|
68
|
|
- }
|
69
|
|
-
|
70
|
|
- return Immersive.off();
|
|
68
|
+ return fullScreen ? Immersive.on() : Immersive.off();
|
71
|
69
|
}
|
72
|
70
|
|
73
|
|
- StatusBar.setHidden(enabled, 'slide');
|
|
71
|
+ // On platforms other than Android go with whatever React Native itself
|
|
72
|
+ // supports.
|
|
73
|
+ StatusBar.setHidden(fullScreen, 'slide');
|
74
|
74
|
|
75
|
75
|
return Promise.resolve();
|
76
|
76
|
}
|