|
@@ -0,0 +1,76 @@
|
|
1
|
+import { StatusBar } from 'react-native';
|
|
2
|
+import { Immersive } from 'react-native-immersive';
|
|
3
|
+
|
|
4
|
+import {
|
|
5
|
+ CONFERENCE_FAILED,
|
|
6
|
+ CONFERENCE_LEFT,
|
|
7
|
+ CONFERENCE_WILL_JOIN
|
|
8
|
+} from '../base/conference';
|
|
9
|
+import { Platform } from '../base/react';
|
|
10
|
+import { MiddlewareRegistry } from '../base/redux';
|
|
11
|
+
|
|
12
|
+/**
|
|
13
|
+ * 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
|
|
15
|
+ * immersive mode:
|
|
16
|
+ * https://developer.android.com/training/system-ui/immersive.html
|
|
17
|
+ * In immersive mode the status and navigation bars are hidden and thus the
|
|
18
|
+ * entire screen will be covered by our application.
|
|
19
|
+ *
|
|
20
|
+ * @param {Store} store - Redux store.
|
|
21
|
+ * @returns {Function}
|
|
22
|
+ */
|
|
23
|
+MiddlewareRegistry.register(store => next => action => {
|
|
24
|
+ let useFullScreen;
|
|
25
|
+
|
|
26
|
+ switch (action.type) {
|
|
27
|
+ case CONFERENCE_WILL_JOIN: {
|
|
28
|
+ const state = store.getState()['features/base/conference'];
|
|
29
|
+
|
|
30
|
+ useFullScreen = !state.audioOnly;
|
|
31
|
+ break;
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ case CONFERENCE_FAILED:
|
|
35
|
+ case CONFERENCE_LEFT:
|
|
36
|
+ useFullScreen = false;
|
|
37
|
+ break;
|
|
38
|
+
|
|
39
|
+ default:
|
|
40
|
+ useFullScreen = null;
|
|
41
|
+ break;
|
|
42
|
+ }
|
|
43
|
+
|
|
44
|
+ if (useFullScreen !== null) {
|
|
45
|
+ setFullScreen(useFullScreen)
|
|
46
|
+ .catch(err => {
|
|
47
|
+ console.warn(`Error setting full screen mode: ${err}`);
|
|
48
|
+ });
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ return next(action);
|
|
52
|
+});
|
|
53
|
+
|
|
54
|
+/**
|
|
55
|
+ * 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
|
+ *
|
|
58
|
+ * @param {boolean} enabled - True to set full screen mode, false to
|
|
59
|
+ * deactivate it.
|
|
60
|
+ * @returns {Promise}
|
|
61
|
+ */
|
|
62
|
+function setFullScreen(enabled) {
|
|
63
|
+ // XXX The Immersive module is only implemented on Android and throws on
|
|
64
|
+ // other platforms.
|
|
65
|
+ if (Platform.OS === 'android') {
|
|
66
|
+ if (enabled) {
|
|
67
|
+ return Immersive.on();
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ return Immersive.off();
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ StatusBar.setHidden(enabled, 'slide');
|
|
74
|
+
|
|
75
|
+ return Promise.resolve();
|
|
76
|
+}
|