Browse Source

Coding style: consistency, formatting, naming

master
Lyubo Marinov 7 years ago
parent
commit
6a0de0ddde

+ 15
- 13
android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java View File

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
      * @param view the {@link JitsiMeetView} instance.
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
         switch(eventName) {
127
         switch(eventName) {
127
         case "CONFERENCE_WILL_JOIN":
128
         case "CONFERENCE_WILL_JOIN":
128
-            view.setCurrentConferenceUrl(url);
129
+            view.setURL(eventData.getString("url"));
129
             break;
130
             break;
130
 
131
 
131
         case "CONFERENCE_FAILED":
132
         case "CONFERENCE_FAILED":
132
         case "CONFERENCE_WILL_LEAVE":
133
         case "CONFERENCE_WILL_LEAVE":
133
         case "LOAD_CONFIG_ERROR":
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
             break;
140
             break;
139
         }
141
         }
158
             return;
160
             return;
159
         }
161
         }
160
 
162
 
161
-        maybeSetConferenceUrlOnTheView(name, view, data.getString("url"));
163
+        maybeSetViewURL(name, data, view);
162
 
164
 
163
         JitsiMeetViewListener listener = view.getListener();
165
         JitsiMeetViewListener listener = view.getListener();
164
 
166
 

+ 36
- 34
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java View File

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
      * The default base {@code URL} used to join a conference when a partial URL
208
      * The default base {@code URL} used to join a conference when a partial URL
