[RN] Add ability to skip the welcome page
Also expose this in the native SDKs.
This commit is contained in:
parent
79d51bc379
commit
4687c1f465
|
@ -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.
|
||||
|
|
|
@ -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}
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"]];
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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).
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 } />
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue