From 73621c70f5311d2bcc0e216e83cd726f583e9545 Mon Sep 17 00:00:00 2001 From: NZ COVID Tracer App Date: Tue, 23 Feb 2021 21:46:07 +1300 Subject: [PATCH] Release 3.0.3 --- package.json | 2 +- src/__snapshots__/config.spec.ts.snap | 1 + src/components/molecules/FormV2.tsx | 13 +++-- src/config.ts | 5 ++ .../__snapshots__/externalLinks.spec.ts.snap | 1 + src/constants/externalLinks.ts | 1 + src/features/enf/strings.ts | 4 ++ src/features/enf/views/ENFSettings.tsx | 9 +++- src/features/enf/views/ENFiOS12Support.tsx | 54 +++++++++++++++++++ src/features/onboarding/reducer.ts | 10 ++++ src/features/onboarding/saga.ts | 8 ++- src/features/onboarding/strings.ts | 2 + src/features/onboarding/views/EnableENF.tsx | 11 +++- src/features/scan/strings.ts | 3 +- .../scan/views/VisitRecordedScreen.tsx | 1 + .../__snapshots__/strings.spec.ts.snap | 6 ++- src/utils/versions.spec.ts | 13 +++++ src/utils/versions.ts | 40 ++++++++++++++ 18 files changed, 173 insertions(+), 11 deletions(-) create mode 100644 src/features/enf/views/ENFiOS12Support.tsx create mode 100644 src/utils/versions.spec.ts create mode 100644 src/utils/versions.ts diff --git a/package.json b/package.json index e571695..30d0b48 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "postinstall": "node scripts/add-certs.js", - "android": "react-native run-android --variant=envDevelopDebug", + "android": "react-native run-android --variant=envEnfDebug", "ios": "react-native run-ios", "start": "react-native start", "test": "yarn fix:test:realm && jest", diff --git a/src/__snapshots__/config.spec.ts.snap b/src/__snapshots__/config.spec.ts.snap index 771e9d4..515b1a5 100644 --- a/src/__snapshots__/config.spec.ts.snap +++ b/src/__snapshots__/config.spec.ts.snap @@ -33,5 +33,6 @@ Object { "SafetynetKey": "", "SupportPhoneLink": "tel:0800800606", "WebAppBaseUrl": "", + "iOS12SupportLink": "https://www.health.govt.nz/our-work/diseases-and-conditions/covid-19-novel-coronavirus/covid-19-resources-and-tools/nz-covid-tracer-app/getting-started-nz-covid-tracer/bluetooth-tracing#ios-12-5", } `; diff --git a/src/components/molecules/FormV2.tsx b/src/components/molecules/FormV2.tsx index 7ab7fa5..877ffee 100644 --- a/src/components/molecules/FormV2.tsx +++ b/src/components/molecules/FormV2.tsx @@ -11,6 +11,7 @@ import { useHeaderHeight } from "@react-navigation/stack"; import React, { createContext, forwardRef, + ReactNode, Ref, useCallback, useEffect, @@ -109,6 +110,7 @@ export interface FormV2Props extends FormHeaderProps { headingStyle?: TextStyle; description?: string; descriptionStyle?: TextStyle; + descriptionElement?: ReactNode; buttonText?: string; buttonTestID?: string; buttonLoading?: boolean; @@ -164,6 +166,7 @@ function _FormV2(props: FormV2Props, ref: Ref) { headingStyle, description, descriptionStyle, + descriptionElement, buttonText, buttonTestID, buttonLoading, @@ -393,9 +396,13 @@ function _FormV2(props: FormV2Props, ref: Ref) { } {!!heading && {heading}} - {!!description && ( - {description} - )} + {descriptionElement + ? descriptionElement + : !!description && ( + + {description} + + )} diff --git a/src/config.ts b/src/config.ts index 0211939..3a5c864 100644 --- a/src/config.ts +++ b/src/config.ts @@ -33,6 +33,7 @@ export interface AppConfigRaw { ENFServerUrl?: string; SafetynetKey?: string; ENFCheckInterval?: string; + iOS12SupportLink?: string; } export interface AppConfig { @@ -67,6 +68,7 @@ export interface AppConfig { ENFServerUrl: string; SafetynetKey: string; ENFCheckInterval: number; + iOS12SupportLink: string; } export let disableAnimations = false; @@ -182,6 +184,9 @@ const config: AppConfig = { ENFServerUrl: raw.ENFServerUrl || "", SafetynetKey: raw.SafetynetKey || "", ENFCheckInterval: getENFCheckInterval(), + iOS12SupportLink: + raw.iOS12SupportLink || + "https://www.health.govt.nz/our-work/diseases-and-conditions/covid-19-novel-coronavirus/covid-19-resources-and-tools/nz-covid-tracer-app/getting-started-nz-covid-tracer/bluetooth-tracing#ios-12-5", }; export default config; diff --git a/src/constants/__snapshots__/externalLinks.spec.ts.snap b/src/constants/__snapshots__/externalLinks.spec.ts.snap index 73ec0eb..52b8288 100644 --- a/src/constants/__snapshots__/externalLinks.spec.ts.snap +++ b/src/constants/__snapshots__/externalLinks.spec.ts.snap @@ -10,6 +10,7 @@ Object { "copyrightLink": "/help/copyright?src=app", "feedbackLink": "mailto:help@covidtracer.min.health.nz?subject=NZ COVID Tracer App Feedback", "helpLink": "https://www.health.govt.nz/our-work/diseases-and-conditions/covid-19-novel-coronavirus/covid-19-novel-coronavirus-resources-and-tools/nz-covid-tracer-app/questions-and-answers-nz-covid-tracer", + "iOS12SupportLink": "https://www.health.govt.nz/our-work/diseases-and-conditions/covid-19-novel-coronavirus/covid-19-resources-and-tools/nz-covid-tracer-app/getting-started-nz-covid-tracer/bluetooth-tracing#ios-12-5", "loginLink": "/login?src=app", "privacyLink": "/help/privacypolicy?src=app", "resourcesLink": "/resources?src=app", diff --git a/src/constants/externalLinks.ts b/src/constants/externalLinks.ts index bb4662e..7b44684 100644 --- a/src/constants/externalLinks.ts +++ b/src/constants/externalLinks.ts @@ -13,3 +13,4 @@ export const helpLink = config.HelpPageUrl; export const contactLink = config.ContactUsPageUrl; export const contactAlertslink = config.ContactAlertsUrl; export const aboutBluetoothLink = config.AboutBluetoothLink; +export const iOS12SupportLink = config.iOS12SupportLink; diff --git a/src/features/enf/strings.ts b/src/features/enf/strings.ts index e65cf2c..ef5a02c 100644 --- a/src/features/enf/strings.ts +++ b/src/features/enf/strings.ts @@ -15,6 +15,10 @@ export const strings = { title: "Bluetooth tracing", description: "Anonymously log when you are near other app users by enabling your phone’s Exposure Notification System.", + descriptioniOS12: + "Your phone is partially supported. You can enable Bluetooth tracing now, and it will work fully in a future version of the app. ", + descriptionLinkiOS12: + "Read more about Bluetooth tracing on iOS 12.5 here.", buttonEnabled: "Turn it off", buttonEnabledAccessibility: "Turn bluetooth tracing off", buttonDisabled: "Turn it on", diff --git a/src/features/enf/views/ENFSettings.tsx b/src/features/enf/views/ENFSettings.tsx index 74a1486..f4afc4f 100644 --- a/src/features/enf/views/ENFSettings.tsx +++ b/src/features/enf/views/ENFSettings.tsx @@ -9,6 +9,7 @@ import { import { isIOS } from "@lib/helpers"; import { createLogger } from "@logger/createLogger"; import { useAccessibleTitle } from "@navigation/hooks/useAccessibleTitle"; +import { iOS12EnfSupported } from "@utils/versions"; import React, { useCallback, useEffect, useRef } from "react"; import { useTranslation } from "react-i18next"; import { Alert, Linking } from "react-native"; @@ -20,6 +21,7 @@ import styled from "styled-components/native"; import { AnalyticsEvent, recordAnalyticEvent } from "../../../analytics"; import { Subtext } from "../components/Subtext"; +import { ENFiOS12Support } from "./ENFiOS12Support"; const Subheading = styled(Text)` font-family: ${fontFamilies["open-sans-bold"]}; @@ -150,6 +152,9 @@ export function ENFSettings() { headerImage={require("../assets/images/information.png")} heading={t("screens:enfSettings:title")} description={t("screens:enfSettings:description")} + descriptionElement={ + iOS12EnfSupported ? : undefined + } buttonText={buttonText} onButtonPress={onButtonPress} buttonAccessibilityLabel={buttonAccessibilityLabel} @@ -174,7 +179,9 @@ export function ENFSettings() { {t("screens:enfSettings:subheading")} {t("screens:enfSettings:subtext")} {t("screens:enfSettings:subtextP2")} - {t("screens:enfSettings:subtextP3")} + {!iOS12EnfSupported && ( + {t("screens:enfSettings:subtextP3")} + )} ); } diff --git a/src/features/enf/views/ENFiOS12Support.tsx b/src/features/enf/views/ENFiOS12Support.tsx new file mode 100644 index 0000000..ca6193a --- /dev/null +++ b/src/features/enf/views/ENFiOS12Support.tsx @@ -0,0 +1,54 @@ +import { VerticalSpacing } from "@components/atoms"; +import { Text } from "@components/atoms/Text"; +import { fontFamilies, fontSizes, grid2x, grid4x } from "@constants"; +import React, { useCallback } from "react"; +import { useTranslation } from "react-i18next"; +import { Linking } from "react-native"; +import styled from "styled-components/native"; + +import config from "../../../config"; + +const DescriptionBold = styled(Text)` + font-family: ${fontFamilies["open-sans-bold"]}; + font-size: ${fontSizes.normal}px; + text-align: left; +`; + +const Description = styled(Text)` + font-family: ${fontFamilies["open-sans"]}; + font-size: ${fontSizes.normal}px; + margin-bottom: ${grid4x}px; + text-align: left; +`; + +const DescriptionLink = styled(DescriptionBold)` + padding-top: 8px; + text-decoration-line: underline; +`; + +export interface ENFiOS12SupportProps { + showLogParagraph?: boolean; +} + +export function ENFiOS12Support({ showLogParagraph }: ENFiOS12SupportProps) { + const { t } = useTranslation(); + + const handleLink = useCallback(() => { + Linking.openURL(config.iOS12SupportLink); + }, []); + + return ( + <> + + {t("screens:enfSettings:descriptioniOS12")} + + + {t("screens:enfSettings:descriptionLinkiOS12")} + + + {showLogParagraph && ( + {t("screens:enfSettings:description")} + )} + + ); +} diff --git a/src/features/onboarding/reducer.ts b/src/features/onboarding/reducer.ts index a88ac3e..481b5f4 100644 --- a/src/features/onboarding/reducer.ts +++ b/src/features/onboarding/reducer.ts @@ -205,6 +205,11 @@ const slice = createSlice({ state.loadingDidTimeout = true; reduceIsLoading(state); }, + patchEnfCompleted(state) { + if (state.hasSeenDashboardEnf) { + state.screenCompleted[OnboardingScreen.EnableENF] = true; + } + }, }, extraReducers: (builder) => { builder.addCase( @@ -249,6 +254,11 @@ export const { navigateNext, setHasSeenEnf, loadingDidTimeout, + /** + * This action patches the enf screen completed state, + * in case if it wasn't shown in the first time. (due to attestation failure) + */ + patchEnfCompleted, } = actions; export { reducer as _reducer }; diff --git a/src/features/onboarding/saga.ts b/src/features/onboarding/saga.ts index a32d7ee..3896538 100644 --- a/src/features/onboarding/saga.ts +++ b/src/features/onboarding/saga.ts @@ -6,7 +6,7 @@ import ExposureNotificationModule from "react-native-exposure-notification-servi import { SagaIterator } from "redux-saga"; import { all, call, delay, put, race, select, take } from "redux-saga/effects"; -import { setEnfSupported, setSessionType } from "./reducer"; +import { patchEnfCompleted, setEnfSupported, setSessionType } from "./reducer"; import { selectSessionType } from "./selectors"; import { SessionType } from "./types"; @@ -60,5 +60,9 @@ function* onboarding(): SagaIterator { } export default function* sagaWatcher(): SagaIterator { - yield all([call(onboarding), call(loadEnfSupported)]); + yield all([ + put(patchEnfCompleted()), + call(onboarding), + call(loadEnfSupported), + ]); } diff --git a/src/features/onboarding/strings.ts b/src/features/onboarding/strings.ts index 62a4d08..7381d12 100644 --- a/src/features/onboarding/strings.ts +++ b/src/features/onboarding/strings.ts @@ -20,6 +20,8 @@ export const strings = { title: "We’ve made a few changes for you", infoEnf: "Use Bluetooth to anonymously log when you are near other app users", + infoEnfiOS12: + "Your phone is now partially supported for Bluetooth tracing. You can enable it now, and it will work fully soon.", infoPassword: "You don't need to set a password or log in to use the app", infoLook: diff --git a/src/features/onboarding/views/EnableENF.tsx b/src/features/onboarding/views/EnableENF.tsx index 3174678..db9475b 100644 --- a/src/features/onboarding/views/EnableENF.tsx +++ b/src/features/onboarding/views/EnableENF.tsx @@ -7,11 +7,13 @@ import { fontSizes, grid2x, } from "@constants"; +import { ENFiOS12Support } from "@features/enf/views/ENFiOS12Support"; import { ENFEvent } from "@features/enfExposure/events"; import { isIOS } from "@lib/helpers"; import { createLogger } from "@logger/createLogger"; import { useAccessibleTitle } from "@navigation/hooks/useAccessibleTitle"; import { StackScreenProps } from "@react-navigation/stack"; +import { iOS12EnfSupported } from "@utils/versions"; import React, { useCallback, useLayoutEffect, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { Linking } from "react-native"; @@ -163,6 +165,7 @@ export function EnableENF(props: Props) { headingStyle={styles.headingBig} renderButton={renderButton} ref={formRef} + descriptionElement={iOS12EnfSupported ? : undefined} > {t("screens:enableENF:description1")} @@ -170,8 +173,12 @@ export function EnableENF(props: Props) { {t("screens:enableENF:description3")} - {t("screens:enableENF:description4")} - + {!iOS12EnfSupported && ( + <> + {t("screens:enableENF:description4")} + + + )} { + expect(parseVersion(version)).toEqual(result); +}); diff --git a/src/utils/versions.ts b/src/utils/versions.ts new file mode 100644 index 0000000..0a3dd3d --- /dev/null +++ b/src/utils/versions.ts @@ -0,0 +1,40 @@ +import { Platform } from "react-native"; + +export interface Version { + major: number; + minor?: number; +} + +export const parseVersion = (version: string | number): Version | undefined => { + if (typeof version === "number") { + return { + major: version, + }; + } + const components = version.split("."); + if (components.length < 2) { + return undefined; + } + + const major = parseInt(components[0]); + const minor = parseInt(components[1]); + + if (isNaN(major) || isNaN(minor)) { + return undefined; + } + + return { + major, + minor, + }; +}; + +const platform = Platform.OS; +const version = parseVersion(Platform.Version || ""); + +export const iOS12EnfSupported = + platform === "ios" && + version != null && + version.major === 12 && + version.minor != null && + version.minor >= 5;