Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from minhealthnz/release-3.0.1
Browse files Browse the repository at this point in the history
Release 3.0.1
  • Loading branch information
nzcovidtracer-dev committed Dec 17, 2020
2 parents 6dec264 + b525b63 commit ff9c283
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 78 deletions.
7 changes: 6 additions & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning"
tools:remove="android:networkSecurityConfig"
/>
</manifest>
2 changes: 0 additions & 2 deletions ios/UniteAppRN/Info-DEV.plist
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
</dict>
<key>NSCameraUsageDescription</key>
<string>We need your camera to scan QR codes</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UIAppFonts</key>
<array>
<string>Baloo-Black.ttf</string>
Expand Down
2 changes: 0 additions & 2 deletions ios/UniteAppRN/Info-DEVOPS.plist
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
</dict>
<key>NSCameraUsageDescription</key>
<string>We need your camera to scan QR codes</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UIAppFonts</key>
<array>
<string>Baloo-Black.ttf</string>
Expand Down
4 changes: 0 additions & 4 deletions ios/UniteAppRN/Info-ENF.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
</dict>
<key>NSCameraUsageDescription</key>
<string>We need your camera to scan QR codes</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UIAppFonts</key>
<array>
<string>Baloo-Black.ttf</string>
Expand Down Expand Up @@ -80,8 +78,6 @@
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
<string>bluetooth-le</string>
<string>telephony</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
Expand Down
2 changes: 0 additions & 2 deletions ios/UniteAppRN/Info-TEST.plist
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
</dict>
<key>NSCameraUsageDescription</key>
<string>We need your camera to scan QR codes</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UIAppFonts</key>
<array>
<string>Baloo-Black.ttf</string>
Expand Down
2 changes: 0 additions & 2 deletions ios/UniteAppRN/Info-UAT.plist
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
</dict>
<key>NSCameraUsageDescription</key>
<string>We need your camera to scan QR codes</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UIAppFonts</key>
<array>
<string>Baloo-Black.ttf</string>
Expand Down
4 changes: 0 additions & 4 deletions ios/UniteAppRN/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
</dict>
<key>NSCameraUsageDescription</key>
<string>We need your camera to scan QR codes</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UIAppFonts</key>
<array>
<string>Baloo-Black.ttf</string>
Expand Down Expand Up @@ -85,8 +83,6 @@
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
<string>bluetooth-le</string>
<string>telephony</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
Expand Down
21 changes: 21 additions & 0 deletions setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import { createLogger } from "@logger/createLogger";
import messaging, {
FirebaseMessagingTypes,
} from "@react-native-firebase/messaging";
import { Analytics } from "aws-amplify";
import { dirname } from "path";
import { AppState, AppStateStatus, Platform } from "react-native";
import DeviceInfo from "react-native-device-info";
import ExposureNotificationModule from "react-native-exposure-notification-service";
import { enableScreens } from "react-native-screens";

import { configure as configurePush } from "./src/notifications";
Expand Down Expand Up @@ -95,3 +97,22 @@ logInfo(`app state ${AppState.currentState}`);
AppState.addEventListener("change", (value: AppStateStatus) => {
logInfo(`app state ${value}`);
});

