From 5f64ccb97d3b8579b64a2c7cc00ef6502744f7db Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Fri, 9 Jun 2017 14:09:23 -0500 Subject: [PATCH] [RN] Naming --- android/README.md | 26 +++++------ .../java/org/jitsi/meet/MainActivity.java | 23 ++++++++-- .../org/jitsi/meet/sdk/JitsiMeetActivity.java | 39 +++++++++++----- .../org/jitsi/meet/sdk/JitsiMeetView.java | 40 ++++++++++------- ios/README.md | 15 +++---- ios/app/src/ViewController.m | 5 +++ ios/sdk/src/JitsiMeetView.h | 3 +- ios/sdk/src/JitsiMeetView.m | 5 ++- react/features/app/actionTypes.js | 17 +------ react/features/app/actions.js | 26 +---------- react/features/app/components/AbstractApp.js | 40 +++++++++-------- react/features/app/components/App.native.js | 15 ++----- react/features/app/functions.native.js | 15 +++++-- react/features/app/reducer.js | 23 +++------- react/index.native.js | 45 ++++++++++++------- react/index.web.js | 2 +- 16 files changed, 175 insertions(+), 164 deletions(-) diff --git a/android/README.md b/android/README.md index 0ea161075..a31466ae9 100644 --- a/android/README.md +++ b/android/README.md @@ -85,17 +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() +#### getWelcomePageEnabled() -See JitsiMeetView.getWelcomePageDisabled. +See JitsiMeetView.getWelcomePageEnabled. -#### loadURL(url) +#### loadURL(URL) See JitsiMeetView.loadURL. -#### setWelcomePageDisabled(disabled) +#### setWelcomePageEnabled(boolean) -See JitsiMeetView.setWelcomePageDisabled. +See JitsiMeetView.setWelcomePageEnabled. ### JitsiMeetView @@ -106,12 +106,12 @@ display a Jitsi Meet conference (or a welcome page). Returns the `JitsiMeetViewListener` instance attached to the view. -#### getWelcomePageDisabled() +#### getWelcomePageEnabled() -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. +Returns true if the Welcome page is enabled; otherwise, false. If false, a black +empty view will be rendered when not in a conference. Defaults to false. -#### loadURL(url) +#### loadURL(URL) Loads the given URL and joins the room. If `null` is specified, the welcome page is displayed instead. @@ -121,12 +121,12 @@ is displayed instead. Sets the given listener (class implementing the `JitsiMeetViewListener` interface) on the view. -#### setWelcomePageDisabled(disabled) +#### setWelcomePageEnabled(boolean) -Sets if the welcome page should be disabled or not. See `getWelcomePageDisabled` -for more info. +Sets whether the Welcome page is enabled. See `getWelcomePageEnabled` for more +information. -NOTE: This function must be called before `loadURL` for it to take effect. +NOTE: Must be called before `loadURL` for it to take effect. #### onBackPressed() diff --git a/android/app/src/main/java/org/jitsi/meet/MainActivity.java b/android/app/src/main/java/org/jitsi/meet/MainActivity.java index abd5b1034..ba13956cf 100644 --- a/android/app/src/main/java/org/jitsi/meet/MainActivity.java +++ b/android/app/src/main/java/org/jitsi/meet/MainActivity.java @@ -16,6 +16,8 @@ package org.jitsi.meet; +import android.os.Bundle; + import org.jitsi.meet.sdk.JitsiMeetActivity; /** @@ -25,10 +27,23 @@ import org.jitsi.meet.sdk.JitsiMeetActivity; * of it. Further attempts at launching the application once it was already * launched will result in {@link Activity#onNewIntent(Intent)} being called. * - * This {@code Activity} extends {@link JitsiMeetActivity} without adding - * anything to it. It exists to merely keep the React Native CLI working, since - * the latter always tries to launch an {@code Activity} named - * {@code MainActivity} when doing {@code react-native run-android}. + * This {@code Activity} extends {@link JitsiMeetActivity} to keep the React + * Native CLI working, since the latter always tries to launch an + * {@code Activity} named {@code MainActivity} when doing + * {@code react-native run-android}. */ public class MainActivity extends JitsiMeetActivity { + /** + * {@inheritDoc} + */ + @Override + protected void onCreate(Bundle savedInstanceState) { + // As this is the Jitsi Meet app (i.e. not the Jitsi Meet SDK), we do + // want the Welcome page to be enabled. It defaults to disabled in the + // SDK at the time of this writing but it is clearer to be explicit + // about what we want anyway. + setWelcomePageEnabled(true); + + super.onCreate(savedInstanceState); + } } 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 eb47fdea3..ccac970f6 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 @@ -51,10 +51,17 @@ public class JitsiMeetActivity extends AppCompatActivity { private JitsiMeetView view; /** - * See {@JitsiMeetView.getWelcomePageDisabled}. + * Whether the Welcome page is enabled. The value is used only while + * {@link #view} equals {@code null}. */ - public boolean getWelcomePageDisabled() { - return view != null && view.getWelcomePageDisabled(); + private boolean welcomePageEnabled; + + /** + * + * @see JitsiMeetView#getWelcomePageEnabled + */ + public boolean getWelcomePageEnabled() { + return view == null ? welcomePageEnabled : view.getWelcomePageEnabled(); } /** @@ -67,15 +74,6 @@ public class JitsiMeetActivity extends AppCompatActivity { view.loadURL(url); } - /** - * See {@JitsiMeetView.setWelcomePageDisabled}. - */ - public void setWelcomePageDisabled(boolean disabled) { - if (view != null) { - view.setWelcomePageDisabled(disabled); - } - } - /** * {@inheritDoc} */ @@ -115,6 +113,11 @@ public class JitsiMeetActivity extends AppCompatActivity { super.onCreate(savedInstanceState); view = new JitsiMeetView(this); + + // In order to have the desired effect + // JitsiMeetView#setWelcomePageEnabled(boolean) must be invoked before + // JitsiMeetView#loadURL(URL). + view.setWelcomePageEnabled(welcomePageEnabled); view.loadURL(null); // In debug mode React needs permission to write over other apps in @@ -171,4 +174,16 @@ public class JitsiMeetActivity extends AppCompatActivity { JitsiMeetView.onHostResume(this); } + + /** + * + * @see JitsiMeetView#setWelcomePageEnabled + */ + public void setWelcomePageEnabled(boolean welcomePageEnabled) { + if (view == null) { + this.welcomePageEnabled = welcomePageEnabled; + } else { + view.setWelcomePageEnabled(welcomePageEnabled); + } + } } 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 58b26ae1d..72508ac62 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,16 +58,16 @@ 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. */ private ReactRootView reactRootView; + /** + * Whether the Welcome page is enabled. + */ + private boolean welcomePageEnabled; + public JitsiMeetView(@NonNull Context context) { super(context); @@ -94,7 +94,7 @@ public class JitsiMeetView extends FrameLayout { /** * Returns the only instance of this class we currently allow creating. * - * @returns The {@code JitsiMeetView} instance. + * @return The {@code JitsiMeetView} instance. */ public static JitsiMeetView getInstance() { return instance; @@ -103,7 +103,7 @@ public class JitsiMeetView extends FrameLayout { /** * Gets the {@link JitsiMeetViewListener} set on this {@code JitsiMeetView}. * - * @returns The {@code JitsiMeetViewListener} set on this + * @return The {@code JitsiMeetViewListener} set on this * {@code JitsiMeetView}. */ public JitsiMeetViewListener getListener() { @@ -111,10 +111,14 @@ public class JitsiMeetView extends FrameLayout { } /** - * @return - true if the welcome page is disabled, false if not. + * Gets whether the Welcome page is enabled. If {@code true}, the Welcome + * page is rendered when this {@code JitsiMeetView} is not at a URL + * identifying a Jitsi Meet conference/room. + * + * @return {@true} if the Welcome page is enabled; otherwise, {@code false}. */ - public boolean getWelcomePageDisabled() { - return welcomePageDisabled; + public boolean getWelcomePageEnabled() { + return welcomePageEnabled; } /** @@ -153,11 +157,12 @@ public class JitsiMeetView extends FrameLayout { public void loadURL(@Nullable URL url) { Bundle props = new Bundle(); + // url if (url != null) { props.putString("url", url.toString()); } - - props.putBoolean("disableWelcomePage", welcomePageDisabled); + // welcomePageEnabled + props.putBoolean("welcomePageEnabled", welcomePageEnabled); // TODO: ReactRootView#setAppProperties is only available on React // Native 0.45, so destroy the current root view and create a new one. @@ -185,13 +190,14 @@ public class JitsiMeetView extends FrameLayout { } /** - * Sets if the welcome page should be enabled or not. Must be called before calling loadURL or - * it won't take effect. + * Sets whether the Welcome page is enabled. Must be called before + * {@link #loadURL(URL)} for it to take effect. * - * @param disabled - set to true for disabling the welcome page, false not to do so. + * @param welcomePageEnabled {@code true} to enable the Welcome page; + * otherwise, {@code false}. */ - public void setWelcomePageDisabled(boolean disabled) { - welcomePageDisabled = disabled; + public void setWelcomePageEnabled(boolean welcomePageEnabled) { + this.welcomePageEnabled = welcomePageEnabled; } /** diff --git a/ios/README.md b/ios/README.md index 84888575d..04dc4075d 100644 --- a/ios/README.md +++ b/ios/README.md @@ -34,19 +34,16 @@ The `JitsiMeetView` class is the entry point to the SDK. It a subclass of #### delegate -Property for getting / setting the delegate (instance of `JitsiMeetViewDelegate` -in the view. +Property for getting / setting the `JitsiMeetViewDelegate` on `JitsiMeetView`. -#### disableWelcomePage +#### welcomePageEnabled -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. +Property for getting / setting whether the Welcome page is enabled. If NO, a +black empty view will be rendered when not in a conference. Defaults to NO. -NOTE: This property must be set before calling `loadURL` in order for it to take -effect. +NOTE: Must be set before calling `loadURL` for it to take effect. -#### loadURL(url) +#### loadURL(URL) ```objc [meetView loadURL:[NSURL URLWithString:@"https://meet.jit.si/test123"]]; diff --git a/ios/app/src/ViewController.m b/ios/app/src/ViewController.m index d2718ccf5..b9eb69b69 100644 --- a/ios/app/src/ViewController.m +++ b/ios/app/src/ViewController.m @@ -32,6 +32,11 @@ JitsiMeetView *view = (JitsiMeetView *) self.view; view.delegate = self; + // As this is the Jitsi Meet app (i.e. not the Jitsi Meet SDK), we do + // want the Welcome page to be enabled. It defaults to disabled in the + // SDK at the time of this writing but it is clearer to be explicit + // about what we want anyway. + view.welcomePageEnabled = YES; [view loadURL:nil]; } diff --git a/ios/sdk/src/JitsiMeetView.h b/ios/sdk/src/JitsiMeetView.h index 4e5d7adb6..ba6e642b5 100644 --- a/ios/sdk/src/JitsiMeetView.h +++ b/ios/sdk/src/JitsiMeetView.h @@ -22,7 +22,8 @@ @interface JitsiMeetView : UIView @property (nonatomic, weak, nullable) id delegate; -@property (nonatomic) BOOL disableWelcomePage; + +@property (nonatomic) BOOL welcomePageEnabled; + (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity diff --git a/ios/sdk/src/JitsiMeetView.m b/ios/sdk/src/JitsiMeetView.m index c8fa7968d..9b9cad54c 100644 --- a/ios/sdk/src/JitsiMeetView.m +++ b/ios/sdk/src/JitsiMeetView.m @@ -108,11 +108,12 @@ static JitsiMeetView *instance; - (void)loadURL:(NSURL *)url { NSMutableDictionary *props = [[NSMutableDictionary alloc] init]; + // url if (url) { [props setObject:url.absoluteString forKey:@"url"]; } - - [props setObject:@(self.disableWelcomePage) forKey:@"disableWelcomePage"]; + // welcomePageEnabled + [props setObject:@(self.welcomePageEnabled) forKey:@"welcomePageEnabled"]; if (rootView == nil) { rootView diff --git a/react/features/app/actionTypes.js b/react/features/app/actionTypes.js index 1c266b98e..669f1c7bd 100644 --- a/react/features/app/actionTypes.js +++ b/react/features/app/actionTypes.js @@ -1,18 +1,5 @@ /** - * 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 + * The type of (redux) action which signals that a specific App will mount (in * React terms). * * { @@ -23,7 +10,7 @@ export const APP_SET_WELCOME_PAGE_DISABLED export const APP_WILL_MOUNT = Symbol('APP_WILL_MOUNT'); /** - * The type of (Redux) action which signals that a specific App will unmount (in + * The type of (redux) action which signals that a specific App will unmount (in * React terms). * * { diff --git a/react/features/app/actions.js b/react/features/app/actions.js index b4a0ff273..faa42bbc7 100644 --- a/react/features/app/actions.js +++ b/react/features/app/actions.js @@ -3,11 +3,7 @@ import { setLocationURL } from '../base/connection'; import { setConfig } from '../base/config'; import { loadConfig } from '../base/lib-jitsi-meet'; -import { - APP_SET_WELCOME_PAGE_DISABLED, - APP_WILL_MOUNT, - APP_WILL_UNMOUNT -} from './actionTypes'; +import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes'; import { _getRouteToRender, _parseURIString } from './functions'; declare var APP: Object; @@ -160,26 +156,6 @@ 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 ec2659adf..0701bfcef 100644 --- a/react/features/app/components/AbstractApp.js +++ b/react/features/app/components/AbstractApp.js @@ -21,7 +21,8 @@ import { declare var APP: Object; /** - * Default URL to be loaded if no other was specified using props. + * The default URL to open if no other was specified to {@code AbstractApp} + * via props. */ const DEFAULT_URL = 'https://meet.jit.si'; @@ -38,9 +39,10 @@ export class AbstractApp extends Component { */ static propTypes = { /** - * Default URL to be loaded by the app when not in any room. + * The default URL {@code AbstractApp} is to open when not in any + * conference/room. */ - defaultUrl: React.PropTypes.string, + defaultURL: React.PropTypes.string, /** * (Optional) Redux store for this app. @@ -203,27 +205,31 @@ export class AbstractApp extends Component { * @protected */ _createElement(component, props) { - /* eslint-disable no-unused-vars, lines-around-comment */ + /* eslint-disable no-unused-vars */ + const { - // The defaultUrl property was introduced to be consumed entirely by - // AbstractApp. - defaultUrl, // Don't propagate the dispatch and store props because they usually // come from react-redux and programmers don't really expect them to // be inherited but rather explicitly connected. dispatch, // eslint-disable-line react/prop-types store, - // The url property was introduced to be consumed entirely by - // AbstractApp. + + // The following props were introduced to be consumed entirely by + // AbstractApp: + defaultURL, url, + // The remaining props, if any, are considered suitable for // propagation to the children of this Component. ...thisProps } = this.props; - /* eslint-enable no-unused-vars, lines-around-comment */ - // eslint-disable-next-line object-property-newline - return React.createElement(component, { ...thisProps, ...props }); + /* eslint-enable no-unused-vars */ + + return React.createElement(component, { + ...thisProps, + ...props + }); } /** @@ -276,7 +282,7 @@ export class AbstractApp extends Component { } } - return this.props.defaultUrl || DEFAULT_URL; + return this.props.defaultURL || DEFAULT_URL; } /** @@ -350,7 +356,7 @@ export class AbstractApp extends Component { // role of Router is now this AbstractApp, provide its nextState. // (2) A replace function would be provided to the Route in case it // chose to redirect to another path. - this._onRouteEnter(route, nextState, pathname => { + route && this._onRouteEnter(route, nextState, pathname => { this._openURL(pathname); // Do not proceed with the route because it chose to redirect to @@ -370,11 +376,9 @@ export class AbstractApp extends Component { */ _onRouteEnter(route, ...args) { // Notify the route that it is about to be entered. - const onEnter = route && route.onEnter; + const { onEnter } = route; - if (typeof onEnter === 'function') { - onEnter(...args); - } + typeof onEnter === 'function' && onEnter(...args); } /** diff --git a/react/features/app/components/App.native.js b/react/features/app/components/App.native.js index 0fd28d4d8..0451cd63a 100644 --- a/react/features/app/components/App.native.js +++ b/react/features/app/components/App.native.js @@ -12,7 +12,6 @@ import '../../mobile/proximity'; import '../../mobile/wake-lock'; import { AbstractApp } from './AbstractApp'; -import { appSetWelcomePageDisabled } from '../actions'; /** * Root application component. @@ -29,10 +28,11 @@ export class App extends AbstractApp { ...AbstractApp.propTypes, /** - * Indicates if the welcome page should be shown when not in a - * conference. + * Whether the Welcome page is enabled. If {@code true}, the Welcome + * page is rendered when the {@link App} is not at a location (URL) + * identifying a Jitsi Meet conference/room. */ - disableWelcomePage: React.PropTypes.bool + welcomePageEnabled: React.PropTypes.bool }; /** @@ -66,13 +66,6 @@ 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 4dac0d1e5..1eb7b6720 100644 --- a/react/features/app/functions.native.js +++ b/react/features/app/functions.native.js @@ -142,12 +142,19 @@ 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; + let component; - if (component === WelcomePage && disableWelcomePage) { - return null; + if (isRoomValid(room)) { + component = Conference; + } else { + // The value of the App prop welcomePageEnabled was stored in redux in + // saghul's PR. But I removed the redux state, action, action type, etc. + // because I didn't like the name. We are not using the prop is a + // React-ive way anyway so it's all the same difference. + const { app } = state['features/app']; + + component = app && app.props.welcomePageEnabled ? WelcomePage : null; } return RouteRegistry.getRouteByComponent(component); diff --git a/react/features/app/reducer.js b/react/features/app/reducer.js index e63c8d096..5f091d7e4 100644 --- a/react/features/app/reducer.js +++ b/react/features/app/reducer.js @@ -1,23 +1,13 @@ import { ReducerRegistry } from '../base/redux'; -import { - APP_SET_WELCOME_PAGE_DISABLED, - APP_WILL_MOUNT, - APP_WILL_UNMOUNT -} from './actionTypes'; +import { 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) { + case APP_WILL_MOUNT: { + const { app } = action; + + if (state.app !== app) { return { ...state, @@ -27,10 +17,11 @@ ReducerRegistry.register('features/app', (state = {}, action) => { * * @type {App} */ - app: action.app + app }; } break; + } case APP_WILL_UNMOUNT: if (state.app === action.app) { diff --git a/react/index.native.js b/react/index.native.js index 53e67b5bc..5100227d2 100644 --- a/react/index.native.js +++ b/react/index.native.js @@ -13,25 +13,26 @@ import { App } from './features/app'; */ class Root extends Component { /** - * Root component's property types. + * {@code 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 + url: React.PropTypes.string, + + /** + * Whether the Welcome page is enabled. If {@code true}, the Welcome + * page is rendered when the {@link App} is not at a location (URL) + * identifying a Jitsi Meet conference/room. + */ + welcomePageEnabled: React.PropTypes.bool }; /** - * Initializes a new Root instance. + * Initializes a new {@code Root} instance. * * @param {Object} props - The read-only properties with which the new * instance is to be initialized. @@ -42,7 +43,9 @@ class Root extends Component { /** * The initial state of this Component. * - * @type {{url: string}} + * @type {{ + * url: string + * }} */ this.state = { /** @@ -74,19 +77,29 @@ class Root extends Component { * @returns {ReactElement} */ render() { - // XXX We don't render the App component until we get the initial URL, - // either it's null or some other non-null defined value; - if (typeof this.state.url === 'undefined') { + const { url } = this.state; + + // XXX We don't render the App component until we get the initial URL. + // Either it's null or some other non-null defined value. + if (typeof url === 'undefined') { return null; } + const { + // The following props are forked in state: + url: _, // eslint-disable-line no-unused-vars + + // The remaining props are passed through to App. + ...props + } = this.props; + return ( + { ...props } + url = { url } /> ); } } -// Register the main Component. +// Register the main/root Component. AppRegistry.registerComponent('App', () => Root); diff --git a/react/index.web.js b/react/index.web.js index cb9b594f7..c3c6130a9 100644 --- a/react/index.web.js +++ b/react/index.web.js @@ -18,7 +18,7 @@ document.addEventListener('DOMContentLoaded', () => { APP.connectionTimes['document.ready'] = now; logger.log('(TIME) document ready:\t', now); - // Render the main Component. + // Render the main/root Component. ReactDOM.render(, document.getElementById('react')); });