瀏覽代碼

[RN] Add ability to skip the welcome page

Also expose this in the native SDKs.
j8
Saúl Ibarra Corretgé 8 年之前
父節點
當前提交
4687c1f465

+ 19
- 0
android/README.md 查看文件

85
 This class encapsulates a high level API in the form of an Android `Activity`
85
 This class encapsulates a high level API in the form of an Android `Activity`
86
 which displays a single `JitsiMeetView`.
86
 which displays a single `JitsiMeetView`.
87
 
87
 
88
+#### getWelcomePageDisabled()
89
+
90
+See JitsiMeetView.getWelcomePageDisabled.
91
+
88
 #### loadURL(url)
92
 #### loadURL(url)
89
 
93
 
90
 See JitsiMeetView.loadURL.
94
 See JitsiMeetView.loadURL.
91
 
95
 
96
+#### setWelcomePageDisabled(disabled)
97
+
98
+See JitsiMeetView.setWelcomePageDisabled.
92
 
99
 
93
 ### JitsiMeetView
100
 ### JitsiMeetView
94
 
101
 
99
 
106
 
100
 Returns the `JitsiMeetViewListener` instance attached to the view.
107
 Returns the `JitsiMeetViewListener` instance attached to the view.
101
 
108
 
109
+#### getWelcomePageDisabled()
110
+
111
+Returns true if the welcome page is disable,d false if not. If the welcome page
112
+is disabled, a black empty view will be rendered when not in a conference.
113
+
102
 #### loadURL(url)
114
 #### loadURL(url)
103
 
115
 
104
 Loads the given URL and joins the room. If `null` is specified, the welcome page
116
 Loads the given URL and joins the room. If `null` is specified, the welcome page
109
 Sets the given listener (class implementing the `JitsiMeetViewListener`
121
 Sets the given listener (class implementing the `JitsiMeetViewListener`
110
 interface) on the view.
122
 interface) on the view.
111
 
123
 
124
+#### setWelcomePageDisabled(disabled)
125
+
126
+Sets if the welcome page should be disabled or not. See `getWelcomePageDisabled`
127
+for more info.
128
+
129
+NOTE: This function must be called before `loadURL` for it to take effect.
130
+
112
 #### onBackPressed()
131
 #### onBackPressed()
113
 
132
 
114
 Helper method which should be called from the activity's `onBackPressed` method.
133
 Helper method which should be called from the activity's `onBackPressed` method.

+ 16
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java 查看文件

50
      */
50
      */
51
     private JitsiMeetView view;
51
     private JitsiMeetView view;
52
 
52
 
53
+    /**
54
+     * See {@JitsiMeetView.getWelcomePageDisabled}.
55
+     */
56
+    public boolean getWelcomePageDisabled() {
57
+        return view != null && view.getWelcomePageDisabled();
58
+    }
59
+
53
     /**
60
     /**
54
      * Loads the given URL and displays the conference. If the specified URL is
61
      * Loads the given URL and displays the conference. If the specified URL is
55
      * null, the welcome page is displayed instead.
62
      * null, the welcome page is displayed instead.
60
         view.loadURL(url);
67
         view.loadURL(url);
61
     }
68
     }
62
 
69
 
70
+    /**
71
+     * See {@JitsiMeetView.setWelcomePageDisabled}.
72
+     */
73
+    public void setWelcomePageDisabled(boolean disabled) {
74
+        if (view != null) {
75
+            view.setWelcomePageDisabled(disabled);
76
+        }
77
+    }
78
+
63
     /**
79
     /**
64
      * {@inheritDoc}
80
      * {@inheritDoc}
65
      */
81
      */

+ 24
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java 查看文件

58
      */
58
      */
59
     private JitsiMeetViewListener listener;
59
     private JitsiMeetViewListener listener;
60
 
60
 
61
+    /**
62
+     * Indicates if the welcome page should be disabled or not.
63
+     */
64
+    private boolean welcomePageDisabled;
65
+
61
     /**
66
     /**
62
      * React Native root view.
67
      * React Native root view.
63
      */
68
      */
105
         return listener;
110
         return listener;
106
     }
111
     }
107
 
112
 
