瀏覽代碼

[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 年之前
父節點
當前提交
7a8c84e990

+ 1
- 0
android/app/build.gradle 查看文件

@@ -139,6 +139,7 @@ if (project.hasProperty('JITSI_SIGNING')
139 139
 }
140 140
 
141 141
 dependencies {
142
+    compile project(':react-native-immersive')
142 143
     compile project(':react-native-keep-awake')
143 144
     compile project(':react-native-vector-icons')
144 145
     compile project(':react-native-webrtc')

+ 1
- 0
android/app/src/main/java/org/jitsi/meet/MainApplication.java 查看文件

@@ -30,6 +30,7 @@ public class MainApplication extends Application implements ReactApplication {
30 30
                 new com.facebook.react.shell.MainReactPackage(),
31 31
                 new com.oblador.vectoricons.VectorIconsPackage(),
32 32
                 new com.oney.WebRTCModule.WebRTCModulePackage(),
33
+                new com.rnimmersive.RNImmersivePackage(),
33 34
                 new org.jitsi.meet.audiomode.AudioModePackage()
34 35
             );
35 36
         }

+ 2
- 0
android/settings.gradle 查看文件

@@ -1,4 +1,6 @@
1 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 5
 include ':app'
4 6
 include ':react-native-keep-awake'

+ 2
- 1
package.json 查看文件

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

+ 1
- 0
react/features/app/components/App.native.js 查看文件

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

+ 1
- 0
react/features/full-screen/index.js 查看文件

@@ -0,0 +1 @@
1
+import './middleware';

+ 76
- 0
react/features/full-screen/middleware.js 查看文件

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

Loading…
取消
儲存