| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 | 
							- // @flow
 - 
 - import React, { Component } from 'react';
 - 
 - // eslint-disable-next-line react-native/split-platform-components
 - import { BackAndroid, BackHandler, StatusBar, View } from 'react-native';
 - import { connect as reactReduxConnect } from 'react-redux';
 - 
 - import { appNavigate } from '../../app';
 - import { connect, disconnect } from '../../base/connection';
 - import { DialogContainer } from '../../base/dialog';
 - import { CalleeInfoContainer } from '../../base/jwt';
 - import { JitsiRecordingConstants } from '../../base/lib-jitsi-meet';
 - import { getParticipantCount } from '../../base/participants';
 - import { Container, LoadingIndicator, TintedView } from '../../base/react';
 - import { TestConnectionInfo } from '../../base/testing';
 - import { createDesiredLocalTracks } from '../../base/tracks';
 - import { ConferenceNotification } from '../../calendar-sync';
 - import { Filmstrip } from '../../filmstrip';
 - import { LargeVideo } from '../../large-video';
 - import { RecordingLabel } from '../../recording';
 - import { setToolboxVisible, Toolbox } from '../../toolbox';
 - import { VideoQualityLabel } from '../../video-quality';
 - 
 - import styles from './styles';
 - 
 - /**
 -  * The type of the React {@code Component} props of {@link Conference}.
 -  */
 - type Props = {
 - 
 -     /**
 -      * The indicator which determines that we are still connecting to the
 -      * conference which includes establishing the XMPP connection and then
 -      * joining the room. If truthy, then an activity/loading indicator will
 -      * be rendered.
 -      *
 -      * @private
 -      */
 -     _connecting: boolean,
 - 
 -     /**
 -      * The handler which dispatches the (redux) action connect.
 -      *
 -      * @private
 -      */
 -     _onConnect: Function,
 - 
 -     /**
 -      * The handler which dispatches the (redux) action disconnect.
 -      *
 -      * @private
 -      */
 -     _onDisconnect: Function,
 - 
 -     /**
 -      * Handles a hardware button press for back navigation. Leaves the
 -      * associated {@code Conference}.
 -      *
 -      * @private
 -      * @returns {boolean} As the associated conference is unconditionally
 -      * left and exiting the app while it renders a {@code Conference} is
 -      * undesired, {@code true} is always returned.
 -      */
 -     _onHardwareBackPress: Function,
 - 
 -     /**
 -      * The number of participants in the conference.
 -      *
 -      * @private
 -      */
 -     _participantCount: number,
 - 
 -     /**
 -      * The indicator which determines whether the UI is reduced (to accommodate
 -      * smaller display areas).
 -      *
 -      * @private
 -      */
 -     _reducedUI: boolean,
 - 
 -     /**
 -      * The handler which dispatches the (redux) action setToolboxVisible to
 -      * show/hide the Toolbox.
 -      *
 -      * @private
 -      */
 -     _setToolboxVisible: Function,
 - 
 -     /**
 -      * The indicator which determines whether the Toolbox is visible.
 -      *
 -      * @private
 -      */
 -     _toolboxVisible: boolean
 - };
 - 
 - /**
 -  * The conference page of the mobile (i.e. React Native) application.
 -  */
 - class Conference extends Component<Props> {
 -     _backHandler: ?BackHandler;
 - 
 -     /**
 -      * Initializes a new Conference instance.
 -      *
 -      * @param {Object} props - The read-only properties with which the new
 -      * instance is to be initialized.
 -      */
 -     constructor(props) {
 -         super(props);
 - 
 -         // Bind event handlers so they are only bound once per instance.
 -         this._onClick = this._onClick.bind(this);
 -         this._onHardwareBackPress = this._onHardwareBackPress.bind(this);
 -     }
 - 
 -     /**
 -      * Implements {@link Component#componentDidMount()}. Invoked immediately
 -      * after this component is mounted.
 -      *
 -      * @inheritdoc
 -      * @returns {void}
 -      */
 -     componentDidMount() {
 -         // Set handling any hardware button presses for back navigation up.
 -         const backHandler = BackHandler || BackAndroid;
 - 
 -         if (backHandler) {
 -             this._backHandler = backHandler;
 -             backHandler.addEventListener(
 -                 'hardwareBackPress',
 -                 this._onHardwareBackPress);
 -         }
 - 
 -         // Show the toolbox if we are the only participant; otherwise, the whole
 -         // UI looks too unpopulated the LargeVideo visible.
 -         const { _participantCount, _setToolboxVisible } = this.props;
 - 
 -         _participantCount === 1 && _setToolboxVisible(true);
 -     }
 - 
 -     /**
 -      * Implements {@link Component#componentWillMount()}. Invoked immediately
 -      * before mounting occurs. Connects the conference described by the redux
 -      * store/state.
 -      *
 -      * @inheritdoc
 -      * @returns {void}
 -      */
 -     componentWillMount() {
 -         this.props._onConnect();
 -     }
 - 
 -     /**
 -      * Notifies this mounted React {@code Component} that it will receive new
 -      * props. Check if we need to show / hide the toolbox based on the
 -      * participant count.
 -      *
 -      * @inheritdoc
 -      * @param {Object} nextProps - The read-only React {@code Component} props
 -      * that this instance will receive.
 -      * @returns {void}
 -      */
 -     componentWillReceiveProps({ _participantCount: newParticipantCount }) {
 -         const {
 -             _participantCount: oldParticipantCount,
 -             _setToolboxVisible
 -         } = this.props;
 - 
 -         if (oldParticipantCount === 1) {
 -             newParticipantCount > 1 && _setToolboxVisible(false);
 -         } else if (oldParticipantCount > 1) {
 -             newParticipantCount === 1 && _setToolboxVisible(true);
 -         }
 -     }
 - 
 -     /**
 -      * Implements {@link Component#componentWillUnmount()}. Invoked immediately
 -      * before this component is unmounted and destroyed. Disconnects the
 -      * conference described by the redux store/state.
 -      *
 -      * @inheritdoc
 -      * @returns {void}
 -      */
 -     componentWillUnmount() {
 -         // Tear handling any hardware button presses for back navigation down.
 -         const backHandler = this._backHandler;
 - 
 -         if (backHandler) {
 -             this._backHandler = undefined;
 -             backHandler.removeEventListener(
 -                 'hardwareBackPress',
 -                 this._onHardwareBackPress);
 -         }
 - 
 -         this.props._onDisconnect();
 -     }
 - 
 -     /**
 -      * Implements React's {@link Component#render()}.
 -      *
 -      * @inheritdoc
 -      * @returns {ReactElement}
 -      */
 -     render() {
 -         return (
 -             <Container style = { styles.conference }>
 -                 <StatusBar
 -                     barStyle = 'light-content'
 -                     hidden = { true }
 -                     translucent = { true } />
 - 
 -                 {/*
 -                   * The LargeVideo is the lowermost stacking layer.
 -                   */}
 -                 <LargeVideo onPress = { this._onClick } />
 - 
 -                 {/*
 -                   * If there is a ringing call, show the callee's info.
 -                   */
 -                     this.props._reducedUI || <CalleeInfoContainer />
 -                 }
 - 
 -                 {/*
 -                   * The activity/loading indicator goes above everything, except
 -                   * the toolbox/toolbars and the dialogs.
 -                   */
 -                     this.props._connecting
 -                         && <TintedView>
 -                             <LoadingIndicator />
 -                         </TintedView>
 -                 }
 - 
 -                 <View
 -                     pointerEvents = 'box-none'
 -                     style = { styles.toolboxAndFilmstripContainer }>
 -                     {/*
 -                       * The Toolbox is in a stacking layer bellow the Filmstrip.
 -                       */}
 -                     <Toolbox />
 -                     {/*
 -                       * The Filmstrip is in a stacking layer above the
 -                       * LargeVideo. The LargeVideo and the Filmstrip form what
 -                       * the Web/React app calls "videospace". Presumably, the
 -                       * name and grouping stem from the fact that these two
 -                       * React Components depict the videos of the conference's
 -                       * participants.
 -                       */}
 -                     <Filmstrip />
 - 
 -                     <View style = { styles.indicatorContainer }>
 -                         <RecordingLabel
 -                             mode = { JitsiRecordingConstants.mode.FILE } />
 -                         <RecordingLabel
 -                             mode = { JitsiRecordingConstants.mode.STREAM } />
 -                         <VideoQualityLabel />
 -                     </View>
 -                 </View>
 -                 <TestConnectionInfo />
 - 
 -                 {
 -                     this._renderConferenceNotification()
 -                 }
 - 
 -                 {/*
 -                   * The dialogs are in the topmost stacking layers.
 -                   */
 -                     this.props._reducedUI || <DialogContainer />
 -                 }
 -             </Container>
 -         );
 -     }
 - 
 -     _onClick: () => void;
 - 
 -     /**
 -      * Changes the value of the toolboxVisible state, thus allowing us to switch
 -      * between Toolbox and Filmstrip and change their visibility.
 -      *
 -      * @private
 -      * @returns {void}
 -      */
 -     _onClick() {
 -         const toolboxVisible = !this.props._toolboxVisible;
 - 
 -         this.props._setToolboxVisible(toolboxVisible);
 -     }
 - 
 -     _onHardwareBackPress: () => boolean;
 - 
 -     /**
 -      * Handles a hardware button press for back navigation.
 -      *
 -      * @returns {boolean} If the hardware button press for back navigation was
 -      * handled by this {@code Conference}, then {@code true}; otherwise,
 -      * {@code false}.
 -      */
 -     _onHardwareBackPress() {
 -         return this._backHandler && this.props._onHardwareBackPress();
 -     }
 - 
 -     /**
 -      * Renders the conference notification badge if the feature is enabled.
 -      *
 -      * Note: If the calendar feature is disabled on a platform, then we don't
 -      * have its components exported so an undefined check is necessary.
 -      *
 -      * @private
 -      * @returns {React$Node}
 -      */
 -     _renderConferenceNotification() {
 -         return ConferenceNotification
 -             ? <ConferenceNotification />
 -             : undefined;
 -     }
 - }
 - 
 - /**
 -  * Maps dispatching of some action to React component props.
 -  *
 -  * @param {Function} dispatch - Redux action dispatcher.
 -  * @private
 -  * @returns {{
 -  *     _onConnect: Function,
 -  *     _onDisconnect: Function,
 -  *     _setToolboxVisible: Function
 -  * }}
 -  */
 - function _mapDispatchToProps(dispatch) {
 -     return {
 -         /**
 -          * Dispatches actions to create the desired local tracks and for
 -          * connecting to the conference.
 -          *
 -          * @returns {void}
 -          * @private
 -          */
 -         _onConnect() {
 -             dispatch(createDesiredLocalTracks());
 -             dispatch(connect());
 -         },
 - 
 -         /**
 -          * Dispatches an action disconnecting from the conference.
 -          *
 -          * @returns {void}
 -          * @private
 -          */
 -         _onDisconnect() {
 -             dispatch(disconnect());
 -         },
 - 
 -         /**
 -          * Handles a hardware button press for back navigation. Leaves the
 -          * associated {@code Conference}.
 -          *
 -          * @returns {boolean} As the associated conference is unconditionally
 -          * left and exiting the app while it renders a {@code Conference} is
 -          * undesired, {@code true} is always returned.
 -          */
 -         _onHardwareBackPress() {
 -             dispatch(appNavigate(undefined));
 - 
 -             return true;
 -         },
 - 
 -         /**
 -          * Dispatches an action changing the visibility of the Toolbox.
 -          *
 -          * @param {boolean} visible - True to show the Toolbox or false to hide
 -          * it.
 -          * @returns {void}
 -          * @private
 -          */
 -         _setToolboxVisible(visible) {
 -             dispatch(setToolboxVisible(visible));
 -         }
 -     };
 - }
 - 
 - /**
 -  * Maps (parts of) the redux state to the associated {@code Conference}'s props.
 -  *
 -  * @param {Object} state - The redux state.
 -  * @private
 -  * @returns {{
 -  *     _connecting: boolean,
 -  *     _participantCount: number,
 -  *     _reducedUI: boolean,
 -  *     _toolboxVisible: boolean
 -  * }}
 -  */
 - function _mapStateToProps(state) {
 -     const { connecting, connection } = state['features/base/connection'];
 -     const { conference, joining, leaving } = state['features/base/conference'];
 -     const { reducedUI } = state['features/base/responsive-ui'];
 - 
 -     // XXX There is a window of time between the successful establishment of the
 -     // XMPP connection and the subsequent commencement of joining the MUC during
 -     // which the app does not appear to be doing anything according to the redux
 -     // state. In order to not toggle the _connecting props during the window of
 -     // time in question, define _connecting as follows:
 -     // - the XMPP connection is connecting, or
 -     // - the XMPP connection is connected and the conference is joining, or
 -     // - the XMPP connection is connected and we have no conference yet, nor we
 -     //   are leaving one.
 -     const connecting_
 -         = connecting || (connection && (joining || (!conference && !leaving)));
 - 
 -     return {
 -         /**
 -          * The indicator which determines that we are still connecting to the
 -          * conference which includes establishing the XMPP connection and then
 -          * joining the room. If truthy, then an activity/loading indicator will
 -          * be rendered.
 -          *
 -          * @private
 -          * @type {boolean}
 -          */
 -         _connecting: Boolean(connecting_),
 - 
 -         /**
 -          * The number of participants in the conference.
 -          *
 -          * @private
 -          * @type {number}
 -          */
 -         _participantCount: getParticipantCount(state),
 - 
 -         /**
 -          * The indicator which determines whether the UI is reduced (to
 -          * accommodate smaller display areas).
 -          *
 -          * @private
 -          * @type {boolean}
 -          */
 -         _reducedUI: reducedUI,
 - 
 -         /**
 -          * The indicator which determines whether the Toolbox is visible.
 -          *
 -          * @private
 -          * @type {boolean}
 -          */
 -         _toolboxVisible: state['features/toolbox'].visible
 -     };
 - }
 - 
 - // $FlowFixMe
 - export default reactReduxConnect(_mapStateToProps, _mapDispatchToProps)(
 -     Conference);
 
 
  |