Browse Source

[RN] Implement full screen mode while in a conference

The implementation varies across platforms, with the same goal: allow the app to
use the entire screen real state while in a conference.

On Android we use immersive mode, which  will hide the status and navigation bars.

https://developer.android.com/training/system-ui/immersive.html

On iOS the status bar is hidden, with a slide effect.
j8
Saúl Ibarra Corretgé 8 years ago
parent
commit
7a8c84e990

+ 1
- 0
android/app/build.gradle View File

139
 }
139
 }
140
 
140
 
141
 dependencies {
141
 dependencies {
142
+    compile project(':react-native-immersive')
142
     compile project(':react-native-keep-awake')
143
     compile project(':react-native-keep-awake')
143
     compile project(':react-native-vector-icons')
144
     compile project(':react-native-vector-icons')
144
     compile project(':react-native-webrtc')
145
     compile project(':react-native-webrtc')

+ 1
- 0
android/app/src/main/java/org/jitsi/meet/MainApplication.java View File

30
                 new com.facebook.react.shell.MainReactPackage(),
30
                 new com.facebook.react.shell.MainReactPackage(),
31
                 new com.oblador.vectoricons.VectorIconsPackage(),
31
                 new com.oblador.vectoricons.VectorIconsPackage(),
32
                 new com.oney.WebRTCModule.WebRTCModulePackage(),
32
                 new com.oney.WebRTCModule.WebRTCModulePackage(),
33
+                new com.rnimmersive.RNImmersivePackage(),
33
                 new org.jitsi.meet.audiomode.AudioModePackage()
34
                 new org.jitsi.meet.audiomode.AudioModePackage()
34
             );
35
             );
35
         }
36
         }

+ 2
- 0
android/settings.gradle View File

1
 rootProject.name = 'jitsi-meet-react'
1
 rootProject.name = 'jitsi-meet-react'
2
+include ':react-native-immersive'
3
+project(':react-native-immersive').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immersive/android')
2
 
4
 
3
 include ':app'
5
 include ':app'
4
 include ':react-native-keep-awake'
6
 include ':react-native-keep-awake'

+ 2
- 1
package.json View File

22
     "bootstrap": "3.1.1",
22
     "bootstrap": "3.1.1",
23
     "i18next": "3.4.4",
23
     "i18next": "3.4.4",
24
     "i18next-xhr-backend": "1.1.0",
24
     "i18next-xhr-backend": "1.1.0",
25
+    "jQuery-Impromptu": "trentrichardson/jQuery-Impromptu#v6.0.0",
25
     "jitsi-meet-logger": "jitsi/jitsi-meet-logger",
26
     "jitsi-meet-logger": "jitsi/jitsi-meet-logger",
26
     "jquery": "~2.1.1",
27
     "jquery": "~2.1.1",
27
     "jquery-contextmenu": "*",
28
     "jquery-contextmenu": "*",
28
     "jquery-i18next": "1.1.0",
29
     "jquery-i18next": "1.1.0",
29
-    "jQuery-Impromptu": "trentrichardson/jQuery-Impromptu#v6.0.0",
30
     "jquery-ui": "1.10.5",
30
     "jquery-ui": "1.10.5",
31
     "jssha": "1.5.0",
31
     "jssha": "1.5.0",
32
     "jws": "*",
32
     "jws": "*",
35
     "react": "15.4.2",
35
     "react": "15.4.2",
36
     "react-dom": "15.4.2",
36
     "react-dom": "15.4.2",
37
     "react-native": "0.41.2",
37
     "react-native": "0.41.2",
38
+    "react-native-immersive": "0.0.4",
38
     "react-native-keep-awake": "^2.0.2",
39
     "react-native-keep-awake": "^2.0.2",
39
     "react-native-prompt": "^1.0.0",
40
     "react-native-prompt": "^1.0.0",
40
     "react-native-vector-icons": "^4.0.0",
41
     "react-native-vector-icons": "^4.0.0",

+ 1
- 0
react/features/app/components/App.native.js View File

4
 
4
 
5
 import { Platform } from '../../base/react';
5
 import { Platform } from '../../base/react';
6
 import '../../audio-mode';
6
 import '../../audio-mode';
7
+import '../../full-screen';
7
 import '../../wake-lock';
8
 import '../../wake-lock';
8
 
9
 
9
 import { AbstractApp } from './AbstractApp';
10
 import { AbstractApp } from './AbstractApp';

+ 1
- 0
react/features/full-screen/index.js View File

1
+import './middleware';

+ 76
- 0
react/features/full-screen/middleware.js View File

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
+}

Loading…
Cancel
Save