2018-02-26 16:14:46 +00:00
|
|
|
// @flow
|
|
|
|
|
2022-07-28 07:28:29 +00:00
|
|
|
import { Link } from '@react-navigation/native';
|
2018-02-26 16:14:46 +00:00
|
|
|
import React from 'react';
|
2021-11-11 14:32:56 +00:00
|
|
|
import {
|
|
|
|
Alert,
|
|
|
|
NativeModules,
|
2021-11-26 11:54:42 +00:00
|
|
|
Platform,
|
2021-11-11 14:32:56 +00:00
|
|
|
ScrollView,
|
2022-07-28 07:28:29 +00:00
|
|
|
Text, View
|
2021-11-11 14:32:56 +00:00
|
|
|
} from 'react-native';
|
2022-07-28 07:28:29 +00:00
|
|
|
import {
|
|
|
|
Divider,
|
|
|
|
Switch,
|
|
|
|
TextInput,
|
|
|
|
withTheme
|
|
|
|
} from 'react-native-paper';
|
|
|
|
|
|
|
|
import { Avatar } from '../../../base/avatar';
|
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
import JitsiScreen from '../../../base/modal/components/JitsiScreen';
|
|
|
|
import {
|
|
|
|
getLocalParticipant,
|
|
|
|
getParticipantDisplayName
|
|
|
|
} from '../../../base/participants';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { screen } from '../../../mobile/navigation/routes';
|
|
|
|
import { AVATAR_SIZE } from '../../../welcome/components/styles';
|
|
|
|
import { normalizeUserInputURL, isServerURLChangeEnabled } from '../../functions';
|
2018-02-26 16:14:46 +00:00
|
|
|
import {
|
|
|
|
AbstractSettingsView,
|
2019-03-05 17:41:39 +00:00
|
|
|
_mapStateToProps as _abstractMapStateToProps,
|
2020-06-26 09:47:48 +00:00
|
|
|
type Props as AbstractProps
|
2022-07-28 07:28:29 +00:00
|
|
|
} from '../AbstractSettingsView';
|
2020-04-06 15:21:50 +00:00
|
|
|
|
2018-02-26 16:14:46 +00:00
|
|
|
import FormRow from './FormRow';
|
2021-05-11 08:01:45 +00:00
|
|
|
import FormSectionAccordion from './FormSectionAccordion';
|
2022-02-21 14:06:02 +00:00
|
|
|
import styles, {
|
|
|
|
DISABLED_TRACK_COLOR,
|
|
|
|
ENABLED_TRACK_COLOR,
|
|
|
|
THUMB_COLOR
|
|
|
|
} from './styles';
|
2018-02-26 16:14:46 +00:00
|
|
|
|
2022-07-28 07:28:29 +00:00
|
|
|
|
2019-04-02 08:03:01 +00:00
|
|
|
/**
|
|
|
|
* Application information module.
|
|
|
|
*/
|
|
|
|
const { AppInfo } = NativeModules;
|
|
|
|
|
2022-07-28 07:28:29 +00:00
|
|
|
|
2019-10-18 14:30:59 +00:00
|
|
|
type State = {
|
|
|
|
|
2020-03-25 10:10:13 +00:00
|
|
|
/**
|
|
|
|
* State variable for the disable call integration switch.
|
|
|
|
*/
|
|
|
|
disableCallIntegration: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* State variable for the disable p2p switch.
|
|
|
|
*/
|
|
|
|
disableP2P: boolean,
|
|
|
|
|
2020-05-07 21:05:48 +00:00
|
|
|
/**
|
|
|
|
* State variable for the disable crash reporting switch.
|
|
|
|
*/
|
|
|
|
disableCrashReporting: boolean,
|
|
|
|
|
2020-03-25 10:10:13 +00:00
|
|
|
/**
|
|
|
|
* State variable for the display name field.
|
|
|
|
*/
|
|
|
|
displayName: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* State variable for the email field.
|
|
|
|
*/
|
|
|
|
email: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* State variable for the server URL field.
|
|
|
|
*/
|
|
|
|
serverURL: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* State variable for the start with audio muted switch.
|
|
|
|
*/
|
|
|
|
startWithAudioMuted: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* State variable for the start with video muted switch.
|
|
|
|
*/
|
2021-05-11 08:01:45 +00:00
|
|
|
startWithVideoMuted: boolean
|
2019-10-18 14:30:59 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 09:47:48 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of
|
|
|
|
* {@link SettingsView}.
|
|
|
|
*/
|
|
|
|
type Props = AbstractProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag indicating if URL can be changed by user.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
*/
|
2021-05-11 08:01:45 +00:00
|
|
|
_serverURLChangeEnabled: boolean,
|
|
|
|
|
2022-07-28 07:28:29 +00:00
|
|
|
/**
|
|
|
|
* Avatar label.
|
|
|
|
*/
|
|
|
|
avatarLabel: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the local participant.
|
|
|
|
*/
|
|
|
|
localParticipantId: string,
|
|
|
|
|
2021-11-11 14:32:56 +00:00
|
|
|
/**
|
|
|
|
* Default prop for navigating between screen components(React Navigation).
|
|
|
|
*/
|
|
|
|
navigation: Object,
|
|
|
|
|
2022-07-28 07:28:29 +00:00
|
|
|
/**
|
|
|
|
* Callback to be invoked when settings screen is focused.
|
|
|
|
*/
|
|
|
|
onSettingsScreenFocused: Function,
|
|
|
|
|
2021-05-11 08:01:45 +00:00
|
|
|
/**
|
|
|
|
* Theme used for styles.
|
|
|
|
*/
|
|
|
|
theme: Object
|
2020-06-26 09:47:48 +00:00
|
|
|
}
|
|
|
|
|
2018-02-26 16:14:46 +00:00
|
|
|
/**
|
|
|
|
* The native container rendering the app settings page.
|
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments AbstractSettingsView
|
2018-02-26 16:14:46 +00:00
|
|
|
*/
|
2019-10-18 14:30:59 +00:00
|
|
|
class SettingsView extends AbstractSettingsView<Props, State> {
|
2018-02-26 16:14:46 +00:00
|
|
|
_urlField: Object;
|
|
|
|
|
|
|
|
/**
|
2022-07-28 07:28:29 +00:00
|
|
|
*
|
2018-02-26 16:14:46 +00:00
|
|
|
* Initializes a new {@code SettingsView} instance.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2020-03-25 10:10:13 +00:00
|
|
|
const {
|
|
|
|
disableCallIntegration,
|
2020-05-07 21:05:48 +00:00
|
|
|
disableCrashReporting,
|
2020-03-25 10:10:13 +00:00
|
|
|
disableP2P,
|
|
|
|
displayName,
|
|
|
|
email,
|
|
|
|
serverURL,
|
|
|
|
startWithAudioMuted,
|
|
|
|
startWithVideoMuted
|
|
|
|
} = props._settings || {};
|
2018-02-26 16:14:46 +00:00
|
|
|
|
2019-10-18 14:30:59 +00:00
|
|
|
this.state = {
|
2020-03-25 10:10:13 +00:00
|
|
|
disableCallIntegration,
|
2020-05-07 21:05:48 +00:00
|
|
|
disableCrashReporting,
|
2020-03-25 10:10:13 +00:00
|
|
|
disableP2P,
|
|
|
|
displayName,
|
|
|
|
email,
|
|
|
|
serverURL,
|
|
|
|
startWithAudioMuted,
|
|
|
|
startWithVideoMuted
|
2019-10-18 14:30:59 +00:00
|
|
|
};
|
|
|
|
|
2018-02-26 16:14:46 +00:00
|
|
|
// Bind event handlers so they are only bound once per instance.
|
|
|
|
this._onBlurServerURL = this._onBlurServerURL.bind(this);
|
2020-04-06 15:21:50 +00:00
|
|
|
this._onClose = this._onClose.bind(this);
|
2019-10-18 14:30:59 +00:00
|
|
|
this._onDisableCallIntegration = this._onDisableCallIntegration.bind(this);
|
2020-05-07 21:05:48 +00:00
|
|
|
this._onDisableCrashReporting = this._onDisableCrashReporting.bind(this);
|
2019-10-18 14:30:59 +00:00
|
|
|
this._onDisableP2P = this._onDisableP2P.bind(this);
|
2018-02-26 16:14:46 +00:00
|
|
|
this._setURLFieldReference = this._setURLFieldReference.bind(this);
|
|
|
|
this._showURLAlert = this._showURLAlert.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}, renders the settings page.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2021-05-11 08:01:45 +00:00
|
|
|
const {
|
|
|
|
disableCallIntegration,
|
|
|
|
disableCrashReporting,
|
|
|
|
disableP2P,
|
|
|
|
displayName,
|
|
|
|
email,
|
|
|
|
serverURL,
|
|
|
|
startWithAudioMuted,
|
|
|
|
startWithVideoMuted
|
|
|
|
} = this.state;
|
|
|
|
const { palette } = this.props.theme;
|
2020-04-06 15:21:50 +00:00
|
|
|
|
2022-02-21 14:06:02 +00:00
|
|
|
const textInputTheme = {
|
|
|
|
colors: {
|
|
|
|
background: palette.ui01,
|
|
|
|
placeholder: palette.text01,
|
|
|
|
primary: palette.screen01Header,
|
|
|
|
underlineColor: 'transparent',
|
|
|
|
text: palette.text01
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-26 16:14:46 +00:00
|
|
|
return (
|
2021-11-11 14:32:56 +00:00
|
|
|
<JitsiScreen
|
2022-07-28 07:28:29 +00:00
|
|
|
safeAreaInsets = { [ 'bottom', 'left', 'right' ] }
|
2021-11-11 14:32:56 +00:00
|
|
|
style = { styles.settingsViewContainer }>
|
2020-04-06 15:21:50 +00:00
|
|
|
<ScrollView>
|
2022-07-28 07:28:29 +00:00
|
|
|
<View style = { styles.avatarContainer }>
|
|
|
|
<Avatar
|
|
|
|
participantId = { this.props.localParticipantId }
|
|
|
|
size = { AVATAR_SIZE } />
|
|
|
|
<Text style = { styles.avatarLabel }>
|
|
|
|
{ this.props.avatarLabel }
|
|
|
|
</Text>
|
|
|
|
</View>
|
2021-05-11 08:01:45 +00:00
|
|
|
<FormSectionAccordion
|
|
|
|
label = 'settingsView.profileSection'>
|
2020-04-06 15:21:50 +00:00
|
|
|
<TextInput
|
|
|
|
autoCorrect = { false }
|
2021-05-11 08:01:45 +00:00
|
|
|
label = { this.props.t('settingsView.displayName') }
|
|
|
|
mode = 'outlined'
|
2020-04-06 15:21:50 +00:00
|
|
|
onChangeText = { this._onChangeDisplayName }
|
2022-06-10 12:50:12 +00:00
|
|
|
placeholder = { this.props.t('settingsView.displayNamePlaceholderText') }
|
2021-10-01 12:09:23 +00:00
|
|
|
spellCheck = { false }
|
2021-05-11 08:01:45 +00:00
|
|
|
style = { styles.textInputContainer }
|
2020-07-21 15:06:41 +00:00
|
|
|
textContentType = { 'name' } // iOS only
|
2022-02-21 14:06:02 +00:00
|
|
|
theme = { textInputTheme }
|
2020-04-06 15:21:50 +00:00
|
|
|
value = { displayName } />
|
2021-05-11 08:01:45 +00:00
|
|
|
<Divider style = { styles.fieldSeparator } />
|
2020-04-06 15:21:50 +00:00
|
|
|
<TextInput
|
|
|
|
autoCapitalize = 'none'
|
|
|
|
autoCorrect = { false }
|
|
|
|
keyboardType = { 'email-address' }
|
2021-05-11 08:01:45 +00:00
|
|
|
label = { this.props.t('settingsView.email') }
|
|
|
|
mode = 'outlined'
|
2020-04-06 15:21:50 +00:00
|
|
|
onChangeText = { this._onChangeEmail }
|
|
|
|
placeholder = 'email@example.com'
|
2021-10-01 12:09:23 +00:00
|
|
|
spellCheck = { false }
|
2021-05-11 08:01:45 +00:00
|
|
|
style = { styles.textInputContainer }
|
2020-07-21 15:06:41 +00:00
|
|
|
textContentType = { 'emailAddress' } // iOS only
|
2022-02-21 14:06:02 +00:00
|
|
|
theme = { textInputTheme }
|
2020-04-06 15:21:50 +00:00
|
|
|
value = { email } />
|
2021-05-11 08:01:45 +00:00
|
|
|
</FormSectionAccordion>
|
|
|
|
<FormSectionAccordion
|
|
|
|
label = 'settingsView.conferenceSection'>
|
2020-04-06 15:21:50 +00:00
|
|
|
<TextInput
|
|
|
|
autoCapitalize = 'none'
|
|
|
|
autoCorrect = { false }
|
2020-06-26 09:47:48 +00:00
|
|
|
editable = { this.props._serverURLChangeEnabled }
|
2020-07-21 15:06:41 +00:00
|
|
|
keyboardType = { 'url' }
|
2021-05-11 08:01:45 +00:00
|
|
|
label = { this.props.t('settingsView.serverURL') }
|
|
|
|
mode = 'outlined'
|
2020-04-06 15:21:50 +00:00
|
|
|
onBlur = { this._onBlurServerURL }
|
|
|
|
onChangeText = { this._onChangeServerURL }
|
|
|
|
placeholder = { this.props._serverURL }
|
2021-10-01 12:09:23 +00:00
|
|
|
spellCheck = { false }
|
2021-05-11 08:01:45 +00:00
|
|
|
style = { styles.textInputContainer }
|
2020-07-21 15:06:41 +00:00
|
|
|
textContentType = { 'URL' } // iOS only
|
2022-02-21 14:06:02 +00:00
|
|
|
theme = { textInputTheme }
|
2020-04-06 15:21:50 +00:00
|
|
|
value = { serverURL } />
|
2021-05-11 08:01:45 +00:00
|
|
|
<Divider style = { styles.fieldSeparator } />
|
|
|
|
<FormRow
|
|
|
|
label = 'settingsView.startWithAudioMuted'>
|
|
|
|
<Switch
|
|
|
|
onValueChange = { this._onStartAudioMutedChange }
|
|
|
|
thumbColor = { THUMB_COLOR }
|
2022-02-21 14:06:02 +00:00
|
|
|
trackColor = {{
|
2022-02-22 16:39:06 +00:00
|
|
|
true: ENABLED_TRACK_COLOR,
|
|
|
|
false: DISABLED_TRACK_COLOR
|
2022-02-21 14:06:02 +00:00
|
|
|
}}
|
2021-05-11 08:01:45 +00:00
|
|
|
value = { startWithAudioMuted } />
|
|
|
|
</FormRow>
|
|
|
|
<Divider style = { styles.fieldSeparator } />
|
|
|
|
<FormRow label = 'settingsView.startWithVideoMuted'>
|
|
|
|
<Switch
|
|
|
|
onValueChange = { this._onStartVideoMutedChange }
|
|
|
|
thumbColor = { THUMB_COLOR }
|
2022-02-21 14:06:02 +00:00
|
|
|
trackColor = {{
|
2022-02-22 16:39:06 +00:00
|
|
|
true: ENABLED_TRACK_COLOR,
|
|
|
|
false: DISABLED_TRACK_COLOR
|
2022-02-21 14:06:02 +00:00
|
|
|
}}
|
2021-05-11 08:01:45 +00:00
|
|
|
value = { startWithVideoMuted } />
|
|
|
|
</FormRow>
|
|
|
|
</FormSectionAccordion>
|
|
|
|
<FormSectionAccordion
|
2022-07-28 07:28:29 +00:00
|
|
|
label = 'settingsView.links'>
|
|
|
|
<Link
|
|
|
|
style = { styles.sectionLink }
|
|
|
|
to = {{ screen: screen.settings.links.help }}>
|
|
|
|
{ this.props.t('settingsView.help') }
|
|
|
|
</Link>
|
|
|
|
<Divider style = { styles.fieldSeparator } />
|
|
|
|
<Link
|
|
|
|
style = { styles.sectionLink }
|
|
|
|
to = {{ screen: screen.settings.links.terms }}>
|
|
|
|
{ this.props.t('settingsView.terms') }
|
|
|
|
</Link>
|
|
|
|
<Divider style = { styles.fieldSeparator } />
|
|
|
|
<Link
|
|
|
|
style = { styles.sectionLink }
|
|
|
|
to = {{ screen: screen.settings.links.privacy }}>
|
|
|
|
{ this.props.t('settingsView.privacy') }
|
|
|
|
</Link>
|
|
|
|
</FormSectionAccordion>
|
|
|
|
<FormSectionAccordion
|
2021-05-11 08:01:45 +00:00
|
|
|
label = 'settingsView.buildInfoSection'>
|
|
|
|
<FormRow
|
|
|
|
label = 'settingsView.version'>
|
2022-02-21 14:06:02 +00:00
|
|
|
<Text style = { styles.text }>
|
2021-05-11 08:01:45 +00:00
|
|
|
{`${AppInfo.version} build ${AppInfo.buildNumber}`}
|
|
|
|
</Text>
|
|
|
|
</FormRow>
|
|
|
|
</FormSectionAccordion>
|
|
|
|
<FormSectionAccordion
|
|
|
|
label = 'settingsView.advanced'>
|
2021-11-26 11:54:42 +00:00
|
|
|
{ Platform.OS === 'android' && (
|
|
|
|
<>
|
|
|
|
<FormRow
|
|
|
|
label = 'settingsView.disableCallIntegration'>
|
|
|
|
<Switch
|
|
|
|
onValueChange = { this._onDisableCallIntegration }
|
|
|
|
thumbColor = { THUMB_COLOR }
|
2022-02-21 14:06:02 +00:00
|
|
|
trackColor = {{
|
2022-02-22 16:39:06 +00:00
|
|
|
true: ENABLED_TRACK_COLOR,
|
|
|
|
false: DISABLED_TRACK_COLOR
|
2022-02-21 14:06:02 +00:00
|
|
|
}}
|
2021-11-26 11:54:42 +00:00
|
|
|
value = { disableCallIntegration } />
|
|
|
|
</FormRow>
|
|
|
|
<Divider style = { styles.fieldSeparator } />
|
|
|
|
</>
|
|
|
|
)}
|
2021-05-11 08:01:45 +00:00
|
|
|
<FormRow
|
|
|
|
label = 'settingsView.disableP2P'>
|
|
|
|
<Switch
|
|
|
|
onValueChange = { this._onDisableP2P }
|
|
|
|
thumbColor = { THUMB_COLOR }
|
2022-02-21 14:06:02 +00:00
|
|
|
trackColor = {{
|
2022-02-22 16:39:06 +00:00
|
|
|
true: ENABLED_TRACK_COLOR,
|
|
|
|
false: DISABLED_TRACK_COLOR
|
|
|
|
}}
|
2021-05-11 08:01:45 +00:00
|
|
|
value = { disableP2P } />
|
|
|
|
</FormRow>
|
|
|
|
<Divider style = { styles.fieldSeparator } />
|
|
|
|
{AppInfo.GOOGLE_SERVICES_ENABLED && (
|
|
|
|
<FormRow
|
|
|
|
fieldSeparator = { true }
|
|
|
|
label = 'settingsView.disableCrashReporting'>
|
|
|
|
<Switch
|
|
|
|
onValueChange = { this._onDisableCrashReporting }
|
|
|
|
thumbColor = { THUMB_COLOR }
|
2022-02-21 14:06:02 +00:00
|
|
|
trackColor = {{
|
2022-02-22 16:39:06 +00:00
|
|
|
true: ENABLED_TRACK_COLOR,
|
|
|
|
false: DISABLED_TRACK_COLOR
|
2022-02-21 14:06:02 +00:00
|
|
|
}}
|
2021-05-11 08:01:45 +00:00
|
|
|
value = { disableCrashReporting } />
|
|
|
|
</FormRow>
|
|
|
|
)}
|
|
|
|
</FormSectionAccordion>
|
2020-04-06 15:21:50 +00:00
|
|
|
</ScrollView>
|
2021-11-11 14:32:56 +00:00
|
|
|
</JitsiScreen>
|
2018-02-26 16:14:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onBlurServerURL: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler the server URL lose focus event. Here we validate the server URL
|
|
|
|
* and update it to the normalized version, or show an error if incorrect.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onBlurServerURL() {
|
|
|
|
this._processServerURL(false /* hideOnSuccess */);
|
|
|
|
}
|
|
|
|
|
2020-03-25 10:10:13 +00:00
|
|
|
/**
|
|
|
|
* Callback to update the display name.
|
|
|
|
*
|
|
|
|
* @param {string} displayName - The new value to set.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onChangeDisplayName(displayName) {
|
|
|
|
super._onChangeDisplayName(displayName);
|
|
|
|
this.setState({
|
|
|
|
displayName
|
|
|
|
});
|
|
|
|
}
|
2018-02-26 16:14:46 +00:00
|
|
|
|
2020-03-25 10:10:13 +00:00
|
|
|
/**
|
|
|
|
* Callback to update the email.
|
|
|
|
*
|
|
|
|
* @param {string} email - The new value to set.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onChangeEmail(email) {
|
|
|
|
super._onChangeEmail(email);
|
|
|
|
this.setState({
|
|
|
|
email
|
|
|
|
});
|
|
|
|
}
|
2018-02-26 16:14:46 +00:00
|
|
|
|
2020-03-25 10:10:13 +00:00
|
|
|
/**
|
|
|
|
* Callback to update the server URL.
|
|
|
|
*
|
|
|
|
* @param {string} serverURL - The new value to set.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onChangeServerURL(serverURL) {
|
|
|
|
super._onChangeServerURL(serverURL);
|
|
|
|
this.setState({
|
|
|
|
serverURL
|
|
|
|
});
|
|
|
|
}
|
2018-02-26 16:14:46 +00:00
|
|
|
|
2019-10-18 14:30:59 +00:00
|
|
|
_onDisableCallIntegration: (boolean) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the disable call integration change event.
|
|
|
|
*
|
2020-03-25 10:10:13 +00:00
|
|
|
* @param {boolean} disableCallIntegration - The new value
|
2019-10-18 14:30:59 +00:00
|
|
|
* option.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2020-03-25 10:10:13 +00:00
|
|
|
_onDisableCallIntegration(disableCallIntegration) {
|
2019-10-18 14:30:59 +00:00
|
|
|
this._updateSettings({
|
2020-03-25 10:10:13 +00:00
|
|
|
disableCallIntegration
|
|
|
|
});
|
|
|
|
this.setState({
|
|
|
|
disableCallIntegration
|
2019-10-18 14:30:59 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_onDisableP2P: (boolean) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the disable P2P change event.
|
|
|
|
*
|
2020-03-25 10:10:13 +00:00
|
|
|
* @param {boolean} disableP2P - The new value
|
2019-10-18 14:30:59 +00:00
|
|
|
* option.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2020-03-25 10:10:13 +00:00
|
|
|
_onDisableP2P(disableP2P) {
|
2019-10-18 14:30:59 +00:00
|
|
|
this._updateSettings({
|
2020-03-25 10:10:13 +00:00
|
|
|
disableP2P
|
|
|
|
});
|
|
|
|
this.setState({
|
|
|
|
disableP2P
|
2019-10-18 14:30:59 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-05-07 21:05:48 +00:00
|
|
|
_onDisableCrashReporting: (boolean) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles the disable crash reporting change event.
|
|
|
|
*
|
|
|
|
* @param {boolean} disableCrashReporting - The new value
|
|
|
|
* option.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onDisableCrashReporting(disableCrashReporting) {
|
|
|
|
if (disableCrashReporting) {
|
|
|
|
this._showCrashReportingDisableAlert();
|
|
|
|
} else {
|
|
|
|
this._disableCrashReporting(disableCrashReporting);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-06 15:21:50 +00:00
|
|
|
_onClose: () => void;
|
2018-02-26 16:14:46 +00:00
|
|
|
|
|
|
|
/**
|
2020-04-06 15:21:50 +00:00
|
|
|
* Callback to be invoked on closing the modal. Also invokes normalizeUserInputURL to validate
|
2018-02-26 16:14:46 +00:00
|
|
|
* the URL entered by the user.
|
|
|
|
*
|
2020-04-06 15:21:50 +00:00
|
|
|
* @returns {boolean} - True if the modal can be closed.
|
2018-02-26 16:14:46 +00:00
|
|
|
*/
|
2020-04-06 15:21:50 +00:00
|
|
|
_onClose() {
|
|
|
|
return this._processServerURL(true /* hideOnSuccess */);
|
2018-02-26 16:14:46 +00:00
|
|
|
}
|
|
|
|
|
2020-03-25 10:10:13 +00:00
|
|
|
/**
|
|
|
|
* Callback to update the start with audio muted value.
|
|
|
|
*
|
|
|
|
* @param {boolean} startWithAudioMuted - The new value to set.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onStartAudioMutedChange(startWithAudioMuted) {
|
|
|
|
super._onStartAudioMutedChange(startWithAudioMuted);
|
|
|
|
this.setState({
|
|
|
|
startWithAudioMuted
|
|
|
|
});
|
|
|
|
}
|
2018-02-26 16:14:46 +00:00
|
|
|
|
2020-03-25 10:10:13 +00:00
|
|
|
/**
|
|
|
|
* Callback to update the start with video muted value.
|
|
|
|
*
|
|
|
|
* @param {boolean} startWithVideoMuted - The new value to set.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onStartVideoMutedChange(startWithVideoMuted) {
|
|
|
|
super._onStartVideoMutedChange(startWithVideoMuted);
|
|
|
|
this.setState({
|
|
|
|
startWithVideoMuted
|
|
|
|
});
|
|
|
|
}
|
2018-02-26 16:14:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes the server URL. It normalizes it and an error alert is
|
|
|
|
* displayed in case it's incorrect.
|
|
|
|
*
|
|
|
|
* @param {boolean} hideOnSuccess - True if the dialog should be hidden if
|
|
|
|
* normalization / validation succeeds, false otherwise.
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_processServerURL(hideOnSuccess: boolean) {
|
2018-04-12 19:58:20 +00:00
|
|
|
const { serverURL } = this.props._settings;
|
2018-02-26 16:14:46 +00:00
|
|
|
const normalizedURL = normalizeUserInputURL(serverURL);
|
|
|
|
|
|
|
|
if (normalizedURL === null) {
|
|
|
|
this._showURLAlert();
|
2020-04-06 15:21:50 +00:00
|
|
|
|
|
|
|
return false;
|
2018-02-26 16:14:46 +00:00
|
|
|
}
|
2020-04-06 15:21:50 +00:00
|
|
|
|
|
|
|
this._onChangeServerURL(normalizedURL);
|
|
|
|
|
|
|
|
return hideOnSuccess;
|
2018-02-26 16:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_setURLFieldReference: (React$ElementRef<*> | null) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores a reference to the URL field for later use.
|
|
|
|
*
|
|
|
|
* @param {Object} component - The field component.
|
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_setURLFieldReference(component) {
|
|
|
|
this._urlField = component;
|
|
|
|
}
|
|
|
|
|
|
|
|
_showURLAlert: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows an alert telling the user that the URL he/she entered was invalid.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_showURLAlert() {
|
|
|
|
const { t } = this.props;
|
|
|
|
|
|
|
|
Alert.alert(
|
|
|
|
t('settingsView.alertTitle'),
|
|
|
|
t('settingsView.alertURLText'),
|
|
|
|
[
|
|
|
|
{
|
|
|
|
onPress: () => this._urlField.focus(),
|
|
|
|
text: t('settingsView.alertOk')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
2019-10-18 14:30:59 +00:00
|
|
|
|
2020-05-07 21:05:48 +00:00
|
|
|
/**
|
|
|
|
* Shows an alert warning the user about disabling crash reporting.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_showCrashReportingDisableAlert() {
|
|
|
|
const { t } = this.props;
|
|
|
|
|
|
|
|
Alert.alert(
|
|
|
|
t('settingsView.alertTitle'),
|
|
|
|
t('settingsView.disableCrashReportingWarning'),
|
|
|
|
[
|
|
|
|
{
|
|
|
|
onPress: () => this._disableCrashReporting(true),
|
|
|
|
text: t('settingsView.alertOk')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: t('settingsView.alertCancel')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-10-18 14:30:59 +00:00
|
|
|
_updateSettings: (Object) => void;
|
2020-05-07 21:05:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the settings and sets state for disableCrashReporting.
|
|
|
|
*
|
|
|
|
* @param {boolean} disableCrashReporting - Whether crash reporting is disabled or not.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_disableCrashReporting(disableCrashReporting) {
|
|
|
|
this._updateSettings({ disableCrashReporting });
|
|
|
|
this.setState({ disableCrashReporting });
|
|
|
|
}
|
2018-02-26 16:14:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-05 17:41:39 +00:00
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
2020-04-06 15:21:50 +00:00
|
|
|
* @returns {Props}
|
2019-03-05 17:41:39 +00:00
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
2022-07-28 07:28:29 +00:00
|
|
|
const localParticipant = getLocalParticipant(state);
|
|
|
|
const localParticipantId = localParticipant?.id;
|
|
|
|
const avatarLabel = localParticipant && getParticipantDisplayName(state, localParticipantId);
|
|
|
|
|
2019-03-05 17:41:39 +00:00
|
|
|
return {
|
2020-06-26 09:47:48 +00:00
|
|
|
..._abstractMapStateToProps(state),
|
2022-07-28 07:28:29 +00:00
|
|
|
_serverURLChangeEnabled: isServerURLChangeEnabled(state),
|
|
|
|
avatarLabel,
|
|
|
|
localParticipantId
|
2019-03-05 17:41:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-11 08:01:45 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(withTheme(SettingsView)));
|