You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Conference.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. // @flow
  2. import React from 'react';
  3. import { NativeModules, SafeAreaView, StatusBar, View } from 'react-native';
  4. import { appNavigate } from '../../../app/actions';
  5. import { PIP_ENABLED, FULLSCREEN_ENABLED, getFeatureFlag } from '../../../base/flags';
  6. import { Container, LoadingIndicator, TintedView } from '../../../base/react';
  7. import { connect } from '../../../base/redux';
  8. import { ASPECT_RATIO_NARROW } from '../../../base/responsive-ui/constants';
  9. import { TestConnectionInfo } from '../../../base/testing';
  10. import { ConferenceNotification, isCalendarEnabled } from '../../../calendar-sync';
  11. import { DisplayNameLabel } from '../../../display-name';
  12. import {
  13. FILMSTRIP_SIZE,
  14. Filmstrip,
  15. isFilmstripVisible,
  16. TileView
  17. } from '../../../filmstrip';
  18. import { CalleeInfoContainer } from '../../../invite';
  19. import { LargeVideo } from '../../../large-video';
  20. import { KnockingParticipantList } from '../../../lobby';
  21. import { getIsLobbyVisible } from '../../../lobby/functions';
  22. import { BackButtonRegistry } from '../../../mobile/back-button';
  23. import { Captions } from '../../../subtitles';
  24. import { setToolboxVisible } from '../../../toolbox/actions';
  25. import { Toolbox } from '../../../toolbox/components/native';
  26. import { isToolboxVisible } from '../../../toolbox/functions';
  27. import {
  28. AbstractConference,
  29. abstractMapStateToProps
  30. } from '../AbstractConference';
  31. import type { AbstractProps } from '../AbstractConference';
  32. import { navigate } from './ConferenceNavigationContainerRef';
  33. import LonelyMeetingExperience from './LonelyMeetingExperience';
  34. import NavigationBar from './NavigationBar';
  35. import { screen } from './routes';
  36. import styles from './styles';
  37. import { WebView } from 'react-native-webview';
  38. // import { Wview_v1 } from '../../../../../mdev/wview/wv1';
  39. import { Wview_v1 } from '../../../../../mdev/wv0';
  40. // import { Wview_v1 } from '../../../../../../mdev/wview/wv1';
  41. // import { Wview_v1 } from '../../../../mdev/wview/wv1';
  42. /**
  43. * The type of the React {@code Component} props of {@link Conference}.
  44. */
  45. type Props = AbstractProps & {
  46. /**
  47. * Application's aspect ratio.
  48. */
  49. _aspectRatio: Symbol,
  50. /**
  51. * Wherther the calendar feature is enabled or not.
  52. */
  53. _calendarEnabled: boolean,
  54. /**
  55. * The indicator which determines that we are still connecting to the
  56. * conference which includes establishing the XMPP connection and then
  57. * joining the room. If truthy, then an activity/loading indicator will be
  58. * rendered.
  59. */
  60. _connecting: boolean,
  61. /**
  62. * Set to {@code true} when the filmstrip is currently visible.
  63. */
  64. _filmstripVisible: boolean,
  65. /**
  66. * The indicator which determines whether fullscreen (immersive) mode is enabled.
  67. */
  68. _fullscreenEnabled: boolean,
  69. /**
  70. * The indicator which determines if the participants pane is open.
  71. */
  72. _isParticipantsPaneOpen: boolean,
  73. /**
  74. * The ID of the participant currently on stage (if any)
  75. */
  76. _largeVideoParticipantId: string,
  77. /**
  78. * Whether Picture-in-Picture is enabled.
  79. */
  80. _pictureInPictureEnabled: boolean,
  81. /**
  82. * The indicator which determines whether the UI is reduced (to accommodate
  83. * smaller display areas).
  84. */
  85. _reducedUI: boolean,
  86. /**
  87. * The indicator which determines whether the Toolbox is visible.
  88. */
  89. _toolboxVisible: boolean,
  90. /**
  91. * Indicates whether the lobby screen should be visible.
  92. */
  93. _showLobby: boolean,
  94. /**
  95. * The redux {@code dispatch} function.
  96. */
  97. dispatch: Function
  98. };
  99. /**
  100. * The conference page of the mobile (i.e. React Native) application.
  101. */
  102. class Conference extends AbstractConference<Props, *> {
  103. /**
  104. * Initializes a new Conference instance.
  105. *
  106. * @param {Object} props - The read-only properties with which the new
  107. * instance is to be initialized.
  108. */
  109. constructor(props) {
  110. super(props);
  111. // Bind event handlers so they are only bound once per instance.
  112. this._onClick = this._onClick.bind(this);
  113. this._onHardwareBackPress = this._onHardwareBackPress.bind(this);
  114. this._setToolboxVisible = this._setToolboxVisible.bind(this);
  115. }
  116. /**
  117. * Implements {@link Component#componentDidMount()}. Invoked immediately
  118. * after this component is mounted.
  119. *
  120. * @inheritdoc
  121. * @returns {void}
  122. */
  123. componentDidMount() {
  124. BackButtonRegistry.addListener(this._onHardwareBackPress);
  125. }
  126. /**
  127. * Implements {@code Component#componentDidUpdate}.
  128. *
  129. * @inheritdoc
  130. */
  131. componentDidUpdate(prevProps) {
  132. const { _showLobby } = this.props;
  133. if (!prevProps._showLobby && _showLobby) {
  134. navigate(screen.lobby);
  135. }
  136. if (prevProps._showLobby && !_showLobby) {
  137. navigate(screen.conference.main);
  138. }
  139. }
  140. /**
  141. * Implements {@link Component#componentWillUnmount()}. Invoked immediately
  142. * before this component is unmounted and destroyed. Disconnects the
  143. * conference described by the redux store/state.
  144. *
  145. * @inheritdoc
  146. * @returns {void}
  147. */
  148. componentWillUnmount() {
  149. // Tear handling any hardware button presses for back navigation down.
  150. BackButtonRegistry.removeListener(this._onHardwareBackPress);
  151. }
  152. /**
  153. * Implements React's {@link Component#render()}.
  154. *
  155. * @inheritdoc
  156. * @returns {ReactElement}
  157. */
  158. render() {
  159. const { _fullscreenEnabled } = this.props;
  160. var conference_style = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("conference_style",{that:this},{}) : {}
  161. var conference_style_v1 = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("conference_style_v1",{that:this},{}) : {}
  162. // var webview_style = window.glob_vhook.fns.glob_dev_fncb ? window.glob_vhook.fns.glob_dev_fncb("webview_style",{that:this},{}) : {}
  163. // <Container style = { styles.conference }>
  164. /* <WebView source = {{uri:"https://excalidraw.videocorners.com/#room=4zmaf7d5jtcx4pqgruba,4zmaf7BMXbI6tCEiW7rbgy"}}
  165. style = {webview_style}
  166. ></WebView>*/
  167. return (
  168. <Container style = { {...styles.conference,...conference_style} }>
  169. <StatusBar
  170. barStyle = 'light-content'
  171. hidden = { _fullscreenEnabled }
  172. translucent = { _fullscreenEnabled } />
  173. { this._renderContent() }
  174. <Wview_v1 style = { conference_style_v1 }></Wview_v1>
  175. </Container>
  176. );
  177. }
  178. _onClick: () => void;
  179. /**
  180. * Changes the value of the toolboxVisible state, thus allowing us to switch
  181. * between Toolbox and Filmstrip and change their visibility.
  182. *
  183. * @private
  184. * @returns {void}
  185. */
  186. _onClick() {
  187. this._setToolboxVisible(!this.props._toolboxVisible);
  188. }
  189. _onHardwareBackPress: () => boolean;
  190. /**
  191. * Handles a hardware button press for back navigation. Enters Picture-in-Picture mode
  192. * (if supported) or leaves the associated {@code Conference} otherwise.
  193. *
  194. * @returns {boolean} Exiting the app is undesired, so {@code true} is always returned.
  195. */
  196. _onHardwareBackPress() {
  197. let p;
  198. console.log("NativeModules:",NativeModules)
  199. if (this.props._pictureInPictureEnabled) {
  200. const { PictureInPicture } = NativeModules;
  201. console.log("PictureInPicture:",PictureInPicture)
  202. p = PictureInPicture.enterPictureInPicture();
  203. } else {
  204. p = Promise.reject(new Error('PiP not enabled'));
  205. }
  206. p.catch(() => {
  207. this.props.dispatch(appNavigate(undefined));
  208. });
  209. return true;
  210. }
  211. /**
  212. * Renders the conference notification badge if the feature is enabled.
  213. *
  214. * @private
  215. * @returns {React$Node}
  216. */
  217. _renderConferenceNotification() {
  218. const { _calendarEnabled, _reducedUI } = this.props;
  219. return (
  220. _calendarEnabled && !_reducedUI
  221. ? <ConferenceNotification />
  222. : undefined);
  223. }
  224. /**
  225. * Renders the content for the Conference container.
  226. *
  227. * @private
  228. * @returns {React$Element}
  229. */
  230. _renderContent() {
  231. const {
  232. _connecting,
  233. _largeVideoParticipantId,
  234. _reducedUI,
  235. _shouldDisplayTileView
  236. } = this.props;
  237. if (_reducedUI) {
  238. return this._renderContentForReducedUi();
  239. }
  240. return (
  241. <>
  242. {/*
  243. * The LargeVideo is the lowermost stacking layer.
  244. */
  245. _shouldDisplayTileView
  246. ? <TileView onClick = { this._onClick } />
  247. : <LargeVideo onClick = { this._onClick } />
  248. }
  249. {/*
  250. * If there is a ringing call, show the callee's info.
  251. */
  252. <CalleeInfoContainer />
  253. }
  254. {/*
  255. * The activity/loading indicator goes above everything, except
  256. * the toolbox/toolbars and the dialogs.
  257. */
  258. _connecting
  259. && <TintedView>
  260. <LoadingIndicator />
  261. </TintedView>
  262. }
  263. <View
  264. pointerEvents = 'box-none'
  265. style = { styles.toolboxAndFilmstripContainer }>
  266. <Captions onPress = { this._onClick } />
  267. { _shouldDisplayTileView || <Container style = { styles.displayNameContainer }>
  268. <DisplayNameLabel participantId = { _largeVideoParticipantId } />
  269. </Container> }
  270. <LonelyMeetingExperience />
  271. { _shouldDisplayTileView || <><Filmstrip /><Toolbox /></> }
  272. </View>
  273. <SafeAreaView
  274. pointerEvents = 'box-none'
  275. style = { styles.navBarSafeView }>
  276. <NavigationBar />
  277. { this._renderNotificationsContainer() }
  278. <KnockingParticipantList />
  279. </SafeAreaView>
  280. <TestConnectionInfo />
  281. { this._renderConferenceNotification() }
  282. {_shouldDisplayTileView && <Toolbox />}
  283. </>
  284. );
  285. }
  286. /**
  287. * Renders the content for the Conference container when in "reduced UI" mode.
  288. *
  289. * @private
  290. * @returns {React$Element}
  291. */
  292. _renderContentForReducedUi() {
  293. const { _connecting } = this.props;
  294. return (
  295. <>
  296. <LargeVideo onClick = { this._onClick } />
  297. {
  298. _connecting
  299. && <TintedView>
  300. <LoadingIndicator />
  301. </TintedView>
  302. }
  303. </>
  304. );
  305. }
  306. /**
  307. * Renders a container for notifications to be displayed by the
  308. * base/notifications feature.
  309. *
  310. * @private
  311. * @returns {React$Element}
  312. */
  313. _renderNotificationsContainer() {
  314. const notificationsStyle = {};
  315. // In the landscape mode (wide) there's problem with notifications being
  316. // shadowed by the filmstrip rendered on the right. This makes the "x"
  317. // button not clickable. In order to avoid that a margin of the
  318. // filmstrip's size is added to the right.
  319. //
  320. // Pawel: after many attempts I failed to make notifications adjust to
  321. // their contents width because of column and rows being used in the
  322. // flex layout. The only option that seemed to limit the notification's
  323. // size was explicit 'width' value which is not better than the margin
  324. // added here.
  325. const { _aspectRatio, _filmstripVisible } = this.props;
  326. if (_filmstripVisible && _aspectRatio !== ASPECT_RATIO_NARROW) {
  327. notificationsStyle.marginRight = FILMSTRIP_SIZE;
  328. }
  329. return super.renderNotificationsContainer(
  330. {
  331. style: notificationsStyle
  332. }
  333. );
  334. }
  335. _setToolboxVisible: (boolean) => void;
  336. /**
  337. * Dispatches an action changing the visibility of the {@link Toolbox}.
  338. *
  339. * @private
  340. * @param {boolean} visible - Pass {@code true} to show the
  341. * {@code Toolbox} or {@code false} to hide it.
  342. * @returns {void}
  343. */
  344. _setToolboxVisible(visible) {
  345. this.props.dispatch(setToolboxVisible(visible));
  346. }
  347. }
  348. /**
  349. * Maps (parts of) the redux state to the associated {@code Conference}'s props.
  350. *
  351. * @param {Object} state - The redux state.
  352. * @private
  353. * @returns {Props}
  354. */
  355. function _mapStateToProps(state) {
  356. const { connecting, connection } = state['features/base/connection'];
  357. const {
  358. conference,
  359. joining,
  360. membersOnly,
  361. leaving
  362. } = state['features/base/conference'];
  363. const { isOpen } = state['features/participants-pane'];
  364. const { aspectRatio, reducedUI } = state['features/base/responsive-ui'];
  365. // XXX There is a window of time between the successful establishment of the
  366. // XMPP connection and the subsequent commencement of joining the MUC during
  367. // which the app does not appear to be doing anything according to the redux
  368. // state. In order to not toggle the _connecting props during the window of
  369. // time in question, define _connecting as follows:
  370. // - the XMPP connection is connecting, or
  371. // - the XMPP connection is connected and the conference is joining, or
  372. // - the XMPP connection is connected and we have no conference yet, nor we
  373. // are leaving one.
  374. const connecting_
  375. = connecting || (connection && (!membersOnly && (joining || (!conference && !leaving))));
  376. return {
  377. ...abstractMapStateToProps(state),
  378. _aspectRatio: aspectRatio,
  379. _calendarEnabled: isCalendarEnabled(state),
  380. _connecting: Boolean(connecting_),
  381. _filmstripVisible: isFilmstripVisible(state),
  382. _fullscreenEnabled: getFeatureFlag(state, FULLSCREEN_ENABLED, true),
  383. _isParticipantsPaneOpen: isOpen,
  384. _largeVideoParticipantId: state['features/large-video'].participantId,
  385. _pictureInPictureEnabled: getFeatureFlag(state, PIP_ENABLED),
  386. _reducedUI: reducedUI,
  387. _showLobby: getIsLobbyVisible(state),
  388. _toolboxVisible: isToolboxVisible(state)
  389. };
  390. }
  391. export default connect(_mapStateToProps)(Conference);