Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settings screen #326

Merged
merged 88 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
ff98f67
Create Settings screen
SamMakesThings Mar 26, 2020
e1660a9
Add navigation and translation for new screen
SamMakesThings Mar 26, 2020
a561c35
Remove irrelevant components from Settings screen
SamMakesThings Mar 27, 2020
1d04e14
Add menu for authorities selection in Settings
SamMakesThings Mar 27, 2020
1304afb
Add stylized button, FlatList bit to Settings
SamMakesThings Mar 27, 2020
3d6ccb9
Add styling to flatlist rows, add close icon
SamMakesThings Mar 27, 2020
5c77802
Fix caps, add iterating menu off authorities obj
SamMakesThings Mar 27, 2020
3aa3ed7
Add add/remove data source functions
SamMakesThings Mar 27, 2020
275999a
Add translation variables and lines to Settings
SamMakesThings Mar 27, 2020
3d44bbc
Fix menu icon color from purple to bluish grey
SamMakesThings Mar 27, 2020
1aa8682
Remove unnecessary whitespace in translation
SamMakesThings Mar 27, 2020
b05202f
Prevent duplicates from authorities list
SamMakesThings Mar 29, 2020
54caf4a
Add custom URL input (all function)
SamMakesThings Mar 29, 2020
3adcb63
Add check for connection, let user know if error
SamMakesThings Mar 29, 2020
bb525d8
Now pulls authorities list from internet source
SamMakesThings Mar 29, 2020
7845213
Store user settings in async storage
SamMakesThings Mar 31, 2020
81c43e3
Version 0.5.4 (Build 9) (#161)
vitorpamplona Mar 23, 2020
8351bde
Example code for private-set point intersection (#163)
penrods Mar 24, 2020
5798589
V2overlap (#166)
tremblerz Mar 24, 2020
65fcf86
Automating Version & Build Numbers (#169)
vitorpamplona Mar 24, 2020
173c845
Add NL (Dutch) locale (#172)
njdehoog Mar 24, 2020
535fbd6
Changetext (#175)
tremblerz Mar 24, 2020
ac652a0
Version 0.5.6 (#177)
vitorpamplona Mar 24, 2020
fb2b9ea
moving pod install command to npm run install:pod (#173)
Utzel-Butzel Mar 24, 2020
bd5c116
Improve data exporter to share data with better names (#174)
tushar-dadlani Mar 24, 2020
97e08f2
Add support for 'Marathi' locale (#154)
code247 Mar 24, 2020
402f92b
Translated pt locations files (#125)
douglara Mar 24, 2020
aec28fd
fixing broken link to issue list (#186)
greggles Mar 24, 2020
c78e91f
Fix formatting in languages json due to merge (#183)
thetimbanks Mar 24, 2020
dfd99dd
Added feedback for trace overlap if it comes back with no results (#190)
SamMakesThings Mar 25, 2020
d981c12
minor version bump to clear Xcode warnings (#168)
rparet Mar 25, 2020
611cc07
Bluetooth Broadcasting on Android. (#193)
vitorpamplona Mar 25, 2020
4cb9405
Fix broken layout on low-res devices using flex layout on LocationTra…
SamMakesThings Mar 25, 2020
e5b666e
Update CSV data source, refine text (#197)
penrods Mar 25, 2020
6de8a39
Version: 0.5.8 (#198)
vitorpamplona Mar 25, 2020
33417d4
Fix typo in location tracking url_info text (#200)
thetimbanks Mar 25, 2020
3eae9e6
Enhancing the License screen (#202)
penrods Mar 25, 2020
76155f2
Fix circles crash by only showing nearby circles (#212)
tremblerz Mar 26, 2020
0864ea8
ESlint added and removed few errors (#201)
harshvitra Mar 26, 2020
caa2cae
Added Loader for Webviews (#206)
harshvitra Mar 26, 2020
0ad7491
Change color of three dot menu button to match the color of other but…
pathakparth Mar 26, 2020
126c4cb
Migrating Bluetooth library to 0.0.5 (#214)
vitorpamplona Mar 26, 2020
dc3e215
Add code formatting rules with git-hooks #189 (#210)
pathakparth Mar 26, 2020
52873d5
Brazilian Portuguese language support (#229)
alpita-masurkar Mar 27, 2020
e61903f
Dutch translation (#225)
alpita-masurkar Mar 27, 2020
22eef9e
Andynuzzo/it (#223)
andreanuzzo Mar 27, 2020
2de8dbf
Update macos_build.yml (#236)
rparet Mar 27, 2020
652cb34
Typo fix from Enrico Santus on latest (#239)
alpita-masurkar Mar 27, 2020
963e3df
Add jest snapshot testing to the main views (#187)
thetimbanks Mar 27, 2020
bb63e15
Italian missing licenses file- Andy's translation added (#241)
alpita-masurkar Mar 27, 2020
2504efe
Add custom map styles to the Overlap map (#246)
thetimbanks Mar 27, 2020
c7da2b3
Haitian Creole with Translation Inputs from Gerald McElroy (#238)
alpita-masurkar Mar 27, 2020
30eca43
Spanish language support based on Miquel Vila Porté's translation (#245)
alpita-masurkar Mar 27, 2020
266ed43
Notification UI to show histogram and day wise list of intersections …
tremblerz Mar 27, 2020
540e4fb
Fixed 'Always Allow' for iOS (#97)
1geek0 Mar 27, 2020
c3d9824
Change the ui of Notifications (#254)
harshvitra Mar 28, 2020
dd5cf1e
Fix design and remove url (#255)
harshvitra Mar 28, 2020
07f6ffb
Cleanup react warning on the Overlap screen (#249)
thetimbanks Mar 28, 2020
113bf6d
Fixed text in the Notifications page (#256)
harshvitra Mar 28, 2020
c669309
Update Export screen to show more accurate log data (#244)
thetimbanks Mar 28, 2020
90ea69c
Change location marker and description, get rid of redundant markers …
tremblerz Mar 28, 2020
24b7356
Minor bug fixes in Share and Overlap features (#265)
tremblerz Mar 29, 2020
a5525be
Create Settings screen
SamMakesThings Mar 26, 2020
f478555
Add navigation and translation for new screen
SamMakesThings Mar 26, 2020
e5381cd
Remove irrelevant components from Settings screen
SamMakesThings Mar 27, 2020
1e8468e
Add menu for authorities selection in Settings
SamMakesThings Mar 27, 2020
283350f
Add stylized button, FlatList bit to Settings
SamMakesThings Mar 27, 2020
4f2f331
Add styling to flatlist rows, add close icon
SamMakesThings Mar 27, 2020
02b2ee8
Fix caps, add iterating menu off authorities obj
SamMakesThings Mar 27, 2020
6b452c6
Add add/remove data source functions
SamMakesThings Mar 27, 2020
32a578b
Add translation variables and lines to Settings
SamMakesThings Mar 27, 2020
0f0213d
Fix menu icon color from purple to bluish grey
SamMakesThings Mar 27, 2020
d0b0c29
Remove unnecessary whitespace in translation
SamMakesThings Mar 27, 2020
337dd38
Prevent duplicates from authorities list
SamMakesThings Mar 29, 2020
b0cad46
Add custom URL input (all function)
SamMakesThings Mar 29, 2020
ef10927
Add check for connection, let user know if error
SamMakesThings Mar 29, 2020
a4b96e7
Now pulls authorities list from internet source
SamMakesThings Mar 29, 2020
dc3b1f7
Store user settings in async storage
SamMakesThings Mar 31, 2020
4087077
Hopefully fix the git mess that somehow happened?
SamMakesThings Mar 31, 2020
57c534e
Merge branch 'add-settings' of https://github.com/StartupSam/private-…
SamMakesThings Mar 31, 2020
c4ca010
Fix delay bug in async settings storage
SamMakesThings Mar 31, 2020
d16f088
Fix null settings bug on fresh install
SamMakesThings Mar 31, 2020
df0028f
Delete macos_build.yml
Apr 1, 2020
d4fa8b7
Delete CONTRIBUTING.md
Apr 1, 2020
0f55967
fixed syntax error in gj labels block on dev, languages.js (#318)
alpita-masurkar Apr 2, 2020
fa7312a
Merge remote-tracking branch 'origin/develop' into add-settings
corbt Apr 3, 2020
2eab9cc
Revert formatting changes
corbt Apr 3, 2020
9efb05c
Merge branch 'safe-paths' into add-settings
tremblerz Apr 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 0 additions & 121 deletions .github/workflows/macos_build.yml

This file was deleted.

6 changes: 6 additions & 0 deletions app/Entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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';
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/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ i18next.init({
gj: {
translation: {
label: gjlabels,
}
},
},
cs: {
translation: {
Expand Down
Loading