Skip to content

Commit

Permalink
Merge branch 'develop' into ts-pull-i18n
Browse files Browse the repository at this point in the history
* develop:
  Set up location after skiping the steps (#721)
  App shows green icon when tracking is inactive (#722)
  Fix postinstall script on Windows (#720)
  Fix isVersionGreater and add tests (#726)
  update the upgrade version to 1.0.0, to match what is in the master branch and avoid mistaken forced upgrades. (#723)
  1.0.1 (#715)
  Put GPS filter behind dev flag (#714)
  Fix headline1 text cutoff (#712)
  Put auto sub behind dev flags (#711)
  remove default news url from News.js constructor (#704)
  Fix i18n placeholder for authorities (#709)
  • Loading branch information
tstirrat committed Apr 30, 2020
2 parents d790a42 + 9b2c5b6 commit 77d7fc2
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 108 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ android {
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

versionCode 24
versionName "1.0.0"
versionCode 25
versionName "1.0.1"
}
splits {
abi {
Expand Down
6 changes: 2 additions & 4 deletions app/Util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dayjs from 'dayjs';
import { Platform } from 'react-native';
import semver from 'semver';

export function isPlatformiOS() {
return Platform.OS === 'ios';
Expand All @@ -13,10 +14,7 @@ export function nowStr() {
return dayjs().format('H:mm');
}

export const isVersionGreater = (source, target) =>
source
.split('.')
.some((val, index) => parseInt(val) > parseInt(target.split('.')[index]));
export const isVersionGreater = (source, target) => semver.gt(source, target);

export default {
isPlatformiOS,
Expand Down
27 changes: 27 additions & 0 deletions app/__tests__/Util.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { isVersionGreater } from '../Util';

describe('Util class', () => {
let versions;

beforeEach(() => {
versions = [
['0.0.1', '0.0.0', true],
['1.0.1', '0.9.9', true],
['3.0.0', '2.7.2+asdf', true],
['1.2.3-a.10', '1.2.3-a.5', true],
['1.2.3-a.b', '1.2.3-a', true],
['0.9.5', '1.0.1', false],
['0.9.9', '1.0.0', false],
['1.3.4', '1.3.5', false],
['2.9.1', '3.0.0', false],
['1.2.3', '1.2.3', false],
];
});

it('version greater than works', () => {
versions.forEach(([v0, v1, expectedValue]) => {
const result = isVersionGreater(v0, v1);
expect(result).toBe(expectedValue);
});
});
});
2 changes: 1 addition & 1 deletion app/components/Typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const FONT_SIZE_MAP = {
const getFontSize = ({ use = Type.Body1 }) => FONT_SIZE_MAP[use];

const LINE_HEIGHT_MAP = {
[Type.Headline1]: '48px',
[Type.Headline1]: '52px',
[Type.Headline2]: '34px',
[Type.Headline3]: '40px',
[Type.Body1]: '24px',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ exports[`headline1 is large and bold 1`] = `
"fontFamily": "IBMPlexSans-Bold",
"fontSize": 52,
"fontWeight": "bold",
"lineHeight": 48,
"lineHeight": 52,
"writingDirection": "ltr",
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/constants/__tests__/__snapshots__/Theme.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ exports[`includes extra background View if setBackground=true 1`] = `
"fontFamily": "IBMPlexSans-Bold",
"fontSize": 52,
"fontWeight": "bold",
"lineHeight": 48,
"lineHeight": 52,
"writingDirection": "ltr",
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"authorities_new_in_area_title_plural": "New Healthcare Authorities",
"authorities_new_subcription_msg": "You have been subscribed to {{count}} new authority in your location",
"authorities_new_subcription_msg_plural": "You have been subscribed to {{count}} new authorities in your location",
"authorities_new_subcription_title": "{{numAuthories}} New Subscription",
"authorities_new_subcription_title_plural": "{{numAuthories}} New Subscriptions",
"authorities_new_subcription_title": "{{count}} New Subscription",
"authorities_new_subcription_title_plural": "{{count}} New Subscriptions",
"authorities_no_sources": "No data source yet",
"authorities_removal_alert_cancel": "Cancel",
"authorities_removal_alert_desc": "Are you sure you want to remove this authority data source?",
Expand Down
2 changes: 1 addition & 1 deletion app/services/BackgroundTaskService.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HCAService } from '../services/HCAService';

export function executeTask() {
checkIntersect();
HCAService.findNewAuthorities();
__DEV__ && HCAService.findNewAuthorities();
}

export default class BackgroundTaskServices {
Expand Down
48 changes: 26 additions & 22 deletions app/views/ChooseProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ChooseProviderScreen extends Component {
urlEntryInProgress: false,
urlText: '',
authoritiesList: [],
isAuthorityFilterActive: true,
isAuthorityFilterActive: false,
isAutoSubscribed: false,
};
}
Expand All @@ -60,7 +60,7 @@ class ChooseProviderScreen extends Component {
BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
await this.fetchAuthoritiesList(this.state.isAuthorityFilterActive);
await this.fetchUserAuthorities();
await this.fetchAutoSubcribeStatus();
__DEV__ && (await this.fetchAutoSubcribeStatus());
}

componentWillUnmount() {
Expand Down Expand Up @@ -235,13 +235,15 @@ class ChooseProviderScreen extends Component {
<Typography style={styles.sectionDescription} use={'body1'}>
{languages.t('label.authorities_desc')}
</Typography>
<TouchableOpacity style={styles.autoSubcribe}>
<Checkbox
label={languages.t('label.auto_subscribe_checkbox')}
checked={this.state.isAutoSubscribed}
onPress={() => this.toggleAutoSubscribe()}
/>
</TouchableOpacity>
{__DEV__ && (
<TouchableOpacity style={styles.autoSubcribe}>
<Checkbox
label={languages.t('label.auto_subscribe_checkbox')}
checked={this.state.isAutoSubscribed}
onPress={() => this.toggleAutoSubscribe()}
/>
</TouchableOpacity>
)}
</View>

<View style={styles.listContainer}>
Expand Down Expand Up @@ -343,19 +345,21 @@ class ChooseProviderScreen extends Component {
</TouchableOpacity>
</MenuTrigger>
<MenuOptions>
<TouchableOpacity
style={styles.authorityFilter}
onPress={() => this.toggleFilterAuthoritesByGPSHistory()}>
<Typography style={styles.authorityFilterText} use={'body2'}>
{languages.t('label.filter_authorities_by_gps_history')}
</Typography>
<Switch
onValueChange={val =>
this.filterAuthoritesByGPSHistory({ val })
}
value={this.state.isAuthorityFilterActive}
/>
</TouchableOpacity>
{__DEV__ && (
<TouchableOpacity
style={styles.authorityFilter}
onPress={() => this.toggleFilterAuthoritesByGPSHistory()}>
<Typography style={styles.authorityFilterText} use={'body2'}>
{languages.t('label.filter_authorities_by_gps_history')}
</Typography>
<Switch
onValueChange={val =>
this.filterAuthoritesByGPSHistory({ val })
}
value={this.state.isAuthorityFilterActive}
/>
</TouchableOpacity>
)}
{this.state.authoritiesList === undefined
? null
: this.state.authoritiesList.map(item => {
Expand Down
26 changes: 15 additions & 11 deletions app/views/LocationTracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,26 @@ class LocationTracking extends Component {

checkIfUserAtRisk() {
BackgroundTaskServices.start();

// If the user has location tracking disabled, set enum to match
GetStoreData(PARTICIPATE, false).then(isParticipating => {
if (isParticipating === false) {
this.setState({
currentState: StateEnum.SETTING_OFF,
});
}
//Location enable
else {
this.crossPathCheck();
}
});
}
//Due to Issue 646 moved below code from checkIfUserAtRisk function
crossPathCheck() {
GetStoreData(DEBUG_MODE).then(dbgMode => {
if (dbgMode != 'true') {
// already set on 12h timer, but run when this screen opens too
checkIntersect();
}

GetStoreData(CROSSED_PATHS).then(dayBin => {
dayBin = JSON.parse(dayBin);
if (dayBin !== null && dayBin.reduce((a, b) => a + b, 0) > 0) {
Expand All @@ -158,15 +171,6 @@ class LocationTracking extends Component {
}
});
});

// If the user has location tracking disabled, set enum to match
GetStoreData(PARTICIPATE, false).then(isParticipating => {
if (isParticipating === false) {
this.setState({
currentState: StateEnum.SETTING_OFF,
});
}
});
}

componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion app/views/News.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NewsScreen extends Component {
this.state = {
visible: true,
default_news: default_news,
newsUrls: [default_news, default_news],
newsUrls: [],
current_page: 0,
};
}
Expand Down
25 changes: 18 additions & 7 deletions app/views/onboarding/Onboarding5.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Onboarding extends Component {
componentDidMount() {
this.checkLocationStatus();
isPlatformiOS() && this.checkNotificationStatus();
this.checkSubsriptionStatus();
__DEV__ && this.checkSubsriptionStatus();
}

isLocationChecked() {
Expand All @@ -106,11 +106,9 @@ class Onboarding extends Component {
getNextStep(currentStep) {
switch (currentStep) {
case StepEnum.LOCATION:
return isPlatformiOS()
? StepEnum.NOTIFICATIONS
: StepEnum.HCA_SUBSCRIPTION;
return this.getLocationNextStep();
case StepEnum.NOTIFICATIONS:
return StepEnum.HCA_SUBSCRIPTION;
return __DEV__ ? StepEnum.HCA_SUBSCRIPTION : StepEnum.DONE;
case StepEnum.HCA_SUBSCRIPTION:
return StepEnum.DONE;
}
Expand Down Expand Up @@ -175,6 +173,16 @@ class Onboarding extends Component {
}
}

getLocationNextStep() {
if (isPlatformiOS()) {
return StepEnum.NOTIFICATIONS;
} else if (__DEV__) {
return StepEnum.HCA_SUBSCRIPTION;
} else {
return isPlatformiOS() ? StepEnum.NOTIFICATIONS : StepEnum.DONE;
}
}

/**
* Gets the respective location permissions settings string
* for the user's current device.
Expand Down Expand Up @@ -279,7 +287,10 @@ class Onboarding extends Component {
this.requestHCASubscription();
break;
case StepEnum.DONE:
SetStoreData(PARTICIPATE, 'true');
SetStoreData(
PARTICIPATE,
this.state.locationPermission === PermissionStatusEnum.GRANTED,
);
SetStoreData('ONBOARDING_DONE', true);
this.props.navigation.replace('LocationTrackingScreen');
}
Expand Down Expand Up @@ -427,7 +438,7 @@ class Onboarding extends Component {
<View style={styles.statusContainer}>
{this.getLocationPermission()}
{this.getNotificationsPermissionIfIOS()}
{this.getAuthSubscriptionStatus()}
{__DEV__ && this.getAuthSubscriptionStatus()}
<View style={styles.spacer} />
</View>
</View>
Expand Down
14 changes: 1 addition & 13 deletions e2e/helpers/onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,8 @@ export const navigateThroughPermissions = async languageStrings => {
await Onboarding4.tapButton(languageStrings);
};

export const navigateThroughOnboarding = async (
languageStrings,
isAutoSubcribe = true,
) => {
export const navigateThroughOnboarding = async languageStrings => {
await navigateThroughPermissions(languageStrings);

await EnableAuthoritySubscription.isOnScreen(languageStrings);

if (isAutoSubcribe) {
await EnableAuthoritySubscription.enable(languageStrings);
} else {
await EnableAuthoritySubscription.skipStep(languageStrings);
}

await FinishSetup.isOnScreen(languageStrings);
await FinishSetup.takeScreenshot(languageStrings);
await FinishSetup.tapButton(languageStrings);
Expand Down
35 changes: 0 additions & 35 deletions e2e/onboarding/NoAuthSubscriptionPermission.spec.js

This file was deleted.

4 changes: 2 additions & 2 deletions ios/COVIDSafePaths/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>1.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>25</string>
<key>LSRequiresIPhoneOS</key>
<true />
<key>NSAppTransportSecurity</key>
Expand Down
4 changes: 2 additions & 2 deletions ios/COVIDSafePathsTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<string>1.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>25</string>
</dict>
</plist>
Loading

0 comments on commit 77d7fc2

Please sign in to comment.