113
+    /**
114
+     * @return - true if the welcome page is disabled, false if not.
115
+     */
116
+    public boolean getWelcomePageDisabled() {
117
+        return welcomePageDisabled;
118
+    }
119
+
108
     /**
120
     /**
109
      * Internal method to initialize the React Native instance manager. We
121
      * Internal method to initialize the React Native instance manager. We
110
      * create a single instance in order to load the JavaScript bundle a single
122
      * create a single instance in order to load the JavaScript bundle a single
145
             props.putString("url", url.toString());
157
             props.putString("url", url.toString());
146
         }
158
         }
147
 
159
 
160
+        props.putBoolean("disableWelcomePage", welcomePageDisabled);
161
+
148
         // TODO: ReactRootView#setAppProperties is only available on React
162
         // TODO: ReactRootView#setAppProperties is only available on React
149
         // Native 0.45, so destroy the current root view and create a new one.
163
         // Native 0.45, so destroy the current root view and create a new one.
150
         if (reactRootView != null) {
164
         if (reactRootView != null) {
170
         this.listener = listener;
184
         this.listener = listener;
171
     }
185
     }
172
 
186
 
187
+    /**
188
+     * Sets if the welcome page should be enabled or not. Must be called before calling loadURL or
189
+     * it won't take effect.
190
+     *
191
+     * @param disabled - set to true for disabling the welcome page, false not to do so.
192
+     */
193
+    public void setWelcomePageDisabled(boolean disabled) {
194
+        welcomePageDisabled = disabled;
195
+    }
196
+
173
     /**
197
     /**
174
      * Activity lifecycle method which should be called from
198
      * Activity lifecycle method which should be called from
175
      * <tt>Activity.onBackPressed</tt> so we can do the required internal
199
      * <tt>Activity.onBackPressed</tt> so we can do the required internal

+ 16
- 0
ios/README.md 查看文件

32
 The `JitsiMeetView` class is the entry point to the SDK. It a subclass of
32
 The `JitsiMeetView` class is the entry point to the SDK. It a subclass of
33
 `UIView` which renders a full conference in the designated area.
33
 `UIView` which renders a full conference in the designated area.
34
 
34
 
35
+#### delegate
36
+
37
+Property for getting / setting the delegate (instance of `JitsiMeetViewDelegate`
38
+in the view.
39
+
40
+#### disableWelcomePage
41
+
42
+Property for setting the welcome page as disabled (or not). It default to NO, so
43
+a welcome page would be shown. When the welcome page is set to disabled, an
44
+empty black view is rendered.
45
+
46
+NOTE: This property must be set before calling `loadURL` in order for it to take
47
+effect.
48
+
49
+#### loadURL(url)
50
+
35
 ```objc
51
 ```objc
36
 [meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];
52
 [meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];
37
 ```
53
 ```

+ 1
- 0
ios/sdk/src/JitsiMeetView.h 查看文件

22
 @interface JitsiMeetView : UIView
22
 @interface JitsiMeetView : UIView
23
 
23
 
24
 @property (nonatomic, weak, nullable) id<JitsiMeetViewDelegate> delegate;
24
 @property (nonatomic, weak, nullable) id<JitsiMeetViewDelegate> delegate;
25
+@property (nonatomic) BOOL disableWelcomePage;
25
 
26
 
26
 +    (BOOL)application:(UIApplication *)application
27
 +    (BOOL)application:(UIApplication *)application
27
   continueUserActivity:(NSUserActivity *)userActivity
28
   continueUserActivity:(NSUserActivity *)userActivity

+ 7
- 1
ios/sdk/src/JitsiMeetView.m 查看文件

106
  * is null, the welcome page is shown.
106
  * is null, the welcome page is shown.
107
  */
107
  */
