Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Add a view to handle when ENAuthorizationStatusAuthorized is false.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeberhardt committed Sep 10, 2020
1 parent caa0bcf commit 3cd9949
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ios/CovidShield/ExposureNotification.m
Expand Up @@ -71,7 +71,7 @@ - (void)invalidate

// Checking the authorizationStatus will check the "Share Exposure Information" toggle in 13.7+
if (ENManager.authorizationStatus != ENAuthorizationStatusAuthorized) {
resolve (@"disabled");
resolve (@"unauthorized");
return;
}
switch (self.enManager.exposureNotificationStatus) {
Expand Down
2 changes: 2 additions & 0 deletions src/bridge/ExposureNotification/types.ts
Expand Up @@ -20,6 +20,8 @@ export enum Status {
Restricted = 'restricted',
LocationOff = 'location_off',
PlayServicesNotAvailable = 'play_services_not_available',
Unauthorized = 'unauthorized',
Authorized = 'authorized',
}

export interface TemporaryExposureKey {
Expand Down
4 changes: 4 additions & 0 deletions src/locale/translations/en.json
Expand Up @@ -60,6 +60,10 @@
"BluetoothDisabled": "Bluetooth is off",
"EnableBluetoothCTA": "You need to turn on Bluetooth in your phone’s settings so COVID Alert can work.",
"TurnOnBluetooth": "Turn on Bluetooth",
"EnUnauthorized": {
"Title": "COVID Alert is unauthorized",
"Body1": "Sharing exposure information with COVID Alert is turn off in the Exposure Notification settings."
},
"EnDisabled": {
"Title": "COVID Alert is off",
"Body1": "You did not enable COVID Alert. The app needs your permission to work.",
Expand Down
4 changes: 4 additions & 0 deletions src/locale/translations/fr.json
Expand Up @@ -132,6 +132,10 @@
"Body2": "Vous êtes à risque d’être infecté."
}
},
"EnUnauthorized": {
"Title": "COVID Alert is unauthorized",
"Body1": "Sharing exposure information with COVID Alert is turn off in the Exposure Notification settings."
},
"EnDisabled": {
"Title": "Alerte COVID est désactivée",
"Body1": "Vous n’avez pas activé Alerte COVID. L’application a besoin de votre autorisation pour fonctionner.",
Expand Down
2 changes: 1 addition & 1 deletion src/locale/translations/index.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/screens/home/HomeScreen.tsx
Expand Up @@ -24,6 +24,7 @@ import {CollapsedOverlayView} from './views/CollapsedOverlayView';
import {DiagnosedShareView} from './views/DiagnosedShareView';
import {DiagnosedView} from './views/DiagnosedView';
import {ExposureNotificationsDisabledView} from './views/ExposureNotificationsDisabledView';
import {ExposureNotificationsUnauthorizedView} from './views/ExposureNotificationsUnauthorizedView';
import {ExposureView} from './views/ExposureView';
import {NoExposureUncoveredRegionView} from './views/NoExposureUncoveredRegionView';
import {NoExposureCoveredRegionView} from './views/NoExposureCoveredRegionView';
Expand Down Expand Up @@ -91,6 +92,8 @@ const Content = ({setBackgroundColor, isBottomSheetExpanded}: ContentProps) => {
switch (systemStatus) {
case SystemStatus.Undefined:
return null;
case SystemStatus.Unauthorized:
return <ExposureNotificationsUnauthorizedView isBottomSheetExpanded={isBottomSheetExpanded} />;
case SystemStatus.Disabled:
case SystemStatus.Restricted:
return <ExposureNotificationsDisabledView isBottomSheetExpanded={isBottomSheetExpanded} />;
Expand Down
47 changes: 47 additions & 0 deletions src/screens/home/views/ExposureNotificationsUnauthorizedView.tsx
@@ -0,0 +1,47 @@
import {useI18n} from 'locale';
import {Box, ButtonSingleLine, Text} from 'components';
import React, {useCallback} from 'react';
import {Linking, Platform} from 'react-native';
import {useStartExposureNotificationService} from 'services/ExposureNotificationService';
import {useAccessibilityAutoFocus} from 'shared/useAccessibilityAutoFocus';

import {BaseHomeView} from '../components/BaseHomeView';

export const ExposureNotificationsUnauthorizedView = ({isBottomSheetExpanded}: {isBottomSheetExpanded: boolean}) => {
const i18n = useI18n();
const startExposureNotificationService = useStartExposureNotificationService();

const toSettings = useCallback(() => {
Linking.openSettings();
}, []);

const startEn = useCallback(() => {
startExposureNotificationService();
}, [startExposureNotificationService]);

const onPress = () => {
if (Platform.OS === 'android') {
return startEn();
}
return toSettings();
};
const autoFocusRef = useAccessibilityAutoFocus(!isBottomSheetExpanded);
return (
<BaseHomeView iconName="icon-exposure-notifications-disabled" testID="exposureNotificationsDisabled">
<Text focusRef={autoFocusRef} variant="bodyTitle" color="bodyText" marginBottom="m" accessibilityRole="header">
{i18n.translate('Home.EnDisabled.Title')}
</Text>
<Text variant="bodyText" color="bodyText">
{i18n.translate('Home.EnDisabled.Body1')}
</Text>
<Box alignSelf="stretch" marginBottom="m" marginTop="l">
<ButtonSingleLine
text={i18n.translate('Home.EnDisabled.CTA')}
variant="danger50Flat"
internalLink
onPress={onPress}
/>
</Box>
</BaseHomeView>
);
};

0 comments on commit 3cd9949

Please sign in to comment.