Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

[RN] Add ability to skip the welcome page

Saúl Ibarra Corretgé4687c1f465d4
diff --git a/android/README.md b/android/README.md
index 42957a85ba..0ea1610756 100644
--- a/android/README.md
+++ b/android/README.md
@@ -85,10 +85,17 @@ public class MainActivity extends AppCompatActivity {
This class encapsulates a high level API in the form of an Android `Activity`
which displays a single `JitsiMeetView`.
+#### getWelcomePageDisabled()
+
+See JitsiMeetView.getWelcomePageDisabled.
+
#### loadURL(url)
See JitsiMeetView.loadURL.
+#### setWelcomePageDisabled(disabled)
+
+See JitsiMeetView.setWelcomePageDisabled.
### JitsiMeetView
@@ -99,6 +106,11 @@ display a Jitsi Meet conference (or a welcome page).
Returns the `JitsiMeetViewListener` instance attached to the view.
+#### getWelcomePageDisabled()
+
+Returns true if the welcome page is disable,d false if not. If the welcome page
+is disabled, a black empty view will be rendered when not in a conference.
+
#### loadURL(url)
Loads the given URL and joins the room. If `null` is specified, the welcome page
@@ -109,6 +121,13 @@ is displayed instead.
Sets the given listener (class implementing the `JitsiMeetViewListener`
interface) on the view.
+#### setWelcomePageDisabled(disabled)
+
+Sets if the welcome page should be disabled or not. See `getWelcomePageDisabled`
+for more info.
+
+NOTE: This function must be called before `loadURL` for it to take effect.
+
#### onBackPressed()
Helper method which should be called from the activity's `onBackPressed` method.
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java
index b298ec0ce4..eb47fdea3e 100644
--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java
+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetActivity.java
@@ -50,6 +50,13 @@ public class JitsiMeetActivity extends AppCompatActivity {
*/
private JitsiMeetView view;
+ /**
+ * See {@JitsiMeetView.getWelcomePageDisabled}.
+ */
+ public boolean getWelcomePageDisabled() {
+ return view != null && view.getWelcomePageDisabled();
+ }
+
/**
* Loads the given URL and displays the conference. If the specified URL is
* null, the welcome page is displayed instead.
@@ -60,6 +67,15 @@ public class JitsiMeetActivity extends AppCompatActivity {
view.loadURL(url);
}
+ /**
+ * See {@JitsiMeetView.setWelcomePageDisabled}.
+ */
+ public void setWelcomePageDisabled(boolean disabled) {
+ if (view != null) {
+ view.setWelcomePageDisabled(disabled);
+ }
+ }
+
/**
* {@inheritDoc}
*/
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java
index 389dd9f42e..58b26ae1dc 100644
--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java
+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java
@@ -58,6 +58,11 @@ public class JitsiMeetView extends FrameLayout {
*/
private JitsiMeetViewListener listener;
+ /**
+ * Indicates if the welcome page should be disabled or not.
+ */
+ private boolean welcomePageDisabled;
+
/**
* React Native root view.
*/
@@ -105,6 +110,13 @@ public class JitsiMeetView extends FrameLayout {
return listener;
}
+ /**
+ * @return - true if the welcome page is disabled, false if not.
+ */
+ public boolean getWelcomePageDisabled() {
+ return welcomePageDisabled;
+ }
+
/**
* Internal method to initialize the React Native instance manager. We
* create a single instance in order to load the JavaScript bundle a single
@@ -145,6 +157,8 @@ public class JitsiMeetView extends FrameLayout {
props.putString("url", url.toString());
}
+ props.putBoolean("disableWelcomePage", welcomePageDisabled);
+
// TODO: ReactRootView#setAppProperties is only available on React
// Native 0.45, so destroy the current root view and create a new one.
if (reactRootView != null) {
@@ -170,6 +184,16 @@ public class JitsiMeetView extends FrameLayout {
this.listener = listener;
}
+ /**
+ * Sets if the welcome page should be enabled or not. Must be called before calling loadURL or
+ * it won't take effect.
+ *
+ * @param disabled - set to true for disabling the welcome page, false not to do so.
+ */
+ public void setWelcomePageDisabled(boolean disabled) {
+ welcomePageDisabled = disabled;
+ }
+
/**
* Activity lifecycle method which should be called from
* <tt>Activity.onBackPressed</tt> so we can do the required internal
diff --git a/ios/README.md b/ios/README.md
index 65f0e65c1a..84888575de 100644
--- a/ios/README.md
+++ b/ios/README.md
@@ -32,6 +32,22 @@ To get started:
The `JitsiMeetView` class is the entry point to the SDK. It a subclass of
`UIView` which renders a full conference in the designated area.
+#### delegate
+
+Property for getting / setting the delegate (instance of `JitsiMeetViewDelegate`
+in the view.
+
+#### disableWelcomePage
+
+Property for setting the welcome page as disabled (or not). It default to NO, so
+a welcome page would be shown. When the welcome page is set to disabled, an
+empty black view is rendered.
+
+NOTE: This property must be set before calling `loadURL` in order for it to take
+effect.
+
+#### loadURL(url)
+
```objc
[meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]];
```
diff --git a/ios/sdk/src/JitsiMeetView.h b/ios/sdk/src/JitsiMeetView.h
index b3ccad0db1..4e5d7adb67 100644
--- a/ios/sdk/src/JitsiMeetView.h
+++ b/ios/sdk/src/JitsiMeetView.h
@@ -22,6 +22,7 @@
@interface JitsiMeetView : UIView
@property (nonatomic, weak, nullable) id<JitsiMeetViewDelegate> delegate;
+@property (nonatomic) BOOL disableWelcomePage;
+ (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
diff --git a/ios/sdk/src/JitsiMeetView.m b/ios/sdk/src/JitsiMeetView.m
index 310834f750..c8fa7968d4 100644
--- a/ios/sdk/src/JitsiMeetView.m
+++ b/ios/sdk/src/JitsiMeetView.m
@@ -106,7 +106,13 @@ static JitsiMeetView *instance;
* is null, the welcome page is shown.
*/
- (void)loadURL:(NSURL *)url {
- NSDictionary *props = url ? @{ url : url.absoluteString } : nil;
+ NSMutableDictionary *props = [[NSMutableDictionary alloc] init];
+
+ if (url) {
+ [props setObject:url.absoluteString forKey:@"url"];
+ }
+
+ [props setObject:@(self.disableWelcomePage) forKey:@"disableWelcomePage"];
if (rootView == nil) {
rootView
diff --git a/react/features/app/actionTypes.js b/react/features/app/actionTypes.js
index eebf1122d4..1c266b98e4 100644
--- a/react/features/app/actionTypes.js
+++ b/react/features/app/actionTypes.js
@@ -1,6 +1,19 @@
/**
- * The type of the actions which signals that a specific App will mount (in the
- * terms of React).
+ * The type of (Redux) action which configures if the welcome page should be
+ * disabled or not.
+ *
+ * {
+ * type: APP_SET_WELCOME_PAGE_DISABLED,
+ * app: App,
+ * disabled: boolean
+ * }
+ */
+export const APP_SET_WELCOME_PAGE_DISABLED
+ = Symbol('APP_SET_WELCOME_PAGE_DISABLED');
+
+/**
+ * The type of (Redux) action which signals that a specific App will mount (in
+ * React terms).
*
* {
* type: APP_WILL_MOUNT,
@@ -10,8 +23,8 @@
export const APP_WILL_MOUNT = Symbol('APP_WILL_MOUNT');
/**
- * The type of the actions which signals that a specific App will unmount (in
- * the terms of React).
+ * The type of (Redux) action which signals that a specific App will unmount (in
+ * React terms).
*
* {
* type: APP_WILL_UNMOUNT,
diff --git a/react/features/app/actions.js b/react/features/app/actions.js
index faa42bbc71..b4a0ff273d 100644
--- a/react/features/app/actions.js
+++ b/react/features/app/actions.js
@@ -3,7 +3,11 @@ import { setLocationURL } from '../base/connection';
import { setConfig } from '../base/config';
import { loadConfig } from '../base/lib-jitsi-meet';
-import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
+import {
+ APP_SET_WELCOME_PAGE_DISABLED,
+ APP_WILL_MOUNT,
+ APP_WILL_UNMOUNT
+} from './actionTypes';
import { _getRouteToRender, _parseURIString } from './functions';
declare var APP: Object;
@@ -156,6 +160,26 @@ function _appNavigateToOptionalLocation(
_appNavigateToMandatoryLocation(dispatch, getState, location);
}
+/**
+ * Configures the welcome page display for this app.
+ *
+ * @param {App} app - The App being configured.
+ * @param {boolean} disabled - Set to true if the welcome page should be
+ * disabled, false if it shouldn't.
+ * @returns {{
+ * type: APP_SET_WELCOME_PAGE_DISABLED,
+ * app: App,
+ * disabled: boolean
+ * }}
+ */
+export function appSetWelcomePageDisabled(app, disabled) {
+ return {
+ type: APP_SET_WELCOME_PAGE_DISABLED,
+ app,
+ disabled
+ };
+}
+
/**
* Signals that a specific App will mount (in the terms of React).
*
diff --git a/react/features/app/components/AbstractApp.js b/react/features/app/components/AbstractApp.js
index 8225bb54ba..ec2659adff 100644
--- a/react/features/app/components/AbstractApp.js
+++ b/react/features/app/components/AbstractApp.js
@@ -370,7 +370,7 @@ export class AbstractApp extends Component {
*/
_onRouteEnter(route, ...args) {
// Notify the route that it is about to be entered.
- const onEnter = route.onEnter;
+ const onEnter = route && route.onEnter;
if (typeof onEnter === 'function') {
onEnter(...args);
diff --git a/react/features/app/components/App.native.js b/react/features/app/components/App.native.js
index da54edcf58..0fd28d4d88 100644
--- a/react/features/app/components/App.native.js
+++ b/react/features/app/components/App.native.js
@@ -1,5 +1,6 @@
/* global __DEV__ */
+import React from 'react';
import { Linking } from 'react-native';
import { Platform } from '../../base/react';
@@ -11,6 +12,7 @@ import '../../mobile/proximity';
import '../../mobile/wake-lock';
import { AbstractApp } from './AbstractApp';
+import { appSetWelcomePageDisabled } from '../actions';
/**
* Root application component.
@@ -23,7 +25,15 @@ export class App extends AbstractApp {
*
* @static
*/
- static propTypes = AbstractApp.propTypes;
+ static propTypes = {
+ ...AbstractApp.propTypes,
+
+ /**
+ * Indicates if the welcome page should be shown when not in a
+ * conference.
+ */
+ disableWelcomePage: React.PropTypes.bool
+ };
/**
* Initializes a new App instance.
@@ -56,6 +66,13 @@ export class App extends AbstractApp {
super.componentWillMount();
Linking.addEventListener('url', this._onLinkingURL);
+
+ // Store the desire to use the welcome page or not in the Redux store.
+ const dispatch = this._getStore().dispatch;
+
+ dispatch(
+ appSetWelcomePageDisabled(
+ this, Boolean(this.props.disableWelcomePage)));
}
/**
diff --git a/react/features/app/functions.native.js b/react/features/app/functions.native.js
index 94b373160d..4dac0d1e50 100644
--- a/react/features/app/functions.native.js
+++ b/react/features/app/functions.native.js
@@ -142,9 +142,14 @@ export function _getRouteToRender(stateOrGetState) {
= typeof stateOrGetState === 'function'
? stateOrGetState()
: stateOrGetState;
+ const { disableWelcomePage } = state['features/app'];
const { room } = state['features/base/conference'];
const component = isRoomValid(room) ? Conference : WelcomePage;
+ if (component === WelcomePage && disableWelcomePage) {
+ return null;
+ }
+
return RouteRegistry.getRouteByComponent(component);
}
diff --git a/react/features/app/reducer.js b/react/features/app/reducer.js
index d6922b8c36..e63c8d0963 100644
--- a/react/features/app/reducer.js
+++ b/react/features/app/reducer.js
@@ -1,9 +1,21 @@
import { ReducerRegistry } from '../base/redux';
-import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
+import {
+ APP_SET_WELCOME_PAGE_DISABLED,
+ APP_WILL_MOUNT,
+ APP_WILL_UNMOUNT
+} from './actionTypes';
ReducerRegistry.register('features/app', (state = {}, action) => {
switch (action.type) {
+ case APP_SET_WELCOME_PAGE_DISABLED:
+ if (state.app === action.app) {
+ return {
+ ...state,
+ disableWelcomePage: action.disabled
+ };
+ }
+ break;
case APP_WILL_MOUNT:
if (state.app !== action.app) {
return {
diff --git a/react/index.native.js b/react/index.native.js
index fd6004b695..53e67b5bcf 100644
--- a/react/index.native.js
+++ b/react/index.native.js
@@ -12,6 +12,24 @@ import { App } from './features/app';
* @extends Component
*/
class Root extends Component {
+ /**
+ * Root component's property types.
+ *
+ * @static
+ */
+ static propTypes = {
+ /**
+ * Indicates if the welcome page should be shown when not in a
+ * conference.
+ */
+ disableWelcomePage: React.PropTypes.bool,
+
+ /**
+ * The URL, if any, with which the app was launched.
+ */
+ url: React.PropTypes.string
+ };
+
/**
* Initializes a new Root instance.
*
@@ -32,7 +50,7 @@ class Root extends Component {
*
* @type {string}
*/
- url: undefined
+ url: this.props.url
};
// Handle the URL, if any, with which the app was launched.
@@ -64,6 +82,7 @@ class Root extends Component {
return (
<App
+ disableWelcomePage = { this.props.disableWelcomePage }
url = { this.state.url } />
);
}