218
      * (e.g. a room name only) is specified to {@link #loadURLString(String)} or
209
      * (e.g. a room name only) is specified to {@link #loadURLString(String)} or
252
      */
243
      */
253
     private ReactRootView reactRootView;
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
      * Whether the Welcome page is enabled.
254
      * Whether the Welcome page is enabled.
257
      */
255
      */
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
      * Gets the default base {@code URL} used to join a conference when a
293
      * Gets the default base {@code URL} used to join a conference when a
306
      * partial URL (e.g. a room name only) is specified to
294
      * partial URL (e.g. a room name only) is specified to
352
                     || pictureInPictureEnabled.booleanValue());
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
      * Gets whether the Welcome page is enabled. If {@code true}, the Welcome
357
      * Gets whether the Welcome page is enabled. If {@code true}, the Welcome
357
      * page is rendered when this {@code JitsiMeetView} is not at a URL
358
      * page is rendered when this {@code JitsiMeetView} is not at a URL
477
      * page.
478
      * page.
478
      */
479
      */
479
     public void onUserLeaveHint() {
480
     public void onUserLeaveHint() {
480
-        if (getPictureInPictureEnabled() && conferenceUrl != null) {
481
+        if (getPictureInPictureEnabled() && getURL() != null) {
481
             PictureInPictureModule pipModule
482
             PictureInPictureModule pipModule
482
                 = ReactInstanceManagerHolder.getNativeModule(
483
                 = ReactInstanceManagerHolder.getNativeModule(
483
                         PictureInPictureModule.class);
484
                         PictureInPictureModule.class);
485
             if (pipModule != null) {
486
             if (pipModule != null) {
486
                 try {
487
                 try {
487
                     pipModule.enterPictureInPicture();
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
         }
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
      * Sets the default base {@code URL} used to join a conference when a
534
      * Sets the default base {@code URL} used to join a conference when a
546
      * partial URL (e.g. a room name only) is specified to
535
      * partial URL (e.g. a room name only) is specified to
577
         this.pictureInPictureEnabled = Boolean.valueOf(pictureInPictureEnabled);
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
      * Sets whether the Welcome page is enabled. Must be called before
583
      * Sets whether the Welcome page is enabled. Must be called before
582
      * {@link #loadURL(URL)} for it to take effect.
584
      * {@link #loadURL(URL)} for it to take effect.

+ 35
- 35
react/features/welcome/components/VideoSwitch.js View File

1
 // @flow
1
 // @flow
2
+
2
 import React, { Component } from 'react';
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
 import { connect } from 'react-redux';
5
 import { connect } from 'react-redux';
9
 
6
 
10
 import { translate } from '../../base/i18n';
7
 import { translate } from '../../base/i18n';
11
 import { updateProfile } from '../../base/profile';
8
 import { updateProfile } from '../../base/profile';
12
 import { Header, Text } from '../../base/react';
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
 type Props = {
16
 type Props = {
20
 
17
 
21
     /**
18
     /**
22
-     * The Redux dispatch functions.
19
+     * The redux {@code dispatch} function.
23
      */
20
      */
24
     dispatch: Function,
21
     dispatch: Function,
25
 
22
 
29
     t: Function,
26
     t: Function,
30
 
27
 
31
     /**
28
     /**
32
-     * The current profile settings from Redux.
29
+     * The current profile settings from redux.
33
      */
30
      */
34
     _profile: Object
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
 class VideoSwitch extends Component<Props> {
37
 class VideoSwitch extends Component<Props> {
41
     /**
38
     /**
42
-     * Constructor of the component.
39
+     * Initializes a new {@code VideoSwitch} instance.
43
      *
40
      *
44
      * @inheritdoc
41
      * @inheritdoc
45
      */
42
      */
46
     constructor(props) {
43
     constructor(props) {
47
         super(props);
44
         super(props);
48
 
45
 
46
+        // Bind event handlers so they are only bound once per instance.
49
         this._onStartAudioOnlyChange = this._onStartAudioOnlyChange.bind(this);
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
      * @inheritdoc
55
      * @inheritdoc
56
      */
56
      */
61
         return (
61
         return (
62
             <View style = { styles.audioVideoSwitchContainer }>
62
             <View style = { styles.audioVideoSwitchContainer }>
63
                 <TouchableWithoutFeedback
63
                 <TouchableWithoutFeedback
64
-                    onPress = {
65
-                        this._onStartAudioOnlyChangeFn(false)
66
-                    } >
67
-                    <Text style = { textStyle } >
64
+                    onPress = { this._onStartAudioOnlyFalse }>
65
+                    <Text style = { textStyle }>
68
                         { t('welcomepage.audioVideoSwitch.video') }
66
                         { t('welcomepage.audioVideoSwitch.video') }
69
                     </Text>
67
                     </Text>
70
                 </TouchableWithoutFeedback>
68
                 </TouchableWithoutFeedback>
75
                     thumbTintColor = { SWITCH_THUMB_COLOR }
73
                     thumbTintColor = { SWITCH_THUMB_COLOR }
76
                     value = { _profile.startAudioOnly } />
74
                     value = { _profile.startAudioOnly } />
77
                 <TouchableWithoutFeedback
75
                 <TouchableWithoutFeedback
78
-                    onPress = {
79
-                        this._onStartAudioOnlyChangeFn(true)
80
-                    } >
81
-                    <Text style = { textStyle } >
76
+                    onPress = { this._onStartAudioOnlyTrue }>
77
+                    <Text style = { textStyle }>
82
                         { t('welcomepage.audioVideoSwitch.audio') }
78
                         { t('welcomepage.audioVideoSwitch.audio') }
83
                     </Text>
79
                     </Text>
84
                 </TouchableWithoutFeedback>
80
                 </TouchableWithoutFeedback>
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
      * Handles the audio-video switch changes.
88
      * Handles the audio-video switch changes.
115
             startAudioOnly
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 View File

13
 import { translate } from '../../base/i18n';
13
 import { translate } from '../../base/i18n';
14
 import { Icon } from '../../base/font-icons';
14
 import { Icon } from '../../base/font-icons';
15
 import { MEDIA_TYPE } from '../../base/media';
15
 import { MEDIA_TYPE } from '../../base/media';
16
-import { LoadingIndicator, Header, Text } from '../../base/react';
16
+import { Header, LoadingIndicator, Text } from '../../base/react';
17
 import { ColorPalette } from '../../base/styles';
17
 import { ColorPalette } from '../../base/styles';
18
 import {
18
 import {
19
     createDesiredLocalTracks,
19
     createDesiredLocalTracks,
24
 import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
24
 import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
25
 import { setSideBarVisible } from '../actions';
25
 import { setSideBarVisible } from '../actions';
26
 import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
26
 import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
27
-import styles, {
28
-    PLACEHOLDER_TEXT_COLOR
29
-} from './styles';
27
+import styles, { PLACEHOLDER_TEXT_COLOR } from './styles';
30
 import VideoSwitch from './VideoSwitch';
28
 import VideoSwitch from './VideoSwitch';
31
 import WelcomePageLists from './WelcomePageLists';
29
 import WelcomePageLists from './WelcomePageLists';
32
 import WelcomePageSideBar from './WelcomePageSideBar';
30
 import WelcomePageSideBar from './WelcomePageSideBar';
155
      */
153
      */
156
     _onFieldFocusChange(focused) {
154
     _onFieldFocusChange(focused) {
157
         return () => {
155
         return () => {
158
-            if (focused) {
159
-                this.setState({
156
+            focused
157
+                && this.setState({
160
                     _fieldFocused: true
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
                     buttonDisabled ? styles.buttonDisabled : null
255
                     buttonDisabled ? styles.buttonDisabled : null
257
                 ] }
256
                 ] }
258
                 underlayColor = { ColorPalette.white }>
257
                 underlayColor = { ColorPalette.white }>
259
-                {
260
-                    children
261
-                }
258
+                { children }
262
             </TouchableHighlight>
259
             </TouchableHighlight>
263
         );
260
         );
264
     }
261
     }

+ 7
- 6
react/features/welcome/components/styles.js View File

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
 export const PLACEHOLDER_TEXT_COLOR = 'rgba(255, 255, 255, 0.3)';
5
 export const PLACEHOLDER_TEXT_COLOR = 'rgba(255, 255, 255, 0.3)';
6
+
10
 export const SIDEBAR_AVATAR_SIZE = 100;
7
 export const SIDEBAR_AVATAR_SIZE = 100;
8
+
9
+const SIDEBAR_HEADER_HEIGHT = 150;
10
+
11
 export const SWITCH_THUMB_COLOR = ColorPalette.blueHighlight;
11
 export const SWITCH_THUMB_COLOR = ColorPalette.blueHighlight;
12
+
12
 export const SWITCH_UNDER_COLOR = 'rgba(0, 0, 0, 0.4)';
13
 export const SWITCH_UNDER_COLOR = 'rgba(0, 0, 0, 0.4)';
13
 
14
 
14
 /**
15
 /**

Loading…
Cancel
Save