Переглянути джерело

Coding style: consistency, formatting, naming

master
Lyubo Marinov 7 роки тому
джерело
коміт
6a0de0ddde

+ 15
- 13
android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java Переглянути файл

@@ -112,28 +112,30 @@ class ExternalAPIModule extends ReactContextBaseJavaModule {
112 112
     }
113 113
 
114 114
     /**
115
-     * The internal processing for the conference URL set on
116
-     * a {@link JitsiMeetView} instance.
115
+     * The internal processing for the URL of the current conference set on the
116
+     * associated {@link JitsiMeetView}.
117 117
      *
118
-     * @param eventName the name of the external API event to be processed.
118
+     * @param eventName the name of the external API event to be processed
119
+     * @param eventData the details/specifics of the event to process determined
120
+     * by/associated with the specified {@code eventName}.
119 121
      * @param view the {@link JitsiMeetView} instance.
120
-     * @param url the "url" attribute value retrieved from the "data" carried by
121
-     * the event.
122 122
      */
123
-    private void maybeSetConferenceUrlOnTheView(
124
-            String eventName, JitsiMeetView view, String url)
125
-    {
123
+    private void maybeSetViewURL(
124
+            String eventName,
125
+            ReadableMap eventData,
126
+            JitsiMeetView view) {
126 127
         switch(eventName) {
127 128
         case "CONFERENCE_WILL_JOIN":
128
-            view.setCurrentConferenceUrl(url);
129
+            view.setURL(eventData.getString("url"));
129 130
             break;
130 131
 
131 132
         case "CONFERENCE_FAILED":
132 133
         case "CONFERENCE_WILL_LEAVE":
133 134
         case "LOAD_CONFIG_ERROR":
134
-            // Abandon the conference only if it's for the current URL
135
-            if (url != null && url.equals(view.getCurrentConferenceUrl())) {
136
-                view.setCurrentConferenceUrl(null);
135
+            String url = eventData.getString("url");
136
+
137
+            if (url != null && url.equals(view.getURL())) {
138
+                view.setURL(null);
137 139
             }
138 140
             break;
139 141
         }
@@ -158,7 +160,7 @@ class ExternalAPIModule extends ReactContextBaseJavaModule {
158 160
             return;
159 161
         }
160 162
 
161
-        maybeSetConferenceUrlOnTheView(name, view, data.getString("url"));
163
+        maybeSetViewURL(name, data, view);
162 164
 
163 165
         JitsiMeetViewListener listener = view.getListener();
164 166
 

+ 36
- 34
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java Переглянути файл

@@ -204,15 +204,6 @@ public class JitsiMeetView extends FrameLayout {
204 204
         }
205 205
     }
206 206
 
207
-    /**
208
-     * Stores the current conference URL. Will have a value when the app is in
209
-     * a conference.
210
-     *
211
-     * Currently one thread writes and one thread reads, so it should be fine to
212
-     * have this field volatile without additional synchronization.
213
-     */
214
-    private volatile String conferenceUrl;
215
-
216 207
     /**
217 208
      * The default base {@code URL} used to join a conference when a partial URL
218 209
      * (e.g. a room name only) is specified to {@link #loadURLString(String)} or
@@ -252,6 +243,13 @@ public class JitsiMeetView extends FrameLayout {
252 243
      */
253 244
     private ReactRootView reactRootView;
254 245
 
246
+    /**
247
+     * The URL of the current conference.
248
+     */
249
+    // XXX Currently, one thread writes and one thread reads, so it should be
250
+    // fine to have this field volatile without additional synchronization.
251
+    private volatile String url;
252
+
255 253
     /**
256 254
      * Whether the Welcome page is enabled.
257 255
      */
@@ -291,16 +289,6 @@ public class JitsiMeetView extends FrameLayout {
291 289
         }
292 290
     }
293 291
 
294
-    /**
295
-     * Retrieves the current conferences URL.
296
-     *
297
-     * @return a string with conference URL if the view is currently in
298
-     * a conference or {@code null} otherwise.
299
-     */
300
-    public String getCurrentConferenceUrl() {
301
-        return conferenceUrl;
302
-    }
303
-
304 292
     /**
305 293
      * Gets the default base {@code URL} used to join a conference when a
306 294
      * partial URL (e.g. a room name only) is specified to
@@ -352,6 +340,19 @@ public class JitsiMeetView extends FrameLayout {
352 340
                     || pictureInPictureEnabled.booleanValue());
353 341
     }
354 342
 
343
+    /**
344
+     * Gets the URL of the current conference.
345
+     *
346
+     * XXX The method is meant for internal purposes only at the time of this
347
+     * writing because there is no equivalent API on iOS.
348
+     *
349
+     * @return the URL {@code String} of the current conference if any;
350
+     * otherwise, {@code null}.
351
+     */
352
+    String getURL() {
353
+        return url;
354
+    }
355
+
355 356
     /**
356 357
      * Gets whether the Welcome page is enabled. If {@code true}, the Welcome
357 358
      * page is rendered when this {@code JitsiMeetView} is not at a URL
@@ -477,7 +478,7 @@ public class JitsiMeetView extends FrameLayout {
477 478
      * page.
478 479
      */
479 480
     public void onUserLeaveHint() {
480
-        if (getPictureInPictureEnabled() && conferenceUrl != null) {
481
+        if (getPictureInPictureEnabled() && getURL() != null) {
481 482
             PictureInPictureModule pipModule
482 483
                 = ReactInstanceManagerHolder.getNativeModule(
483 484
                         PictureInPictureModule.class);
@@ -485,9 +486,8 @@ public class JitsiMeetView extends FrameLayout {
485 486
             if (pipModule != null) {
486 487
                 try {
487 488
                     pipModule.enterPictureInPicture();
488
-                } catch (RuntimeException exc) {
489
-                    Log.e(
490
-                        TAG, "onUserLeaveHint: failed to enter PiP mode", exc);
489
+                } catch (RuntimeException re) {
490
+                    Log.e(TAG, "onUserLeaveHint: failed to enter PiP mode", re);
491 491
                 }
492 492
             }
493 493
         }
@@ -530,17 +530,6 @@ public class JitsiMeetView extends FrameLayout {
530 530
         }
531 531
     }
532 532
 
533
-    /**
534
-     * Sets the current conference URL.
535
-     *
536
-     * @param conferenceUrl a string with new conference URL to set if the view
537
-     * is entering the conference or {@code null} if the view is no longer in
538
-     * the conference.
539
-     */
540
-    void setCurrentConferenceUrl(String conferenceUrl) {
541
-        this.conferenceUrl = conferenceUrl;
542
-    }
543
-
544 533
     /**
545 534
      * Sets the default base {@code URL} used to join a conference when a
546 535
      * partial URL (e.g. a room name only) is specified to
@@ -577,6 +566,19 @@ public class JitsiMeetView extends FrameLayout {
577 566
         this.pictureInPictureEnabled = Boolean.valueOf(pictureInPictureEnabled);
578 567
     }
579 568
 
569
+    /**
570
+     * Sets the URL of the current conference.
571
+     *
572
+     * XXX The method is meant for internal purposes only. It does not
573
+     * {@code loadURL}, it merely remembers the specified URL.
574
+     *
575
+     * @param url the URL {@code String} which to be set as the URL of the
576
+     * current conference.
577
+     */
578
+    void setURL(String url) {
579
+        this.url = url;
580
+    }
581
+
580 582
     /**
581 583
      * Sets whether the Welcome page is enabled. Must be called before
582 584
      * {@link #loadURL(URL)} for it to take effect.

+ 35
- 35
react/features/welcome/components/VideoSwitch.js Переглянути файл

@@ -1,25 +1,22 @@
1 1
 // @flow
2
+
2 3
 import React, { Component } from 'react';
3
-import {
4
-    Switch,
5
-    TouchableWithoutFeedback,
6
-    View
7
-} from 'react-native';
4
+import { Switch, TouchableWithoutFeedback, View } from 'react-native';
8 5
 import { connect } from 'react-redux';
9 6
 
10 7
 import { translate } from '../../base/i18n';
11 8
 import { updateProfile } from '../../base/profile';
12 9
 import { Header, Text } from '../../base/react';
13 10
 
14
-import styles, {
15
-    SWITCH_THUMB_COLOR,
16
-    SWITCH_UNDER_COLOR
17
-} from './styles';
11
+import styles, { SWITCH_THUMB_COLOR, SWITCH_UNDER_COLOR } from './styles';
18 12
 
13
+/**
14
+ * The type of the React {@code Component} props of {@link VideoSwitch}.
15
+ */
19 16
 type Props = {
20 17
 
21 18
     /**
22
-     * The Redux dispatch functions.
19
+     * The redux {@code dispatch} function.
23 20
      */
24 21
     dispatch: Function,
25 22
 
@@ -29,28 +26,31 @@ type Props = {
29 26
     t: Function,
30 27
 
31 28
     /**
32
-     * The current profile settings from Redux.
29
+     * The current profile settings from redux.
33 30
      */
34 31
     _profile: Object
35 32
 };
36 33
 
37 34
 /**
38
- * Renders the audio-video switch on the welcome screen.
35
+ * Renders the "Video <-> Voice" switch on the {@code WelcomePage}.
39 36
  */
40 37
 class VideoSwitch extends Component<Props> {
41 38
     /**
42
-     * Constructor of the component.
39
+     * Initializes a new {@code VideoSwitch} instance.
43 40
      *
44 41
      * @inheritdoc
45 42
      */
46 43
     constructor(props) {
47 44
         super(props);
48 45
 
46
+        // Bind event handlers so they are only bound once per instance.
49 47
         this._onStartAudioOnlyChange = this._onStartAudioOnlyChange.bind(this);
48
+        this._onStartAudioOnlyFalse = this._onStartAudioOnlyChangeFn(false);
49
+        this._onStartAudioOnlyTrue = this._onStartAudioOnlyChangeFn(true);
50 50
     }
51 51
 
52 52
     /**
53
-     * Implements React Component's render.
53
+     * Implements React's {@link Component#render}.
54 54
      *
55 55
      * @inheritdoc
56 56
      */
@@ -61,10 +61,8 @@ class VideoSwitch extends Component<Props> {
61 61
         return (
62 62
             <View style = { styles.audioVideoSwitchContainer }>
63 63
                 <TouchableWithoutFeedback
64
-                    onPress = {
65
-                        this._onStartAudioOnlyChangeFn(false)
66
-                    } >
67
-                    <Text style = { textStyle } >
64
+                    onPress = { this._onStartAudioOnlyFalse }>
65
+                    <Text style = { textStyle }>
68 66
                         { t('welcomepage.audioVideoSwitch.video') }
69 67
                     </Text>
70 68
                 </TouchableWithoutFeedback>
@@ -75,10 +73,8 @@ class VideoSwitch extends Component<Props> {
75 73
                     thumbTintColor = { SWITCH_THUMB_COLOR }
76 74
                     value = { _profile.startAudioOnly } />
77 75
                 <TouchableWithoutFeedback
78
-                    onPress = {
79
-                        this._onStartAudioOnlyChangeFn(true)
80
-                    } >
81
-                    <Text style = { textStyle } >
76
+                    onPress = { this._onStartAudioOnlyTrue }>
77
+                    <Text style = { textStyle }>
82 78
                         { t('welcomepage.audioVideoSwitch.audio') }
83 79
                     </Text>
84 80
                 </TouchableWithoutFeedback>
@@ -86,19 +82,7 @@ class VideoSwitch extends Component<Props> {
86 82
         );
87 83
     }
88 84
 
89
-    /**
90
-     * Creates a function that forwards the startAudioOnly changes to the
91
-     * function that handles it.
92
-     *
93
-     * @private
94
-     * @param {boolean} startAudioOnly - The new startAudioOnly value.
95
-     * @returns {void}
96
-     */
97
-    _onStartAudioOnlyChangeFn(startAudioOnly) {
98
-        return () => this._onStartAudioOnlyChange(startAudioOnly);
99
-    }
100
-
101
-    _onStartAudioOnlyChange: boolean => void
85
+    _onStartAudioOnlyChange: boolean => void;
102 86
 
103 87
     /**
104 88
      * Handles the audio-video switch changes.
@@ -115,6 +99,22 @@ class VideoSwitch extends Component<Props> {
115 99
             startAudioOnly
116 100
         }));
117 101
     }
102
+
103
+    /**
104
+     * Creates a function that forwards the {@code startAudioOnly} changes to
105
+     * the function that handles it.
106
+     *
107
+     * @private
108
+     * @param {boolean} startAudioOnly - The new {@code startAudioOnly} value.
109
+     * @returns {void}
110
+     */
111
+    _onStartAudioOnlyChangeFn(startAudioOnly) {
112
+        return () => this._onStartAudioOnlyChange(startAudioOnly);
113
+    }
114
+
115
+    _onStartAudioOnlyFalse: boolean => void;
116
+
117
+    _onStartAudioOnlyTrue: boolean => void;
118 118
 }
119 119
 
120 120
 /**

+ 17
- 20
react/features/welcome/components/WelcomePage.native.js Переглянути файл

@@ -13,7 +13,7 @@ import { connect } from 'react-redux';
13 13
 import { translate } from '../../base/i18n';
14 14
 import { Icon } from '../../base/font-icons';
15 15
 import { MEDIA_TYPE } from '../../base/media';
16
-import { LoadingIndicator, Header, Text } from '../../base/react';
16
+import { Header, LoadingIndicator, Text } from '../../base/react';
17 17
 import { ColorPalette } from '../../base/styles';
18 18
 import {
19 19
     createDesiredLocalTracks,
@@ -24,9 +24,7 @@ import { SettingsView } from '../../settings';
24 24
 import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
25 25
 import { setSideBarVisible } from '../actions';
26 26
 import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
27
-import styles, {
28
-    PLACEHOLDER_TEXT_COLOR
29
-} from './styles';
27
+import styles, { PLACEHOLDER_TEXT_COLOR } from './styles';
30 28
 import VideoSwitch from './VideoSwitch';
31 29
 import WelcomePageLists from './WelcomePageLists';
32 30
 import WelcomePageSideBar from './WelcomePageSideBar';
@@ -155,22 +153,23 @@ class WelcomePage extends AbstractWelcomePage {
155 153
      */
156 154
     _onFieldFocusChange(focused) {
157 155
         return () => {
158
-            if (focused) {
159
-                this.setState({
156
+            focused
157
+                && this.setState({
160 158
                     _fieldFocused: true
161 159
                 });
162
-            }
163 160
 
164
-            Animated.timing(this.state.hintBoxAnimation, {
165
-                duration: 300,
166
-                toValue: focused ? 1 : 0
167
-            }).start(animationState => {
168
-                if (animationState.finished && !focused) {
169
-                    this.setState({
170
-                        _fieldFocused: false
171
-                    });
172
-                }
173
-            });
161
+            Animated.timing(
162
+                this.state.hintBoxAnimation,
163
+                {
164
+                    duration: 300,
165
+                    toValue: focused ? 1 : 0
166
+                })
167
+                .start(animationState =>
168
+                    animationState.finished
169
+                        && !focused
170
+                        && this.setState({
171
+                            _fieldFocused: false
172
+                        }));
174 173
         };
175 174
     }
176 175
 
@@ -256,9 +255,7 @@ class WelcomePage extends AbstractWelcomePage {
256 255
                     buttonDisabled ? styles.buttonDisabled : null
257 256
                 ] }
258 257
                 underlayColor = { ColorPalette.white }>
259
-                {
260
-                    children
261
-                }
258
+                { children }
262 259
             </TouchableHighlight>
263 260
         );
264 261
     }

+ 7
- 6
react/features/welcome/components/styles.js Переглянути файл

@@ -1,14 +1,15 @@
1
-import {
2
-    BoxModel,
3
-    ColorPalette,
4
-    createStyleSheet
5
-} from '../../base/styles';
1
+// @flow
6 2
 
7
-const SIDEBAR_HEADER_HEIGHT = 150;
3
+import { BoxModel, ColorPalette, createStyleSheet } from '../../base/styles';
8 4
 
9 5
 export const PLACEHOLDER_TEXT_COLOR = 'rgba(255, 255, 255, 0.3)';
6
+
10 7
 export const SIDEBAR_AVATAR_SIZE = 100;
8
+
9
+const SIDEBAR_HEADER_HEIGHT = 150;
10
+
11 11
 export const SWITCH_THUMB_COLOR = ColorPalette.blueHighlight;
12
+
12 13
 export const SWITCH_UNDER_COLOR = 'rgba(0, 0, 0, 0.4)';
13 14
 
14 15
 /**

Завантаження…
Відмінити
Зберегти