Browse Source

[RN] Add ability to skip the welcome page

Also expose this in the native SDKs.
j8
Saúl Ibarra Corretgé 8 years ago
parent
commit
4687c1f465

+ 19
- 0
android/README.md View File

@@ -85,10 +85,17 @@ public class MainActivity extends AppCompatActivity {
85 85
 This class encapsulates a high level API in the form of an Android `Activity`
86 86
 which displays a single `JitsiMeetView`.
87 87
 
88
+#### getWelcomePageDisabled()
89
+
90
+See JitsiMeetView.getWelcomePageDisabled.
91
+
88 92
 #### loadURL(url)
89 93
 
90 94
 See JitsiMeetView.loadURL.
91 95
 
96
+#### setWelcomePageDisabled(disabled)
97
+
98
+See JitsiMeetView.setWelcomePageDisabled.
92 99
 
93 100
 ### JitsiMeetView
94 101
 
@@ -99,6 +106,11 @@ display a Jitsi Meet conference (or a welcome page).
99 106
 
100 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 114
 #### loadURL(url)
103 115
 
104 116
 Loads the given URL and joins the room. If `null` is specified, the welcome page
@@ -109,6 +121,13 @@ is displayed instead.
109 121
 Sets the given listener (class implementing the `JitsiMeetViewListener`
110 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 131
 #### onBackPressed()
113 132
 
114 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 View File

@@ -50,6 +50,13 @@ public class JitsiMeetActivity extends AppCompatActivity {
50 50
      */
51 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 61
      * Loads the given URL and displays the conference. If the specified URL is
55 62
      * null, the welcome page is displayed instead.
@@ -60,6 +67,15 @@ public class JitsiMeetActivity extends AppCompatActivity {
60 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 80
      * {@inheritDoc}
65 81
      */

+ 24
- 0
android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java View File

@@ -58,6 +58,11 @@ public class JitsiMeetView extends FrameLayout {
58 58
      */
59 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 67
      * React Native root view.
63 68
      */
@@ -105,6 +110,13 @@ public class JitsiMeetView extends FrameLayout {
105 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 121
      * Internal method to initialize the React Native instance manager. We
110 122
      * create a single instance in order to load the JavaScript bundle a single
@@ -145,6 +157,8 @@ public class JitsiMeetView extends FrameLayout {
145 157
             props.putString("url", url.toString());
146 158
         }
147 159
 
160
+        props.putBoolean("disableWelcomePage", welcomePageDisabled);
161
+
148 162
         // TODO: ReactRootView#setAppProperties is only available on React
149 163
         // Native 0.45, so destroy the current root view and create a new one.
150 164
         if (reactRootView != null) {
@@ -170,6 +184,16 @@ public class JitsiMeetView extends FrameLayout {
170 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 198
      * Activity lifecycle method which should be called from
175 199
      * <tt>Activity.onBackPressed</tt> so we can do the required internal

+ 16
- 0
ios/README.md View File

@@ -32,6 +32,22 @@ To get started:
32 32
 The `JitsiMeetView` class is the entry point to the SDK. It a subclass of
33 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 51
 ```objc
36 52
 [meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];
37 53
 ```

+ 1
- 0
ios/sdk/src/JitsiMeetView.h View File

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

+ 7
- 1
ios/sdk/src/JitsiMeetView.m View File

@@ -106,7 +106,13 @@ static JitsiMeetView *instance;
106 106
  * is null, the welcome page is shown.
107 107
  */
108 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 117
     if (rootView == nil) {
112 118
         rootView

+ 17
- 4
react/features/app/actionTypes.js View File

@@ -1,6 +1,19 @@
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 19
  *     type: APP_WILL_MOUNT,
@@ -10,8 +23,8 @@
10 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 30
  *     type: APP_WILL_UNMOUNT,

+ 25
- 1
react/features/app/actions.js View File

@@ -3,7 +3,11 @@ import { setLocationURL } from '../base/connection';
3 3
 import { setConfig } from '../base/config';
4 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 11
 import { _getRouteToRender, _parseURIString } from './functions';
8 12
 
9 13
 declare var APP: Object;
@@ -156,6 +160,26 @@ function _appNavigateToOptionalLocation(
156 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 184
  * Signals that a specific App will mount (in the terms of React).
161 185
  *

+ 1
- 1
react/features/app/components/AbstractApp.js View File

@@ -370,7 +370,7 @@ export class AbstractApp extends Component {
370 370
      */
371 371
     _onRouteEnter(route, ...args) {
372 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 375
         if (typeof onEnter === 'function') {
376 376
             onEnter(...args);

+ 18
- 1
react/features/app/components/App.native.js View File

@@ -1,5 +1,6 @@
1 1
 /* global __DEV__ */
2 2
 
3
+import React from 'react';
3 4
 import { Linking } from 'react-native';
4 5
 
5 6
 import { Platform } from '../../base/react';
@@ -11,6 +12,7 @@ import '../../mobile/proximity';
11 12
 import '../../mobile/wake-lock';
12 13
 
13 14
 import { AbstractApp } from './AbstractApp';
15
+import { appSetWelcomePageDisabled } from '../actions';
14 16
 
15 17
 /**
16 18
  * Root application component.
@@ -23,7 +25,15 @@ export class App extends AbstractApp {
23 25
      *
24 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 39
      * Initializes a new App instance.
@@ -56,6 +66,13 @@ export class App extends AbstractApp {
56 66
         super.componentWillMount();
57 67
 
58 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 View File

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

+ 13
- 1
react/features/app/reducer.js View File

@@ -1,9 +1,21 @@
1 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 9
 ReducerRegistry.register('features/app', (state = {}, action) => {
6 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 19
     case APP_WILL_MOUNT:
8 20
         if (state.app !== action.app) {
9 21
             return {

+ 20
- 1
react/index.native.js View File

@@ -12,6 +12,24 @@ import { App } from './features/app';
12 12
  * @extends Component
13 13
  */
14 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 34
      * Initializes a new Root instance.
17 35
      *
@@ -32,7 +50,7 @@ class Root extends Component {
32 50
              *
33 51
              * @type {string}
34 52
              */
35
-            url: undefined
53
+            url: this.props.url
36 54
         };
37 55
 
38 56
         // Handle the URL, if any, with which the app was launched.
@@ -64,6 +82,7 @@ class Root extends Component {
64 82
 
65 83
         return (
66 84
             <App
85
+                disableWelcomePage = { this.props.disableWelcomePage }
67 86
                 url = { this.state.url } />
68 87
         );
69 88
     }

Loading…
Cancel
Save