From 28fb6f4a384be28370c1f8078664fa443f05cb00 Mon Sep 17 00:00:00 2001 From: Stefan Otto Date: Wed, 20 May 2020 11:21:19 +0200 Subject: [PATCH] advanced audio settings as collapsed list --- app/src/actions/settingsActions.js | 6 - app/src/components/Settings/MediaSettings.js | 241 +++++++++++-------- app/src/reducers/settings.js | 7 - 3 files changed, 138 insertions(+), 116 deletions(-) diff --git a/app/src/actions/settingsActions.js b/app/src/actions/settingsActions.js index a2bd055..0a4d626 100644 --- a/app/src/actions/settingsActions.js +++ b/app/src/actions/settingsActions.js @@ -53,12 +53,6 @@ export const toggleShowNotifications = () => type : 'TOGGLE_SHOW_NOTIFICATIONS' }); -export const setShowAdvancedAudio = (showAdvancedAudio) => - ({ - type : 'SET_SHOW_ADVANCED_AUDIO', - payload : { showAdvancedAudio } - }); - export const setEchoCancellation = (echoCancellation) => ({ type : 'SET_ECHO_CANCELLATION', diff --git a/app/src/components/Settings/MediaSettings.js b/app/src/components/Settings/MediaSettings.js index 9d48a42..bc549b8 100644 --- a/app/src/components/Settings/MediaSettings.js +++ b/app/src/components/Settings/MediaSettings.js @@ -12,9 +12,15 @@ import FormHelperText from '@material-ui/core/FormHelperText'; import FormControl from '@material-ui/core/FormControl'; import FormControlLabel from '@material-ui/core/FormControlLabel'; import Select from '@material-ui/core/Select'; -import Checkbox from '@material-ui/core/Checkbox'; import Slider from '@material-ui/core/Slider'; import Typography from '@material-ui/core/Typography'; +import Collapse from '@material-ui/core/Collapse'; +import List from '@material-ui/core/List'; +import ListItem from '@material-ui/core/ListItem'; +import ListItemText from '@material-ui/core/ListItemText'; +import ExpandLess from '@material-ui/icons/ExpandLess'; +import ExpandMore from '@material-ui/icons/ExpandMore'; +import Switch from '@material-ui/core/Switch'; const NoiseSlider = withStyles( { @@ -52,6 +58,19 @@ const styles = (theme) => ({ { height : theme.spacing(3) }, + root : { + width : '100%', + backgroundColor : theme.palette.background.paper + }, + switchLabel : { + justifyContent : 'space-between', + flex : 'auto', + display : 'flex' + }, + nested : { + paddingLeft : theme.spacing(2), + display : 'block' + }, formControl : { display : 'flex' @@ -59,7 +78,6 @@ const styles = (theme) => ({ }); const MediaSettings = ({ - setShowAdvancedAudio, setEchoCancellation, setAutoGainControl, setNoiseSuppression, @@ -130,6 +148,13 @@ const MediaSettings = ({ else audioOutputDevices = []; + const [ open, setOpen ] = React.useState(true); + + const advancedAudioSettings = () => + { + setOpen(!open); + }; + return (
@@ -288,109 +313,121 @@ const MediaSettings = ({
} -
- - { - setShowAdvancedAudio(event.target.checked); - }} - />} - label={intl.formatMessage({ + + + - - {settings.showAdvancedAudio ? -
- + /> + {open ? : } + + + + + + { + setEchoCancellation(event.target.checked); + roomClient.changeAudioDevice(settings.selectedAudioDevice); + }} + />} + labelPlacement='start' + label={intl.formatMessage({ + id : 'settings.echoCancellation', + defaultMessage : 'Echo cancellation' + })} + /> + + + + { + setAutoGainControl(event.target.checked); + roomClient.changeAudioDevice(settings.selectedAudioDevice); + }} + />} + labelPlacement='start' + label={intl.formatMessage({ + id : 'settings.autoGainControl', + defaultMessage : 'Auto gain control' + })} + /> + + + + { + setNoiseSuppression(event.target.checked); + roomClient.changeAudioDevice(settings.selectedAudioDevice); + }} + />} + labelPlacement='start' + label={intl.formatMessage({ + id : 'settings.noiseSuppression', + defaultMessage : 'Noise suppression' + })} + /> + + + + { + setVoiceActivatedUnmute(event.target.checked); + }} + />} + labelPlacement='start' + label={intl.formatMessage({ + id : 'settings.voiceActivatedUnmute', + defaultMessage : 'Voice activated unmute' + })} + /> + + +
+ { - setEchoCancellation(event.target.checked); - roomClient.changeAudioDevice(settings.selectedAudioDevice); - }} - />} - label={intl.formatMessage({ - id : 'settings.echoCancellation', - defaultMessage : 'Echo cancellation' - })} - /> - - { - setAutoGainControl(event.target.checked); - roomClient.changeAudioDevice(settings.selectedAudioDevice); - }} - />} - label={intl.formatMessage({ - id : 'settings.autoGainControl', - defaultMessage : 'Auto gain control' - })} - /> - - { - setNoiseSuppression(event.target.checked); - roomClient.changeAudioDevice(settings.selectedAudioDevice); - }} - />} - label={intl.formatMessage({ - id : 'settings.noiseSuppression', - defaultMessage : 'Noise suppression' - })} - /> - - { - setVoiceActivatedUnmute(event.target.checked); - }} - />} - label={intl.formatMessage({ - id : 'settings.voiceActivatedUnmute', - defaultMessage : 'Voice activated unmute' - })} - /> -
- - { - intl.formatMessage({ - id : 'settings.noiseThreshold', - defaultMessage : 'Noise threshold:' - }) - } - - - { - roomClient._setNoiseThreshold(value); - }} - marks={[ { value: volume, label: 'level' } ]} - /> -
- - : null - } + intl.formatMessage({ + id : 'settings.noiseThreshold', + defaultMessage : 'Noise threshold:' + }) + } + + + { + roomClient._setNoiseThreshold(value); + }} + marks={[ { value: volume, label: volume+'dB' } ]} + /> +
+ + + + ); }; @@ -398,7 +435,6 @@ const MediaSettings = ({ MediaSettings.propTypes = { roomClient : PropTypes.any.isRequired, - setShowAdvancedAudio : PropTypes.func.isRequired, setEchoCancellation : PropTypes.func.isRequired, setAutoGainControl : PropTypes.func.isRequired, setNoiseSuppression : PropTypes.func.isRequired, @@ -419,7 +455,6 @@ const mapStateToProps = (state) => }; const mapDispatchToProps = { - setShowAdvancedAudio : settingsActions.setShowAdvancedAudio, setEchoCancellation : settingsActions.setEchoCancellation, setAutoGainControl : settingsActions.setAutoGainControl, setNoiseSuppression : settingsActions.setNoiseSuppression, diff --git a/app/src/reducers/settings.js b/app/src/reducers/settings.js index 0421f0f..051b642 100644 --- a/app/src/reducers/settings.js +++ b/app/src/reducers/settings.js @@ -7,7 +7,6 @@ const initialState = sampleRate : 48000, channelCount : 1, volume : 1.0, - showAdvancedAudio : false, autoGainControl : false, echoCancellation : true, noiseSuppression : true, @@ -80,12 +79,6 @@ const settings = (state = initialState, action) => return { ...state, volume }; } - case 'SET_SHOW_ADVANCED_AUDIO': - { - const { showAdvancedAudio } = action.payload; - - return { ...state, showAdvancedAudio }; - } case 'SET_AUTO_GAIN_CONTROL': {