From 7a9ff9975a5090ea73bcdc2aee77ad6e40179726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Fri, 2 Feb 2018 14:41:30 +0100 Subject: [PATCH] [RN] Adjust Conference for the reduced UI mode --- .../components/Conference.native.js | 26 ++++++++++-- react/features/conference/index.js | 2 + react/features/conference/middleware.js | 40 +++++++++++++++++++ .../features/mobile/full-screen/middleware.js | 5 ++- 4 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 react/features/conference/middleware.js diff --git a/react/features/conference/components/Conference.native.js b/react/features/conference/components/Conference.native.js index a73f140c0..21d9ad297 100644 --- a/react/features/conference/components/Conference.native.js +++ b/react/features/conference/components/Conference.native.js @@ -66,6 +66,13 @@ type Props = { */ _onHardwareBackPress: Function, + /** + * The indicator which determines if we are in reduced UI mode. + * + * @private + */ + _reducedUI: boolean, + /** * The handler which dispatches the (redux) action setToolboxVisible to * show/hide the Toolbox. @@ -192,8 +199,9 @@ class Conference extends Component { {/* * If there is a ringing call, show the callee's info. - */} - + */ + !this.props._reducedUI && + } {/* * The activity/loading indicator goes above everything, except @@ -223,8 +231,9 @@ class Conference extends Component { {/* * The dialogs are in the topmost stacking layers. - */} - + */ + !this.props._reducedUI && + } ); } @@ -367,6 +376,7 @@ function _mapDispatchToProps(dispatch) { 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 @@ -392,6 +402,14 @@ function _mapStateToProps(state) { */ _connecting: Boolean(connecting_), + /** + * The indicator which determines if we are in reduced UI mode. + * + * @private + * @type {boolean} + */ + _reducedUI: reducedUI, + /** * The indicator which determines whether the Toolbox is visible. * diff --git a/react/features/conference/index.js b/react/features/conference/index.js index f502aa446..406ed9037 100644 --- a/react/features/conference/index.js +++ b/react/features/conference/index.js @@ -1,3 +1,5 @@ import './route'; export * from './components'; + +import './middleware'; diff --git a/react/features/conference/middleware.js b/react/features/conference/middleware.js new file mode 100644 index 000000000..6cda7d2be --- /dev/null +++ b/react/features/conference/middleware.js @@ -0,0 +1,40 @@ +// @flow + +import { + CONFERENCE_JOINED, + VIDEO_QUALITY_LEVELS, + setReceiveVideoQuality +} from '../base/conference'; +import { SET_REDUCED_UI } from '../base/responsive-ui'; +import { MiddlewareRegistry } from '../base/redux'; +import { setFilmstripEnabled } from '../filmstrip'; +import { setToolboxEnabled } from '../toolbox'; + +MiddlewareRegistry.register(({ dispatch, getState }) => next => action => { + const result = next(action); + + switch (action.type) { + case CONFERENCE_JOINED: + case SET_REDUCED_UI: { + const state = getState(); + const { audioOnly } = state['features/base/conference']; + const { reducedUI } = state['features/base/responsive-ui']; + + dispatch(setToolboxEnabled(!reducedUI)); + dispatch(setFilmstripEnabled(!reducedUI)); + + // XXX: Currently setting the received video quality will disable + // audio-only mode if engaged, that's why we check for it here. + if (!audioOnly) { + dispatch(setReceiveVideoQuality( + reducedUI + ? VIDEO_QUALITY_LEVELS.LOW + : VIDEO_QUALITY_LEVELS.HIGH)); + } + + break; + } + } + + return result; +}); diff --git a/react/features/mobile/full-screen/middleware.js b/react/features/mobile/full-screen/middleware.js index 787b74543..4ff76db44 100644 --- a/react/features/mobile/full-screen/middleware.js +++ b/react/features/mobile/full-screen/middleware.js @@ -12,6 +12,7 @@ import { } from '../../base/conference'; import { HIDE_DIALOG } from '../../base/dialog'; import { Platform } from '../../base/react'; +import { SET_REDUCED_UI } from '../../base/responsive-ui'; import { MiddlewareRegistry } from '../../base/redux'; /** @@ -34,7 +35,9 @@ MiddlewareRegistry.register(({ getState }) => next => action => { case APP_STATE_CHANGED: case CONFERENCE_WILL_JOIN: case HIDE_DIALOG: - case SET_AUDIO_ONLY: { + case SET_AUDIO_ONLY: + case SET_REDUCED_UI: { + // FIXME: Simplify this by listening to Immediate events. // Check if we just came back from the background and re-enable full // screen mode if necessary. const { appState } = action;