浏览代码

Comply w/ coding style

- Use 1 name for 1 abstraction. Instead of useFullScreen and enabled use
  fullScreen.
- Comments are correct English sentences so no double spaces between
  senteces, no capitalization of the work On midsentence.
- Write as little source code as possible if readability is preserved.
- Utilize Facebook's Flow.
- The name of a private function must start with _ and the jsdoc should
  state that the function is private.
j8
Lyubomir Marinov 8 年前
父节点
当前提交
2ad869a036
共有 4 个文件被更改,包括 30 次插入26 次删除
  1. 2
    2
      android/settings.gradle
  2. 1
    1
      package.json
  3. 5
    1
      react/features/audio-mode/middleware.js
  4. 22
    22
      react/features/full-screen/middleware.js

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

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')
4
 
2
 
5
 include ':app'
3
 include ':app'
4
+include ':react-native-immersive'
5
+project(':react-native-immersive').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immersive/android')
6
 include ':react-native-keep-awake'
6
 include ':react-native-keep-awake'
7
 project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-awake/android')
7
 project(':react-native-keep-awake').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keep-awake/android')
8
 include ':react-native-vector-icons'
8
 include ':react-native-vector-icons'

+ 1
- 1
package.json 查看文件

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",
26
     "jitsi-meet-logger": "jitsi/jitsi-meet-logger",
25
     "jitsi-meet-logger": "jitsi/jitsi-meet-logger",
27
     "jquery": "~2.1.1",
26
     "jquery": "~2.1.1",
28
     "jquery-contextmenu": "*",
27
     "jquery-contextmenu": "*",
29
     "jquery-i18next": "1.1.0",
28
     "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": "*",

+ 5
- 1
react/features/audio-mode/middleware.js 查看文件

1
+/* @flow */
2
+
1
 import { NativeModules } from 'react-native';
3
 import { NativeModules } from 'react-native';
2
 
4
 
3
 import { APP_WILL_MOUNT } from '../app';
5
 import { APP_WILL_MOUNT } from '../app';
49
         if (mode !== null) {
51
         if (mode !== null) {
50
             AudioMode.setMode(mode)
52
             AudioMode.setMode(mode)
51
                 .catch(err =>
53
                 .catch(err =>
52
-                    console.error(`Failed to set audio mode ${mode}: ${err}`));
54
+                    console.error(
55
+                            `Failed to set audio mode ${String(mode)}: `
56
+                                + `${err}`));
53
         }
57
         }
54
     }
58
     }
55
 
59
 

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

1
+/* @flow */
2
+
1
 import { StatusBar } from 'react-native';
3
 import { StatusBar } from 'react-native';
2
 import { Immersive } from 'react-native-immersive';
4
 import { Immersive } from 'react-native-immersive';
3
 
5
 
11
 
13
 
12
 /**
14
 /**
13
  * Middleware that captures conference actions and activates or deactivates the
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
  * immersive mode:
17
  * immersive mode:
16
  * https://developer.android.com/training/system-ui/immersive.html
18
  * https://developer.android.com/training/system-ui/immersive.html
17
  * In immersive mode the status and navigation bars are hidden and thus the
19
  * In immersive mode the status and navigation bars are hidden and thus the
21
  * @returns {Function}
23
  * @returns {Function}
22
  */
24
  */
23
 MiddlewareRegistry.register(store => next => action => {
25
 MiddlewareRegistry.register(store => next => action => {
24
-    let useFullScreen;
26
+    let fullScreen;
25
 
27
 
26
     switch (action.type) {
28
     switch (action.type) {
27
     case CONFERENCE_WILL_JOIN: {
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
         break;
33
         break;
32
     }
34
     }
33
 
35
 
34
     case CONFERENCE_FAILED:
36
     case CONFERENCE_FAILED:
35
     case CONFERENCE_LEFT:
37
     case CONFERENCE_LEFT:
36
-        useFullScreen = false;
38
+        fullScreen = false;
37
         break;
39
         break;
38
 
40
 
39
     default:
41
     default:
40
-        useFullScreen = null;
42
+        fullScreen = null;
41
         break;
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
     return next(action);
52
     return next(action);
53
 
54
 
54
 /**
55
 /**
55
  * Activates/deactivates the full screen mode. On iOS it will hide the status
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
  * deactivate it.
60
  * deactivate it.
61
+ * @private
60
  * @returns {Promise}
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
     if (Platform.OS === 'android') {
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
     return Promise.resolve();
75
     return Promise.resolve();
76
 }
76
 }

正在加载...
取消
保存