Skip to content

Commit

Permalink
Merge Safe paths branch into develop (#328)
Browse files Browse the repository at this point in the history
* Add Settings Screen - #150 (#160)

* Remove Additional Stop Location Recording

* Add Settings Screen

* Add Intersection of points download from authority (#165)

With this PR the app now:

* Contacts each authority URL once every 12 hours
* Downloads intersection data from that authority
* Runs a simple point intersection against it
* Saves the exposure results in the CROSSED_PATHS storage array
* Still several things to do for an MVP, then more to optimize:

Authority cannot be edited yet (in Settings)
* No display of CROSSED_PATHS
* Only results from one Authority are saved
* Improve overlap calculation accuracy
* Optimize the intersection calculation

* Fix export issue

* Add settings screen (#326)

* Create Settings screen

* Add navigation and translation for new screen

* Remove irrelevant components from Settings screen

* Add menu for authorities selection in Settings

* Add stylized button, FlatList bit to Settings

* Add styling to flatlist rows, add close icon

* Fix caps, add iterating menu off authorities obj

* Add add/remove data source functions

* Add translation variables and lines to Settings

* Fix menu icon color from purple to bluish grey

* Remove unnecessary whitespace in translation

* Prevent duplicates from authorities list

* Add custom URL input (all function)

* Add check for connection, let user know if error

* Now pulls authorities list from internet source

* Store user settings in async storage

* Version 0.5.4 (Build 9) (#161)

* Simple Script to reset react native

* Version 0.5.4 (Build 9)

* Example code for private-set point intersection (#163)

Add a complete Pytyon example of performing private set intersection.
This solution give pretty good privacy, estimated at approximately
10 days to crack a single published lat/lon/time point.

This is donated to the Private Kit project by Triple Blind, and
may be freely used within the project.

* V2overlap (#166)

* display map

* working v2; only android

* improve and optimize map support;android only

* add heatmap code

* Automating Version & Build Numbers (#169)

* Adding version and build number automator (Changes ReactNative, iOS and Android upon npm version).

* Removing Build Number from Targets on Xcode so that npm version with react-native-version can update the number automatically.

* Test Bundle version and Main Bundle version should be the same.

* 0.5.5

* Add NL (Dutch) locale (#172)

* Changetext (#175)

* Add News, Import, Export buttons

* add new colors

* add positive and sensitive buttons

* change button color in the main menu

* change text for overlap screen

* Version 0.5.6 (#177)

* Adding version and build number automator (Changes ReactNative, iOS and Android upon npm version).

* Removing Build Number from Targets on Xcode so that npm version with react-native-version can update the number automatically.

* Test Bundle version and Main Bundle version should be the same.

* 0.5.5

* Production API keys.

* 0.5.6

* moving pod install command to npm run install:pod (#173)

* Improve data exporter to share data with better names (#174)

* Write file to filesystem before sharing

* Enhance sharing data output

- Updated react-native-share to 3.1.0 because of [issue](react-native-share/react-native-share#702)
- Separated out iOS specific and android share logic as the behaviors for sharing are significanlty different even for a simple case like filename

* Add support for 'Marathi' locale (#154)

* Add support for 'Marathi' locale

* Incorporate review suggestions

Co-authored-by: Sagar Manohar <[email protected]>
Co-authored-by: Abhishek Singh <[email protected]>

* Translated pt locations files (#125)

* Translated locations files from ingles to pt-br

* Updated sentence for better semantics, remintz suggestion

* Fix typo

* fixing broken link to issue list (#186)

* Fix formatting in languages json due to merge (#183)

This fixes a formatting issue due to a merge. Languages were added in multiple PRs and they didn't get merged together correctly.

* Added feedback for trace overlap if it comes back with no results (#190)

See issue #188 - I'd advise this is merged ASAP since the current build feels broken from a user perspective.

* minor version bump to clear Xcode warnings (#168)

Co-authored-by: Vitor Pamplona <[email protected]>

* Bluetooth Broadcasting on Android.  (#193)

* Running build on develop.

* Keeping action to Master

* Starting Bluetooth Beacon Broadcasting.

* Other ID was too big.

* Only runs Bluetooth on Android

* Changing Package version to 0.0.4 to pass tests on Phones without Bluetooth adapters.

* Fix broken layout on low-res devices using flex layout on LocationTracking.js and Overlap.js (#196)

* quality of life improvements

* Add dynamic button text for trace overlap results

* Reenabled Prettier in Overlap.js but didn't format

* Add translation for overlap button text and title

* Move website link footer inside scrollview

* Use flex layout to fix display on low-res devices

* Update CSV data source, refine text (#197)

* Update CSV data source, refine text

The source of the public data moved, breaking this feature.  Also
refined the text show and added a link to the public dataset.

* Change terminology for now

* Version: 0.5.8 (#198)

* Running build on develop.

* Keeping action to Master

* Starting Bluetooth Beacon Broadcasting.

* Other ID was too big.

* Only runs Bluetooth on Android

* Changing Package version to 0.0.4 to pass tests on Phones without Bluetooth adapters.

* 0.5.7

* 0.5.8

* Fix typo in location tracking url_info text (#200)

* Enhancing the License screen (#202)

* Enhancing the License screen

The kebab > License screen now is a combination of an About screen
and a license.  The top of the screen shows information about the current
app version, OS version on which it is running and screen resolution info.

Below that is license test.  It pulls from the new LICENSE.json in the
assets directory.  It will render an array of licenses, so later we can
add the licenses of components we use in addition to the main Private
Kit MIT license.

* Remove debugging console.log() message

* Fix circles crash by only showing nearby circles (#212)

* ESlint added and removed few errors (#201)

Co-authored-by: Harsh Vitra <[email protected]>

* Added Loader for Webviews (#206)

Co-authored-by: Harsh Vitra <[email protected]>

* Change color of three dot menu button to match the color of other button elements - #178 (#208)

* Migrating Bluetooth library to 0.0.5 (#214)

* Add code formatting rules with git-hooks #189 (#210)

* Brazilian Portuguese language support (#229)

* Dutch translation (#225)

* Update index.js

* Update locationTracking.json

* Create overlap.json

* Andynuzzo/it (#223)

* Update macos_build.yml (#236)

Fix breaking gradle error

* Typo fix from Enrico Santus on latest (#239)

* Add jest snapshot testing to the main views (#187)

* Add jest snapshot testing to the main views

    This adds jest snapshot testing the main views for the application. The
    main views it covers are:

    * Export
    * Import
    * Licenses
    * LocationTracking
    * News
    * Overlap
    * Welcome

    The tests are run using `yarn test`.

    Mock setup has been added for some of the react native packages so the testing
    doesn't have to rely on the packages.

    Cleaned up some of the formatting in the language files to not include the trailing
    comma on the last property. This was throwing errors for some of the jest tests.

    Add jestSetupFile to setup some of the mocks for the tests

* Update tests after rebasing the develop branch

* Fix LICENSES json due to failing test

* Add mock for react-native-zip-archive

* Italian missing licenses file- Andy's translation added (#241)

* Andy's translation for the missing licenses file

* Update index.js

* Add custom map styles to the Overlap map (#246)

The custom styles were taken from https://snazzymaps.com/style/127403/no-label-bright-colors
which was linked to in the issue #243

Closes #243

* Haitian Creole with Translation Inputs from Gerald McElroy (#238)

* Spanish language support based on Miquel Vila Porté's translation (#245)

* Notification UI to show histogram and day wise list of intersections (#237)

* Add News, Import, Export buttons

* add new colors

* add positive and sensitive buttons

* change button color in the main menu

* notification UI

* remove callback for button

* Fixed 'Always Allow' for iOS (#97)

* 1. Added RN permissions to dependencies.
2. Added location permissions in AndroidManifest.xml

* 1. Permissions now handled by react-native-permissions
2. If platform is iOS 12.x.x or earlier. Directly acquire 'Always Allow' permission
3. If platform is iOS 13.0 or later, redirect to app settings.
Apps cannot directly ask for 'Always Allow' post iOS 13.

* Added comments

* Added yarn.lock and Podfile.lock to gitignore

* No changes

* Added lock files

* Removed Podfile.lock

Co-authored-by: Rich Paret <[email protected]>
Co-authored-by: Abhishek Singh <[email protected]>

* Change the ui of Notifications (#254)

Co-authored-by: Harsh Vitra <[email protected]>

* Fix design and remove url (#255)

Co-authored-by: Harsh Vitra <[email protected]>

* Cleanup react warning on the Overlap screen (#249)

There were some react warnings being thrown due to the key
prop not being set on some components. This sets the key prop
on the components that are added in a loop

* Fixed text in the Notifications page (#256)

* Fixed Text on Notifications page

* Fixed Font size of Export

Co-authored-by: Harsh Vitra <[email protected]>

* Update Export screen to show more accurate log data (#244)

* Update Export screen to show more accurate log data

This is a pretty update to how the Export screen works and how the
log data is modified.

The Export screen component was rewritten as a functional component
in order to take advantage of hooks. The use for the hooks is to
update the log data details when the Export component comes in to
focus. The old version would only update the data once since the
component would mount and never unmount leading to stale data. The
new Export component will update the log details each time the view
comes in to focus. The log details have now been broken up in to
3 sections: Total time the log covers, Number of points logged, and
Time since last updated.

The LocationService has been updated with a new class called
LocationData. This take the old saveLocation method and makes it
an instance method on the LocationData class. This also allows
access to the location data that is in memory in order for the
Export screen to show more accurate details. The LocationService
has been updated to use this new class when saving the location
data.

* Revert change to the location time interval

* Remove old references to some variable names

* Fix export tests due to changes

* Add LocationData tests

* Remove old test file

* Change location marker and description, get rid of redundant markers as well (#250)

* Add News, Import, Export buttons

* add new colors

* add positive and sensitive buttons

* change button color in the main menu

* change marker icon and description

* remove maps-clustering package

* Minor bug fixes in Share and Overlap features (#265)

* Create Settings screen

* Add navigation and translation for new screen

* Remove irrelevant components from Settings screen

* Add menu for authorities selection in Settings

* Add stylized button, FlatList bit to Settings

* Add styling to flatlist rows, add close icon

* Fix caps, add iterating menu off authorities obj

* Add add/remove data source functions

* Add translation variables and lines to Settings

* Fix menu icon color from purple to bluish grey

* Remove unnecessary whitespace in translation

* Prevent duplicates from authorities list

* Add custom URL input (all function)

* Add check for connection, let user know if error

* Now pulls authorities list from internet source

* Store user settings in async storage

* Hopefully fix the git mess that somehow happened?

* Fix delay bug in async settings storage

* Fix null settings bug on fresh install

* Delete macos_build.yml

* Delete CONTRIBUTING.md

* fixed syntax error in gj labels block on dev, languages.js (#318)

* Revert formatting changes

Co-authored-by: Sam Stowers <[email protected]>
Co-authored-by: Vitor Pamplona <[email protected]>
Co-authored-by: Steve Penrod <[email protected]>
Co-authored-by: Abhishek Singh <[email protected]>
Co-authored-by: Niels de Hoog <[email protected]>
Co-authored-by: Robert Gühne <[email protected]>
Co-authored-by: Tushar Dadlani <[email protected]>
Co-authored-by: Sagar Manohar <[email protected]>
Co-authored-by: Sagar Manohar <[email protected]>
Co-authored-by: Douglas Lara <[email protected]>
Co-authored-by: Greg Knaddison <[email protected]>
Co-authored-by: Tim Banks <[email protected]>
Co-authored-by: Rich Paret <[email protected]>
Co-authored-by: Harsh Vitra <[email protected]>
Co-authored-by: Harsh Vitra <[email protected]>
Co-authored-by: Parth Pathak <[email protected]>
Co-authored-by: alpita-masurkar <[email protected]>
Co-authored-by: Andy Nuzzo <[email protected]>
Co-authored-by: Nilay Kulkarni <[email protected]>
Co-authored-by: Steve Penrod <[email protected]>

* Update Entry.js

* Fix merge issues (#330)

Co-authored-by: David Biga <[email protected]>
Co-authored-by: Steve Penrod <[email protected]>
Co-authored-by: Kyle Corbitt <[email protected]>
Co-authored-by: Sam Stowers <[email protected]>
Co-authored-by: Vitor Pamplona <[email protected]>
Co-authored-by: Niels de Hoog <[email protected]>
Co-authored-by: Robert Gühne <[email protected]>
Co-authored-by: Tushar Dadlani <[email protected]>
Co-authored-by: Sagar Manohar <[email protected]>
Co-authored-by: Sagar Manohar <[email protected]>
Co-authored-by: Douglas Lara <[email protected]>
Co-authored-by: Greg Knaddison <[email protected]>
Co-authored-by: Tim Banks <[email protected]>
Co-authored-by: Rich Paret <[email protected]>
Co-authored-by: Harsh Vitra <[email protected]>
Co-authored-by: Harsh Vitra <[email protected]>
Co-authored-by: Parth Pathak <[email protected]>
Co-authored-by: alpita-masurkar <[email protected]>
Co-authored-by: Andy Nuzzo <[email protected]>
Co-authored-by: Nilay Kulkarni <[email protected]>
Co-authored-by: Steve Penrod <[email protected]>
  • Loading branch information
1 parent 0f55967 commit 0f48894
Show file tree
Hide file tree
Showing 19 changed files with 961 additions and 93 deletions.
8 changes: 3 additions & 5 deletions __mocks__/react-native-i18n.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export function getLanguages() {
return new Promise((resolve, reject) => {
process.nextTick(() =>
resolve(['en-US'])
);
})
};
process.nextTick(() => resolve(['en-US']));
});
}
8 changes: 7 additions & 1 deletion app/Entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import NewsScreen from './views/News';
import ExportScreen from './views/Export';
import ImportScreen from './views/Import';
import OverlapScreen from './views/Overlap';
import SettingsScreen from './views/Settings';
import LicencesScreen from './views/Licenses';
import NotificationScreen from './views/Notification';
import Slider from './views/welcomeScreens/Slider';
import { GetStoreData } from './helpers/General';
import { GetStoreData, SetStoreData } from './helpers/General';

const Stack = createStackNavigator();

Expand Down Expand Up @@ -83,6 +84,11 @@ class Entry extends Component {
component={ImportScreen}
options={{ headerShown: false }}
/>
<Stack.Screen
name='SettingsScreen'
component={SettingsScreen}
options={{ headerShown: false }}
/>
<Stack.Screen
name='LicensesScreen'
component={LicencesScreen}
Expand Down
Binary file added app/assets/images/closeIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/images/kebabIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/saveIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
149 changes: 149 additions & 0 deletions app/helpers/Intersect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/**
* Intersect a set of points against the user's locally stored points.
*
* v1 - Unencrypted, simpleminded (minimal optimization).
*/

import { GetStoreData, SetStoreData } from '../helpers/General';

export async function IntersectSet(concernLocationArray) {
GetStoreData('LOCATION_DATA').then(locationArrayString => {
var locationArray;
if (locationArrayString !== null) {
locationArray = JSON.parse(locationArrayString);
} else {
locationArray = [];
}

let dayBin = [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
]; // Bins for 28 days

// Sort the concernLocationArray
let localArray = normalizeData(locationArray);
let concernArray = normalizeData(concernLocationArray);

let concernTimeWindow = 1000 * 60 * 60 * 2; // +/- 2 hours window
let concernDistWindow = 60; // distance of concern, in feet

// At 38 degrees North latitude:
let ftPerLat = 364000; // 1 deg lat equals 364,000 ft
let ftPerLon = 288200; // 1 deg of longitude equals 288,200 ft

var nowUTC = new Date().toISOString();
var timeNow = Date.parse(nowUTC);

// Save a little CPU, no need to do sqrt()
let concernDistWindowSq = concernDistWindow * concernDistWindow;

// Both locationArray and concernLocationArray should be in the
// format [ { "time": 123, "latitude": 12.34, "longitude": 34.56 }]

for (let loc of localArray) {
let timeMin = loc.time - concernTimeWindow;
let timeMax = loc.time + concernTimeWindow;

let i = binarySearchForTime(concernArray, timeMin);
if (i < 0) i = -(i + 1);

while (i < concernArray.length && concernArray[i].time <= timeMax) {
// Perform a simple Euclidian distance test
let deltaLat = (concernArray[i].latitude - loc.latitude) * ftPerLat;
let deltaLon = (concernArray[i].longitude - loc.longitude) * ftPerLon;
// TODO: Scale ftPer factors based on lat to reduce projection error

let distSq = deltaLat * deltaLat + deltaLon * deltaLon;
if (distSq < concernDistWindowSq) {
// Crossed path. Bin the count of encounters by days from today.
let longAgo = timeNow - loc.time;
let daysAgo = Math.round(longAgo / (1000 * 60 * 60 * 24));

dayBin[daysAgo] += 1;
}

i++;
}
}

// TODO: Show in the UI!
console.log('Crossing results: ', dayBin);
SetStoreData('CROSSED_PATHS', dayBin); // TODO: Store per authority?
});
}

function normalizeData(arr) {
// This fixes several issues that I found in different input data:
// * Values stored as strings instead of numbers
// * Extra info in the input
// * Improperly sorted data (can happen after an Import)
var result = [];

for (var i = 0; i < arr.length; i++) {
elem = arr[i];
if ('time' in elem && 'latitude' in elem && 'longitude' in elem) {
result.push({
time: Number(elem.time),
latitude: Number(elem.latitude),
longitude: Number(elem.longitude),
});
}
}

result.sort();
return result;
}

function binarySearchForTime(array, targetTime) {
// Binary search:
// array = sorted array
// target = search target
// Returns:
// value >= 0, index of found item
// value < 0, i where -(i+1) is the insertion point
var i = 0;
var n = array.length - 1;

while (i <= n) {
var k = (n + i) >> 1;
var cmp = targetTime - array[k].time;

if (cmp > 0) {
i = k + 1;
} else if (cmp < 0) {
n = k - 1;
} else {
// Found exact match!
// NOTE: Could be one of several if array has duplicates
return k;
}
}
return -i - 1;
}
2 changes: 2 additions & 0 deletions app/locales/en/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import exportFile from './exportscreen.json';
import licensesFile from './licensesscreen.json';
import overlapFile from './overlap.json';
import notificationFile from './notification.json';
import settingsFile from './settingsScreen.json';

export default {
...intro,
Expand All @@ -14,4 +15,5 @@ export default {
...overlapFile,
...licensesFile,
...notificationFile,
...settingsFile,
};
6 changes: 3 additions & 3 deletions app/locales/en/overlap.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"overlap_title": "Check Overlap",
"overlap_para_1": "The green trail represents your location history\n\nThe light purple circles represent the public dataset",
"show_overlap": "Click to view the public dataset",
"loading_public_data": "loading data...",
"overlap_para_1": "Green circles are clusters of your locations, click to zoom. Red markers are your recorded locations.\n\nPress the button to download public information of confirmed cases, shown as faint purple circles.",
"show_overlap": "Check Public Data",
"loading_public_data": "Loading Data...",
"overlap_no_results_button_label": "Public Data Loaded",
"overlap_found_button_label": "Public Data Loaded",
"nCoV2019_url_info": "For more information on the dataset for this map",
Expand Down
16 changes: 16 additions & 0 deletions app/locales/en/settingsScreen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"settings_title": "Settings",
"authorities_title": "Trusted Sources",
"authorities_desc": "You can get data from one or more healthcare authorities that you trust. Either select a name from the global registry, or enter the web address of an authority you trust that's implemented Safe Paths.",
"authorities_removal_alert_title": "Remove authority",
"authorities_removal_alert_desc": "Are you sure you want to remove this authority data source?",
"authorities_removal_alert_cancel": "Cancel",
"authorities_removal_alert_proceed": "Procceed",
"authorities_no_sources": "No data sources yet! Tap below to add one.",
"authorities_add_button_label": "Add Trusted Source",
"authorities_coming_soon_title": "Coming soon",
"authorities_coming_soon_desc": "You'll be able to add custom data sources in an imminent update.",
"authorities_done": "Done",
"authorities_add_url": "Add authority via URL",
"authorities_input_placeholder": "Paste your URL here"
}
2 changes: 1 addition & 1 deletion app/locales/fr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export default {
...overlapFile,
...licensesFile,
...notificationFile,
};
};
12 changes: 6 additions & 6 deletions app/locales/ht/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import licensesFile from './licensesscreen.json';
import overlapFile from './overlap.json';

export default {
...intro,
...locationTracking,
...importFile,
...exportFile,
...overlapFile,
...licensesFile,
...intro,
...locationTracking,
...importFile,
...exportFile,
...overlapFile,
...licensesFile,
};
12 changes: 6 additions & 6 deletions app/locales/it/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import licensesFile from './licensesscreen.json';
import overlapFile from './overlap.json';

export default {
...intro,
...locationTracking,
...importFile,
...exportFile,
...overlapFile,
...licensesFile,
...intro,
...locationTracking,
...importFile,
...exportFile,
...overlapFile,
...licensesFile,
};
12 changes: 6 additions & 6 deletions app/locales/pt_BR/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import licensesFile from './licensesscreen.json';
import overlapFile from './overlap.json';

export default {
...intro,
...locationTracking,
...importFile,
...exportFile,
...overlapFile,
...licensesFile,
...intro,
...locationTracking,
...importFile,
...exportFile,
...overlapFile,
...licensesFile,
};
Loading

0 comments on commit 0f48894

Please sign in to comment.