AppState.addEventListener("change", (value) => {
if (value === "active") {
ExposureNotificationModule.exposureEnabled()
.then((isENFEnabled) => {
logInfo(
"Update isENFEnabled via Analytics.updateEndpoint with value: " +
isENFEnabled,
);

return Analytics.updateEndpoint({
attributes: {
isENFEnabled: [isENFEnabled],
},
});
})
.catch(logError);
}
});
5 changes: 3 additions & 2 deletions src/HeadlessCheck.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SplashScreen } from "@features/onboarding/views/SplashScreen";
import { createLogger } from "@logger/createLogger";
import { useAppState } from "@react-native-community/hooks";
import React, { useEffect, useState } from "react";
Expand Down Expand Up @@ -25,13 +26,13 @@ export function HeadlessCheck({ isHeadless, isBackground }: Prop) {
if (isHeadless) {
// App has been launched in the background by iOS, ignore
logInfo("is headless, ignore");
return null;
return <SplashScreen />;
}

if (!beenActive) {
// App has been launched in the background by iOS, ignore
logInfo("app is not active, ignore");
return null;
return <SplashScreen />;
}

return <App />;
Expand Down
1 change: 1 addition & 0 deletions src/features/enfExposure/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const ENFEvent = {
ENFEnableSuccess: "enfEnableSuccess",
ENFDisableButtonPressed: "enfDisableButtonPressed",
ENFDisableModalPressed: "enfDisableModalPressed",
ENFOnboardingEnableSuccess: "enfOnboardingEnableSuccess",
} as const;

export type ENFEventPayloads = {
Expand Down
5 changes: 0 additions & 5 deletions src/features/onboarding/reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { setCountedOldDiaries } from "@features/diary/commonActions";
import {
registerDeviceFulfilled,
registerDeviceRejected,
registerDeviceSkipped,
} from "@features/verification/commonActions";
import { nanoid } from "@reduxjs/toolkit";

Expand Down Expand Up @@ -130,7 +129,6 @@ describe("#registerDevice", () => {
const cases = [
["failure", registerDeviceFulfilled.type, "retrySuccess"],
[undefined, registerDeviceFulfilled.type, "success"],
[undefined, registerDeviceSkipped.type, "skipped"],
[undefined, registerDeviceRejected.type, "failure"],
];

Expand All @@ -143,9 +141,6 @@ describe("#registerDevice", () => {
refreshToken: nanoid(),
});
break;
case registerDeviceSkipped.type:
action = registerDeviceSkipped();
break;
case registerDeviceRejected.type:
action = registerDeviceRejected({ isNetworkError: false });
break;
Expand Down
5 changes: 0 additions & 5 deletions src/features/onboarding/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { setCountedOldDiaries } from "@features/diary/commonActions";
import {
registerDeviceFulfilled,
registerDeviceRejected,
registerDeviceSkipped,
} from "@features/verification/commonActions";
import { createLogger } from "@logger/createLogger";
import { createSlice, Draft, PayloadAction } from "@reduxjs/toolkit";
Expand Down Expand Up @@ -227,10 +226,6 @@ const slice = createSlice({
}
reduceIsLoading(state);
})
.addCase(registerDeviceSkipped, (state) => {
state.deviceRegistered = "skipped";
reduceIsLoading(state);
})
.addCase(registerDeviceRejected, (state, _action) => {
if (state.deviceRegistered === undefined) {
state.deviceRegistered = "failure";
Expand Down
5 changes: 5 additions & 0 deletions src/features/onboarding/views/EnableENF.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
fontSizes,
grid2x,
} from "@constants";
import { ENFEvent } from "@features/enfExposure/events";
import { isIOS } from "@lib/helpers";
import { createLogger } from "@logger/createLogger";
import { useAccessibleTitle } from "@navigation/hooks/useAccessibleTitle";
Expand All @@ -20,6 +21,7 @@ import {
} from "react-native-exposure-notification-service";
import styled from "styled-components";

import { recordAnalyticEvent } from "../../../analytics";
import { OnboardingScreen } from "../screens";
import { styles } from "../styles";
import { useOnboardingFlow } from "../useOnboardingFlow";
Expand Down Expand Up @@ -103,6 +105,9 @@ export function EnableENF(props: Props) {

try {
const authorised = await authoriseExposure();
if (authorised) {
recordAnalyticEvent(ENFEvent.ENFOnboardingEnableSuccess);
}
await readPermissions();

logInfo("Attempt to authoriseExposure" + authorised);
Expand Down
21 changes: 21 additions & 0 deletions src/features/scan/views/Scan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useAppDispatch } from "@lib/useAppDispatch";
import { createLogger } from "@logger/createLogger";
import { BarcodeMask } from "@nartc/react-native-barcode-mask";
import { useAccessibleTitle } from "@navigation/hooks/useAccessibleTitle";
import { useAppState } from "@react-native-community/hooks";
import { useFocusEffect, useIsFocused } from "@react-navigation/native";
import { StackScreenProps } from "@react-navigation/stack";
import { nanoid, unwrapResult } from "@reduxjs/toolkit";
Expand Down Expand Up @@ -201,6 +202,7 @@ export function Scan(props: Props) {

useEffect(() => {
if (!isCameraMounted && isFocused) {
logInfo("remount camera");
setIsCameraMounted(true);
return;
}
Expand All @@ -209,6 +211,7 @@ export function Scan(props: Props) {
useEffect(() => {
const timeoutId = setTimeout(() => {
if (!isFocused) {
logInfo("unmount camera");
setIsCameraMounted(false);
}
}, TIME_TO_UNMOUNT_CAMERA_AFTER);
Expand Down Expand Up @@ -373,6 +376,24 @@ export function Scan(props: Props) {
[isCameraMounted, cameraPermission],
);

const appState = useAppState();

useEffect(() => {
if (cameraRef.current == null) {
return;
}
switch (appState) {
case "background":
logInfo("pause preview");
cameraRef.current.pausePreview();
break;
case "active":
logInfo("resume preview");
cameraRef.current.resumePreview();
break;
}
}, [appState]);

useAccessibleTitle();

const hasRequestedCameraPermission = useSelector(
Expand Down
4 changes: 0 additions & 4 deletions src/features/verification/commonActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ export const registerDeviceRejected = createAction<RegisterDeviceRejected>(
"verfication/registerDeviceRejected",
);

export const registerDeviceSkipped = createAction(
"verification/registerDeviceSkipped",
);

export const setEnfEnabled = createAction<boolean>(
"verification/setEnfEnabled",
);
28 changes: 6 additions & 22 deletions src/features/verification/sagas/registerDevice.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { appDidBecomeAvailable } from "@domain/device/reducer";
import { selectIsEnfSupported } from "@features/enf/selectors";
import {
selectDeviceRegistered,
selectHasSeenEnf,
Expand All @@ -11,11 +10,16 @@ import { select } from "redux-saga-test-plan/matchers";
import {
registerDeviceFulfilled,
registerDeviceRejected,
registerDeviceSkipped,
} from "../commonActions";
import { selectRefreshToken, selectToken } from "../selectors";
import { registerDevice } from "./registerDevice";

jest.mock("react-native-exposure-notification-service", () => ({
isSupported: async () => {
return true;
},
}));

describe("#registerDevice", () => {
it("fullfills registration", async () => {
const tokens = {
Expand All @@ -26,7 +30,6 @@ describe("#registerDevice", () => {
await expectSaga(registerDevice, verifyDevice)
.provide([
[select(selectRefreshToken), undefined],
[select(selectIsEnfSupported), true],
[select(selectDeviceRegistered), "skipped"],
[select(selectHasSeenEnf), false],
])
Expand All @@ -39,7 +42,6 @@ describe("#registerDevice", () => {
await expectSaga(registerDevice, verifyDevice)
.provide([
[select(selectRefreshToken), undefined],
[select(selectIsEnfSupported), true],
[select(selectDeviceRegistered), "skipped"],
[select(selectHasSeenEnf), false],
])
Expand All @@ -55,7 +57,6 @@ describe("#registerDevice", () => {
.provide([
[select(selectRefreshToken), refreshToken],
[select(selectToken), token],
[select(selectIsEnfSupported), true],
[select(selectDeviceRegistered), "skipped"],
[select(selectHasSeenEnf), false],
])
Expand All @@ -64,21 +65,4 @@ describe("#registerDevice", () => {
.put(registerDeviceFulfilled({ refreshToken, token }))
.silentRun();
});
it("skips registration if device is not supported", async () => {
const tokens = {
token: nanoid(),
refreshToken: nanoid(),
};
const verifyDevice = jest.fn().mockReturnValue(tokens);
await expectSaga(registerDevice, verifyDevice)
.provide([
[select(selectRefreshToken), undefined],
[select(selectIsEnfSupported), false],
[select(selectDeviceRegistered), "skipped"],
[select(selectHasSeenEnf), false],
])
.dispatch(appDidBecomeAvailable())
.put(registerDeviceSkipped())
.silentRun();
});
});
Loading

0 comments on commit ff9c283

Please sign in to comment.