2017-01-05 21:06:41 +00:00
|
|
|
/* global __DEV__ */
|
|
|
|
|
2017-09-27 21:23:31 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2017-10-13 16:13:46 +00:00
|
|
|
import React from 'react';
|
2017-01-16 00:28:02 +00:00
|
|
|
import { Linking } from 'react-native';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-09-01 19:14:03 +00:00
|
|
|
import '../../analytics';
|
2017-09-18 07:09:43 +00:00
|
|
|
import '../../authentication';
|
2017-02-10 16:13:39 +00:00
|
|
|
import { Platform } from '../../base/react';
|
2018-02-02 13:39:27 +00:00
|
|
|
import {
|
|
|
|
AspectRatioDetector,
|
|
|
|
ReducedUIDetector
|
|
|
|
} from '../../base/responsive-ui';
|
2017-03-27 09:39:10 +00:00
|
|
|
import '../../mobile/audio-mode';
|
|
|
|
import '../../mobile/background';
|
2017-09-08 09:28:44 +00:00
|
|
|
import '../../mobile/callkit';
|
2017-06-07 15:50:30 +00:00
|
|
|
import '../../mobile/external-api';
|
2017-03-27 09:39:10 +00:00
|
|
|
import '../../mobile/full-screen';
|
2017-08-18 10:54:05 +00:00
|
|
|
import '../../mobile/permissions';
|
2018-02-01 16:02:07 +00:00
|
|
|
import '../../mobile/picture-in-picture';
|
2017-03-30 08:12:38 +00:00
|
|
|
import '../../mobile/proximity';
|
2017-03-27 09:39:10 +00:00
|
|
|
import '../../mobile/wake-lock';
|
2017-01-15 18:09:52 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
import { AbstractApp } from './AbstractApp';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Root application component.
|
|
|
|
*
|
|
|
|
* @extends AbstractApp
|
|
|
|
*/
|
|
|
|
export class App extends AbstractApp {
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
|
|
|
* App component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
2017-06-09 10:30:59 +00:00
|
|
|
static propTypes = {
|
|
|
|
...AbstractApp.propTypes,
|
|
|
|
|
2018-03-28 00:49:22 +00:00
|
|
|
addPeopleEnabled: PropTypes.bool,
|
|
|
|
|
|
|
|
dialOutEnabled: PropTypes.bool,
|
|
|
|
|
2018-02-01 16:02:07 +00:00
|
|
|
/**
|
2018-02-19 22:52:21 +00:00
|
|
|
* Whether Picture-in-Picture is enabled. If {@code true}, a toolbar
|
|
|
|
* button is rendered in the {@link Conference} view to afford entering
|
|
|
|
* Picture-in-Picture.
|
2018-02-01 16:02:07 +00:00
|
|
|
*/
|
2018-02-19 22:52:21 +00:00
|
|
|
pictureInPictureEnabled: PropTypes.bool,
|
2018-02-01 16:02:07 +00:00
|
|
|
|
2017-06-09 10:30:59 +00:00
|
|
|
/**
|
2017-06-09 19:09:23 +00:00
|
|
|
* 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.
|
2017-06-09 10:30:59 +00:00
|
|
|
*/
|
2017-09-27 21:23:31 +00:00
|
|
|
welcomePageEnabled: PropTypes.bool
|
2017-06-09 10:30:59 +00:00
|
|
|
};
|
2016-12-01 01:52:39 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Initializes a new App instance.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The read-only React Component props with which
|
|
|
|
* the new instance is to be initialized.
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
|
|
this._onLinkingURL = this._onLinkingURL.bind(this);
|
2017-01-05 21:06:41 +00:00
|
|
|
|
|
|
|
// In the Release configuration, React Native will (intentionally) throw
|
|
|
|
// an unhandled JavascriptException for an unhandled JavaScript error.
|
|
|
|
// This will effectively kill the application. In accord with the Web,
|
|
|
|
// do not kill the application.
|
|
|
|
this._maybeDisableExceptionsManager();
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Subscribe to notifications about activating URLs registered to be handled
|
|
|
|
* by this app.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
2017-03-28 16:43:33 +00:00
|
|
|
* @see https://facebook.github.io/react-native/docs/linking.html
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
|
|
|
componentWillMount() {
|
|
|
|
super.componentWillMount();
|
|
|
|
|
|
|
|
Linking.addEventListener('url', this._onLinkingURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unsubscribe from notifications about activating URLs registered to be
|
|
|
|
* handled by this app.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
2017-03-28 16:43:33 +00:00
|
|
|
* @see https://facebook.github.io/react-native/docs/linking.html
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
|
|
|
componentWillUnmount() {
|
|
|
|
Linking.removeEventListener('url', this._onLinkingURL);
|
|
|
|
|
|
|
|
super.componentWillUnmount();
|
|
|
|
}
|
|
|
|
|
2017-10-13 16:13:46 +00:00
|
|
|
/**
|
2017-11-07 14:28:08 +00:00
|
|
|
* Injects {@link AspectRatioDetector} in order to detect the aspect ratio
|
|
|
|
* of this {@code App}'s user interface and afford {@link AspectRatioAware}.
|
2017-10-13 16:13:46 +00:00
|
|
|
*
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
_createElement(component, props) {
|
|
|
|
return (
|
|
|
|
<AspectRatioDetector>
|
2018-02-02 13:39:27 +00:00
|
|
|
<ReducedUIDetector>
|
|
|
|
{ super._createElement(component, props) }
|
|
|
|
</ReducedUIDetector>
|
2017-11-07 14:28:08 +00:00
|
|
|
</AspectRatioDetector>
|
|
|
|
);
|
2017-10-13 16:13:46 +00:00
|
|
|
}
|
|
|
|
|
2017-01-05 21:06:41 +00:00
|
|
|
/**
|
|
|
|
* Attempts to disable the use of React Native
|
|
|
|
* {@link ExceptionsManager#handleException} on platforms and in
|
|
|
|
* configurations on/in which the use of the method in questions has been
|
|
|
|
* determined to be undesirable. For example, React Native will
|
|
|
|
* (intentionally) throw an unhandled JavascriptException for an
|
|
|
|
* unhandled JavaScript error in the Release configuration. This will
|
|
|
|
* effectively kill the application. In accord with the Web, do not kill the
|
|
|
|
* application.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_maybeDisableExceptionsManager() {
|
|
|
|
if (__DEV__) {
|
|
|
|
// As mentioned above, only the Release configuration was observed
|
|
|
|
// to suffer.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Platform.OS !== 'android') {
|
|
|
|
// A solution based on RTCSetFatalHandler was implemented on iOS and
|
|
|
|
// it is preferred because it is at a later step of the
|
|
|
|
// error/exception handling and it is specific to fatal
|
|
|
|
// errors/exceptions which were observed to kill the application.
|
|
|
|
// The solution implemented bellow was tested on Android only so it
|
|
|
|
// is considered safest to use it there only.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const oldHandler = global.ErrorUtils.getGlobalHandler();
|
|
|
|
const newHandler = _handleException;
|
|
|
|
|
|
|
|
if (!oldHandler || oldHandler !== newHandler) {
|
|
|
|
newHandler.next = oldHandler;
|
|
|
|
global.ErrorUtils.setGlobalHandler(newHandler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Notified by React's Linking API that a specific URL registered to be
|
|
|
|
* handled by this App was activated.
|
|
|
|
*
|
|
|
|
* @param {Object} event - The details of the notification/event.
|
|
|
|
* @param {string} event.url - The URL registered to be handled by this App
|
|
|
|
* which was activated.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-07-06 18:24:24 +00:00
|
|
|
_onLinkingURL({ url }) {
|
|
|
|
this._openURL(url);
|
2016-10-05 14:36:59 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-05 21:06:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles a (possibly unhandled) JavaScript error by preventing React Native
|
|
|
|
* from converting a fatal error into an unhandled native exception which will
|
|
|
|
* kill the application.
|
|
|
|
*
|
|
|
|
* @param {Error} error - The (possibly unhandled) JavaScript error to handle.
|
|
|
|
* @param {boolean} fatal - True if the specified error is fatal; otherwise,
|
|
|
|
* false.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function _handleException(error, fatal) {
|
|
|
|
if (fatal) {
|
|
|
|
// In the Release configuration, React Native will (intentionally) throw
|
|
|
|
// an unhandled JavascriptException for an unhandled JavaScript error.
|
|
|
|
// This will effectively kill the application. In accord with the Web,
|
|
|
|
// do not kill the application.
|
|
|
|
console.error(error);
|
|
|
|
} else {
|
|
|
|
// Forward to the next globalHandler of ErrorUtils.
|
|
|
|
const next = _handleException.next;
|
|
|
|
|
|
|
|
typeof next === 'function' && next(error, fatal);
|
|
|
|
}
|
|
|
|
}
|