2021-08-23 14:15:01 +00:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2020-10-30 18:31:04 +00:00
|
|
|
import { Switch } from 'react-native';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import AsyncStorage from '@react-native-community/async-storage';
|
2021-08-23 14:15:01 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
2020-10-30 18:31:04 +00:00
|
|
|
|
|
|
|
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 {
|
2021-08-23 14:15:01 +00:00
|
|
|
logEvent, events, toggleCrashErrorsReport, toggleAnalyticsEventsReport, getReportCrashErrorsValue, getReportAnalyticsEventsValue
|
2020-10-30 18:31:04 +00:00
|
|
|
} from '../utils/log';
|
|
|
|
import SafeAreaView from '../containers/SafeAreaView';
|
|
|
|
import { isFDroidBuild } from '../constants/environment';
|
|
|
|
|
2021-08-23 14:15:01 +00:00
|
|
|
const SecurityPrivacyView = ({ navigation }) => {
|
|
|
|
const [crashReportState, setCrashReportState] = useState(getReportCrashErrorsValue());
|
|
|
|
const [analyticsEventsState, setAnalyticsEventsState] = useState(getReportAnalyticsEventsValue());
|
2020-10-30 18:31:04 +00:00
|
|
|
|
2021-08-27 18:49:26 +00:00
|
|
|
const e2eEnabled = useSelector(state => state.settings.E2E_Enable);
|
2020-10-30 18:31:04 +00:00
|
|
|
|
2021-08-23 14:15:01 +00:00
|
|
|
useEffect(() => {
|
|
|
|
navigation.setOptions({
|
|
|
|
title: I18n.t('Security_and_privacy')
|
|
|
|
});
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
const toggleCrashReport = (value) => {
|
2020-10-30 18:31:04 +00:00
|
|
|
logEvent(events.SE_TOGGLE_CRASH_REPORT);
|
|
|
|
AsyncStorage.setItem(CRASH_REPORT_KEY, JSON.stringify(value));
|
2021-08-23 14:15:01 +00:00
|
|
|
setCrashReportState(value);
|
|
|
|
toggleCrashErrorsReport(value);
|
|
|
|
};
|
2020-10-30 18:31:04 +00:00
|
|
|
|
2021-08-23 14:15:01 +00:00
|
|
|
const toggleAnalyticsEvents = (value) => {
|
2020-10-30 18:31:04 +00:00
|
|
|
logEvent(events.SE_TOGGLE_ANALYTICS_EVENTS);
|
|
|
|
AsyncStorage.setItem(ANALYTICS_EVENTS_KEY, JSON.stringify(value));
|
2021-08-23 14:15:01 +00:00
|
|
|
setAnalyticsEventsState(value);
|
|
|
|
toggleAnalyticsEventsReport(value);
|
|
|
|
};
|
2020-10-30 18:31:04 +00:00
|
|
|
|
2021-08-23 14:15:01 +00:00
|
|
|
const navigateToScreen = (screen) => {
|
2020-10-30 18:31:04 +00:00
|
|
|
logEvent(events[`SP_GO_${ screen.replace('View', '').toUpperCase() }`]);
|
|
|
|
navigation.navigate(screen);
|
2021-08-23 14:15:01 +00:00
|
|
|
};
|
2020-10-30 18:31:04 +00:00
|
|
|
|
2021-08-23 14:15:01 +00:00
|
|
|
return (
|
|
|
|
<SafeAreaView testID='security-privacy-view'>
|
|
|
|
<StatusBar />
|
|
|
|
<List.Container testID='security-privacy-view-list'>
|
|
|
|
<List.Section>
|
|
|
|
<List.Separator />
|
|
|
|
{e2eEnabled
|
|
|
|
? (
|
|
|
|
<>
|
2020-10-30 18:31:04 +00:00
|
|
|
<List.Item
|
2021-08-23 14:15:01 +00:00
|
|
|
title='E2E_Encryption'
|
|
|
|
showActionIndicator
|
|
|
|
onPress={() => navigateToScreen('E2EEncryptionSecurityView')}
|
|
|
|
testID='security-privacy-view-e2e-encryption'
|
2020-10-30 18:31:04 +00:00
|
|
|
/>
|
|
|
|
<List.Separator />
|
2021-08-23 14:15:01 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
<List.Item
|
|
|
|
title='Screen_lock'
|
|
|
|
showActionIndicator
|
|
|
|
onPress={() => navigateToScreen('ScreenLockConfigView')}
|
|
|
|
testID='security-privacy-view-screen-lock'
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
</List.Section>
|
2020-10-30 18:31:04 +00:00
|
|
|
|
2021-08-23 14:15:01 +00:00
|
|
|
{!isFDroidBuild ? (
|
|
|
|
<>
|
|
|
|
<List.Section>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item
|
|
|
|
title='Log_analytics_events'
|
|
|
|
testID='security-privacy-view-analytics-events'
|
|
|
|
right={() => (
|
|
|
|
<Switch
|
|
|
|
value={analyticsEventsState}
|
|
|
|
trackColor={SWITCH_TRACK_COLOR}
|
|
|
|
onValueChange={toggleAnalyticsEvents}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Item
|
|
|
|
title='Send_crash_report'
|
|
|
|
testID='security-privacy-view-crash-report'
|
|
|
|
right={() => (
|
|
|
|
<Switch
|
|
|
|
value={crashReportState}
|
|
|
|
trackColor={SWITCH_TRACK_COLOR}
|
|
|
|
onValueChange={toggleCrashReport}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
<List.Info info='Crash_report_disclaimer' />
|
|
|
|
</List.Section>
|
|
|
|
</>
|
|
|
|
) : null}
|
|
|
|
</List.Container>
|
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
};
|
2020-10-30 18:31:04 +00:00
|
|
|
|
2021-08-23 14:15:01 +00:00
|
|
|
SecurityPrivacyView.propTypes = {
|
|
|
|
navigation: PropTypes.object
|
|
|
|
};
|
2020-10-30 18:31:04 +00:00
|
|
|
|
2021-08-23 14:15:01 +00:00
|
|
|
export default SecurityPrivacyView;
|