import React, { useEffect, useState } from 'react'; import { Switch } from 'react-native'; import PropTypes from 'prop-types'; import AsyncStorage from '@react-native-community/async-storage'; import { useSelector } from 'react-redux'; import { SWITCH_TRACK_COLOR } from '../constants/colors'; import StatusBar from '../containers/StatusBar'; import * as List from '../containers/List'; import I18n from '../i18n'; import { CRASH_REPORT_KEY, ANALYTICS_EVENTS_KEY } from '../lib/rocketchat'; import { logEvent, events, toggleCrashErrorsReport, toggleAnalyticsEventsReport, getReportCrashErrorsValue, getReportAnalyticsEventsValue } from '../utils/log'; import SafeAreaView from '../containers/SafeAreaView'; import { isFDroidBuild } from '../constants/environment'; const SecurityPrivacyView = ({ navigation }) => { const [crashReportState, setCrashReportState] = useState(getReportCrashErrorsValue()); const [analyticsEventsState, setAnalyticsEventsState] = useState(getReportAnalyticsEventsValue()); const e2eEnabled = useSelector(state => state.settings.E2E_Enable); useEffect(() => { navigation.setOptions({ title: I18n.t('Security_and_privacy') }); }, []); const toggleCrashReport = value => { logEvent(events.SE_TOGGLE_CRASH_REPORT); AsyncStorage.setItem(CRASH_REPORT_KEY, JSON.stringify(value)); setCrashReportState(value); toggleCrashErrorsReport(value); }; const toggleAnalyticsEvents = value => { logEvent(events.SE_TOGGLE_ANALYTICS_EVENTS); AsyncStorage.setItem(ANALYTICS_EVENTS_KEY, JSON.stringify(value)); setAnalyticsEventsState(value); toggleAnalyticsEventsReport(value); }; const navigateToScreen = screen => { logEvent(events[`SP_GO_${screen.replace('View', '').toUpperCase()}`]); navigation.navigate(screen); }; return ( {e2eEnabled ? ( <> navigateToScreen('E2EEncryptionSecurityView')} testID='security-privacy-view-e2e-encryption' /> ) : null} navigateToScreen('ScreenLockConfigView')} testID='security-privacy-view-screen-lock' /> {!isFDroidBuild ? ( <> ( )} /> ( )} /> ) : null} ); }; SecurityPrivacyView.propTypes = { navigation: PropTypes.object }; export default SecurityPrivacyView;