108
 - (void)loadURL:(NSURL *)url {
108
 - (void)loadURL:(NSURL *)url {
109
-    NSDictionary *props = url ? @{ url : url.absoluteString } : nil;
109
+    NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
110
+
111
+    if (url) {
112
+        [props setObject:url.absoluteString forKey:@"url"];
113
+    }
114
+
115
+    [props setObject:@(self.disableWelcomePage) forKey:@"disableWelcomePage"];
110
 
116
 
111
     if (rootView == nil) {
117
     if (rootView == nil) {
112
         rootView
118
         rootView

+ 17
- 4
react/features/app/actionTypes.js 查看文件

1
 /**
1
 /**
2
- * The type of the actions which signals that a specific App will mount (in the
3
- * terms of React).
2
+ * The type of (Redux) action which configures if the welcome page should be
3
+ * disabled or not.
4
+ *
5
+ * {
6
+ *     type: APP_SET_WELCOME_PAGE_DISABLED,
7
+ *     app: App,
8
+ *     disabled: boolean
9
+ * }
10
+ */
11
+export const APP_SET_WELCOME_PAGE_DISABLED
12
+    = Symbol('APP_SET_WELCOME_PAGE_DISABLED');
13
+
14
+/**
15
+ * The type of (Redux) action which signals that a specific App will mount (in
16
+ * React terms).
4
  *
17
  *
5
  * {
18
  * {
6
  *     type: APP_WILL_MOUNT,
19
  *     type: APP_WILL_MOUNT,
10
 export const APP_WILL_MOUNT = Symbol('APP_WILL_MOUNT');
23
 export const APP_WILL_MOUNT = Symbol('APP_WILL_MOUNT');
11
 
24
 
12
 /**
25
 /**
13
- * The type of the actions which signals that a specific App will unmount (in
14
- * the terms of React).
26
+ * The type of (Redux) action which signals that a specific App will unmount (in
27
+ * React terms).
15
  *
28
  *
16
  * {
29
  * {
17
  *     type: APP_WILL_UNMOUNT,
30
  *     type: APP_WILL_UNMOUNT,

+ 25
- 1
react/features/app/actions.js 查看文件

3
 import { setConfig } from '../base/config';
3
 import { setConfig } from '../base/config';
4
 import { loadConfig } from '../base/lib-jitsi-meet';
4
 import { loadConfig } from '../base/lib-jitsi-meet';
5
 
5
 
6
-import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
6
+import {
7
+    APP_SET_WELCOME_PAGE_DISABLED,
8
+    APP_WILL_MOUNT,
9
+    APP_WILL_UNMOUNT
10
+} from './actionTypes';
7
 import { _getRouteToRender, _parseURIString } from './functions';
11
 import { _getRouteToRender, _parseURIString } from './functions';
8
 
12
 
9
 declare var APP: Object;
13
 declare var APP: Object;
156
     _appNavigateToMandatoryLocation(dispatch, getState, location);
160
     _appNavigateToMandatoryLocation(dispatch, getState, location);
157
 }
161
 }
158
 
162
 
163
+/**
164
+ * Configures the welcome page display for this app.
165
+ *
166
+ * @param {App} app - The App being configured.
167
+ * @param {boolean} disabled - Set to true if the welcome page should be
168
+ * disabled, false if it shouldn't.
169
+ * @returns {{
170
+ *     type: APP_SET_WELCOME_PAGE_DISABLED,
171
+ *     app: App,
172
+ *     disabled: boolean
173
+ * }}
174
+ */
175
+export function appSetWelcomePageDisabled(app, disabled) {
176
+    return {
177
+        type: APP_SET_WELCOME_PAGE_DISABLED,
178
+        app,
179
+        disabled
180
+    };
181
+}
182
+
159
 /**
183
 /**
160
  * Signals that a specific App will mount (in the terms of React).
184
  * Signals that a specific App will mount (in the terms of React).
161
  *
185
  *

+ 1
- 1
react/features/app/components/AbstractApp.js 查看文件

370
      */
370
      */
371
     _onRouteEnter(route, ...args) {
371
     _onRouteEnter(route, ...args) {
372
         // Notify the route that it is about to be entered.
372
         // Notify the route that it is about to be entered.
373
-        const onEnter = route.onEnter;
373
+        const onEnter = route && route.onEnter;
374
 
374
 
375
         if (typeof onEnter === 'function') {
375
         if (typeof onEnter === 'function') {
376
             onEnter(...args);
376
             onEnter(...args);

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

1
 /* global __DEV__ */
1
 /* global __DEV__ */
2
 
2
 
3
+import React from 'react';
3
 import { Linking } from 'react-native';
4
 import { Linking } from 'react-native';
4
 
5
 
5
 import { Platform } from '../../base/react';
6
 import { Platform } from '../../base/react';
11
 import '../../mobile/wake-lock';
12
 import '../../mobile/wake-lock';
12
 
13
 
13
 import { AbstractApp } from './AbstractApp';
14
 import { AbstractApp } from './AbstractApp';
15
+import { appSetWelcomePageDisabled } from '../actions';
14
 
16
 
15
 /**
17
 /**
16
  * Root application component.
18
  * Root application component.
23
      *
25
      *
24
      * @static
26
      * @static
25
      */
27
      */
26
-    static propTypes = AbstractApp.propTypes;
28
+    static propTypes = {
29
+        ...AbstractApp.propTypes,
30
+
31
+        /**
32
+         * Indicates if the welcome page should be shown when not in a
33
+         * conference.
34
+         */
35
+        disableWelcomePage: React.PropTypes.bool
36
+    };
27
 
37
 
28
     /**
38
     /**
29
      * Initializes a new App instance.
39
      * Initializes a new App instance.
56
         super.componentWillMount();
66
         super.componentWillMount();
57
 
67
 
58
         Linking.addEventListener('url', this._onLinkingURL);
68
         Linking.addEventListener('url', this._onLinkingURL);
69
+
70
+        // Store the desire to use the welcome page or not in the Redux store.
71
+        const dispatch = this._getStore().dispatch;
72
+
73
+        dispatch(
74
+            appSetWelcomePageDisabled(
75
+                this, Boolean(this.props.disableWelcomePage)));
59
     }
76
     }
60
 
77
 
61
     /**
78
     /**

+ 5
- 0
react/features/app/functions.native.js 查看文件

142
         = typeof stateOrGetState === 'function'
142
         = typeof stateOrGetState === 'function'
143
             ? stateOrGetState()
143
             ? stateOrGetState()
144
             : stateOrGetState;
144
             : stateOrGetState;
145
+    const { disableWelcomePage } = state['features/app'];
145
     const { room } = state['features/base/conference'];
146
     const { room } = state['features/base/conference'];
146
     const component = isRoomValid(room) ? Conference : WelcomePage;
147
     const component = isRoomValid(room) ? Conference : WelcomePage;
147
 
148
 
149
+    if (component === WelcomePage && disableWelcomePage) {
150
+        return null;
151
+    }
152
+
148
     return RouteRegistry.getRouteByComponent(component);
153
     return RouteRegistry.getRouteByComponent(component);
149
 }
154
 }
150
 
155
 

+ 13
- 1
react/features/app/reducer.js 查看文件

1
 import { ReducerRegistry } from '../base/redux';
1
 import { ReducerRegistry } from '../base/redux';
2
 
2
 
3
-import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
3
+import {
4
+    APP_SET_WELCOME_PAGE_DISABLED,
5
+    APP_WILL_MOUNT,
6
+    APP_WILL_UNMOUNT
7
+} from './actionTypes';
4
 
8
 
5
 ReducerRegistry.register('features/app', (state = {}, action) => {
9
 ReducerRegistry.register('features/app', (state = {}, action) => {
6
     switch (action.type) {
10
     switch (action.type) {
11
+    case APP_SET_WELCOME_PAGE_DISABLED:
12
+        if (state.app === action.app) {
13
+            return {
14
+                ...state,
15
+                disableWelcomePage: action.disabled
16
+            };
17
+        }
18
+        break;
7
     case APP_WILL_MOUNT:
19
     case APP_WILL_MOUNT:
8
         if (state.app !== action.app) {
20
         if (state.app !== action.app) {
9
             return {
21
             return {

+ 20
- 1
react/index.native.js 查看文件

12
  * @extends Component
12
  * @extends Component
13
  */
13
  */
14
 class Root extends Component {
14
 class Root extends Component {
15
+    /**
16
+     * Root component's property types.
17
+     *
18
+     * @static
19
+     */
20
+    static propTypes = {
21
+        /**
22
+         * Indicates if the welcome page should be shown when not in a
23
+         * conference.
24
+         */
25
+        disableWelcomePage: React.PropTypes.bool,
26
+
27
+        /**
28
+         * The URL, if any, with which the app was launched.
29
+         */
30
+        url: React.PropTypes.string
31
+    };
32
+
15
     /**
33
     /**
16
      * Initializes a new Root instance.
34
      * Initializes a new Root instance.
17
      *
35
      *
32
              *
50
              *
33
              * @type {string}
51
              * @type {string}
34
              */
52
              */
35
-            url: undefined
53
+            url: this.props.url
36
         };
54
         };
37
 
55
 
38
         // Handle the URL, if any, with which the app was launched.
56
         // Handle the URL, if any, with which the app was launched.
64
 
82
 
65
         return (
83
         return (
66
             <App
84
             <App
85
+                disableWelcomePage = { this.props.disableWelcomePage }
67
                 url = { this.state.url } />
86
                 url = { this.state.url } />
68
         );
87
         );
69
     }
88
     }

Loading…
取消
儲存