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

Create the iOS version of the status screen #812

Merged
merged 6 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,17 @@ $ cp ..... www/json/connectionConfig.json
$ source setup/activate_native.sh
```

### Activation (after install, and in every new shell)

If connecting to a development server over http, make sure to turn on http support on android

```
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true"/>
</edit-config>
```

Run in the emulator
### Run in the emulator

```
$ npx cordova emulate ios
Expand Down
2 changes: 1 addition & 1 deletion config.cordovabuild.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="42" id="edu.berkeley.eecs.emission" ios-CFBundleVersion="42" version="3.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget android-versionCode="43" id="edu.berkeley.eecs.emission" ios-CFBundleVersion="43" version="3.2.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>emission</name>
<description>
A commute pattern tracker and carbon footprint estimator.
Expand Down
13 changes: 7 additions & 6 deletions package.cordovabuild.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edu.berkeley.eecs.emission",
"version": "3.1.0",
"version": "3.2.0",
"displayName": "emission",
"license": "BSD-3-Clause",
"repository": {
Expand Down Expand Up @@ -58,7 +58,8 @@
},
"cordova-plugin-em-server-communication": {},
"cordova-plugin-em-datacollection": {
"LOCATION_VERSION": "17.0.0"
"LOCATION_VERSION": "18.0.0",
"ANDROIDX_CORE_VERSION": "1.7.0"
},
"cordova-plugin-em-serversync": {},
"cordova-plugin-em-settings": {},
Expand All @@ -77,14 +78,14 @@
"cordova-plugin-app-version": "0.1.12",
"cordova-plugin-customurlscheme": "5.0.2",
"cordova-plugin-device": "2.0.3",
"cordova-plugin-em-datacollection": "git+https://github.com/e-mission/e-mission-data-collection.git#v1.6.1",
"cordova-plugin-em-datacollection": "git+https://github.com/e-mission/e-mission-data-collection.git#v1.7.0",
"cordova-plugin-em-jwt-auth": "git+https://github.com/e-mission/cordova-jwt-auth.git#v1.6.5",
"cordova-plugin-em-server-communication": "git+https://github.com/e-mission/cordova-server-communication.git#v1.2.3",
"cordova-plugin-em-serversync": "git+https://github.com/e-mission/cordova-server-sync.git#v1.2.6",
"cordova-plugin-em-serversync": "git+https://github.com/e-mission/cordova-server-sync.git#v1.2.7",
"cordova-plugin-em-settings": "git+https://github.com/e-mission/cordova-connection-settings.git#v1.2.2",
"cordova-plugin-em-transition-notify": "git+https://github.com/e-mission/e-mission-transition-notify.git#v1.2.6",
"cordova-plugin-em-unifiedlogger": "git+https://github.com/e-mission/cordova-unified-logger.git#v1.3.3",
"cordova-plugin-em-usercache": "git+https://github.com/e-mission/cordova-usercache.git#v1.1.3",
"cordova-plugin-em-unifiedlogger": "git+https://github.com/e-mission/cordova-unified-logger.git#v1.3.5",
"cordova-plugin-em-usercache": "git+https://github.com/e-mission/cordova-usercache.git#v1.1.4",
"cordova-plugin-email-composer": "0.9.2",
"cordova-plugin-file": "6.0.2",
"cordova-plugin-inappbrowser": "5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion www/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ span.rz-bar-wrapper {

/*Change later*/
.metric-second-half {
width: 105px;
width: 90%;
margin: auto;
}
.metric-current-title {
Expand Down
14 changes: 10 additions & 4 deletions www/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,15 @@

"intro": {
"appstatus": {
"overall-description": "This app works in the background to automatically build a travel diary for you. Make sure that all the settings below are green so that the app can work properly!",
"overall-loc-name": "Location",
"overall-loc-description": "We use the background location permission to track your location in the background, even when the app is closed. Reading background locations removes the need to turn tracking on and off, making the app easier to use and preventing battery drain.",
"locsettings": {
"name": "Location Settings",
"description": {
"android-lt-9": "Location services should be enabled and set to High Accuracy. This allows us to accurately record the trajectory of the travel",
"android-gte-9": "Location services should be enabled. This allows us to access location data and generate the trip log",
"ios": "Placeholder"
"ios": "Location services should be enabled. This allows us to access location data and generate the trip log"
}
},
"locperms": {
Expand All @@ -331,11 +333,13 @@
"android-6-9": "Please select 'allow'",
"android-10": "Please select 'Allow all the time'",
"android-gte-11": "On the app settings page, choose the 'Location' permission and set it to 'Allow all the time'",
"ios": "Placeholder"
"ios-lt-13": "Please select 'Always allow'",
"ios-gte-13": "On the app settings page, please select 'Always' and 'Precise' and return here to continue"
}
},
"overall-fitness-name-android": "Physical activity",
"overall-fitness-name-ios": "Motion & Fitness",
"overall-fitness-name-ios": "Motion and Fitness",
"overall-fitness-description": "The fitness sensors distinguish between walking, bicycling and motorized modes. We use this data in order to separate the parts of multi-modal travel such as transit. We also use it to as a cross-check potentially spurious trips - if the location sensor jumps across town but the fitness sensor is stationary, we can guess that the trip was invalid.",
"fitnessperms": {
"name": "Fitness Permission",
"description": {
Expand All @@ -344,16 +348,18 @@
}
},
"overall-notification-name": "Notifications",
"overall-notification-description": "We need to use notifications to inform you if the settings are incorrect. We also use hourly invisible push notifications to wake up the app and allow it to upload data and check app status. We also use notifications to remind you to label your trips.",
"notificationperms": {
"app-enabled-name": "App Notifications",
"not-paused-name": "Not Paused",
"description": {
"android-enable": "On the app settings page, ensure that all notifications and channels are enabled.",
"android-unpause": "On the app settings page, ensure that all notifications are enabled. If this doesn't fix the problem, ask for help from your admin",
"ios": "Please allow."
"ios-enable": "Please allow, on the popup or the app settings page if necessary"
}
},
"overall-background-restrictions-name": "Background restrictions",
"overall-background-restrictions-description": "The app runs in the background most of the time to make your life easier. You only need to open it periodically to label trips. Android sometimes restricts apps from working in the background. This prevents us from generating an accurate trip diary. Please remove background restrictions on this app.",
"unusedapprestrict": {
"name": "Unused apps disabled",
"description": {
Expand Down
86 changes: 78 additions & 8 deletions www/js/appstatus/permissioncheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
}

$scope.setupNotificationChecks = function(platform, version) {
if (platform.toLowerCase() == "android") {
return $scope.setupAndroidNotificationChecks(version);
} else if (platform.toLowerCase() == "ios") {
return $scope.setupIOSNotificationChecks(version);
} else {
alert("Unknown platform, no tracking");
}
return $scope.setupAndroidNotificationChecks(version);
}

$scope.setupBackgroundRestrictionChecks = function(platform, version) {
Expand All @@ -53,7 +47,8 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
return $scope.setupAndroidBackgroundRestrictionChecks(version);
} else if (platform.toLowerCase() == "ios") {
$scope.backgroundUnrestrictionsNeeded = false;
return $scope.setupIOSBackgroundRestrictionChecks(version);
$scope.overallBackgroundRestrictionStatus = true;
return true;
} else {
alert("Unknown platform, no tracking");
}
Expand Down Expand Up @@ -204,6 +199,52 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
refreshChecks($scope.locChecks, $scope.recomputeLocStatus);
}

$scope.setupIOSLocChecks = function(platform, version) {
let fixSettings = function() {
console.log("Fix and refresh location settings");
return checkOrFix(locSettingsCheck, $window.cordova.plugins.BEMDataCollection.fixLocationSettings,
$scope.recomputeLocStatus, showError=true);
};
let checkSettings = function() {
console.log("Refresh location settings");
return checkOrFix(locSettingsCheck, $window.cordova.plugins.BEMDataCollection.isValidLocationSettings,
$scope.recomputeLocStatus, showError=false);
};
let fixPerms = function() {
console.log("fix and refresh location permissions");
return checkOrFix(locPermissionsCheck, $window.cordova.plugins.BEMDataCollection.fixLocationPermissions,
$scope.recomputeLocStatus, showError=true).then((error) => locPermissionsCheck.desc = error);
};
let checkPerms = function() {
console.log("fix and refresh location permissions");
return checkOrFix(locPermissionsCheck, $window.cordova.plugins.BEMDataCollection.isValidLocationPermissions,
$scope.recomputeLocStatus, showError=false);
};
var iOSSettingsDescTag = "intro.appstatus.locsettings.description.ios";
var iOSPermDescTag = "intro.appstatus.locperms.description.ios-gte-13";
if($scope.osver < 13) {
iOSPermDescTag = 'intro.appstatus.locperms.description.ios-lt-13';
}
console.log("description tags are "+iOSSettingsDescTag+" "+iOSPermDescTag);
// location settings
let locSettingsCheck = {
name: $translate.instant("intro.appstatus.locsettings.name"),
desc: $translate.instant(iOSSettingsDescTag),
statusState: false,
fix: fixSettings,
refresh: checkSettings
}
let locPermissionsCheck = {
name: $translate.instant("intro.appstatus.locperms.name"),
desc: $translate.instant(iOSPermDescTag),
statusState: false,
fix: fixPerms,
refresh: checkPerms
}
$scope.locChecks = [locSettingsCheck, locPermissionsCheck];
refreshChecks($scope.locChecks, $scope.recomputeLocStatus);
}

$scope.setupAndroidFitnessChecks = function(platform, version) {
$scope.fitnessPermNeeded = ($scope.osver >= 10);

Expand All @@ -229,6 +270,31 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,
refreshChecks($scope.fitnessChecks, $scope.recomputeFitnessStatus);
}

$scope.setupIOSFitnessChecks = function(platform, version) {
$scope.fitnessPermNeeded = true;

let fixPerms = function() {
console.log("fix and refresh fitness permissions");
return checkOrFix(fitnessPermissionsCheck, $window.cordova.plugins.BEMDataCollection.fixFitnessPermissions,
$scope.recomputeFitnessStatus, showError=true).then((error) => fitnessPermissionsCheck.desc = error);
};
let checkPerms = function() {
console.log("fix and refresh fitness permissions");
return checkOrFix(fitnessPermissionsCheck, $window.cordova.plugins.BEMDataCollection.isValidFitnessPermissions,
$scope.recomputeFitnessStatus, showError=false);
};

let fitnessPermissionsCheck = {
name: $translate.instant("intro.appstatus.fitnessperms.name"),
desc: $translate.instant("intro.appstatus.fitnessperms.description.ios"),
fix: fixPerms,
refresh: checkPerms
}
$scope.overallFitnessName = $translate.instant("intro.appstatus.overall-fitness-name-ios");
$scope.fitnessChecks = [fitnessPermissionsCheck];
refreshChecks($scope.fitnessChecks, $scope.recomputeFitnessStatus);
}

$scope.setupAndroidNotificationChecks = function() {
let fixPerms = function() {
console.log("fix and refresh notification permissions");
Expand Down Expand Up @@ -305,6 +371,10 @@ controller("PermissionCheckControl", function($scope, $element, $attrs,

$ionicPlatform.on("resume", function() {
console.log("PERMISSION CHECK: app has resumed, should refresh");
refreshChecks($scope.locChecks, $scope.recomputeLocStatus);
refreshChecks($scope.fitnessChecks, $scope.recomputeFitnessStatus);
refreshChecks($scope.notificationChecks, $scope.recomputeNotificationStatus);
refreshChecks($scope.backgroundRestrictionChecks, $scope.recomputeBackgroundRestrictionStatus);
});

$scope.$on("recomputeAppStatus", function() {
Expand Down
22 changes: 7 additions & 15 deletions www/templates/appstatus/permissioncheck.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
Make sure that all the settings below are green so that the app can work properly!
{{'intro.appstatus.overall-description' | translate }}

<details>
<summary><h4 ng-class="overallLocStatusClass"> {{ 'intro.appstatus.overall-loc-name' | translate }} {{overallLocStatusIcon}} </h4></summary>
We use location permissions to automatically generate a trip diary for annotation.
We use the background location permission to track your location in the
background, even when the app is closed. Reading background locations obviates
the need to turn tracking on and off, making the app easier to use and
preventing battery drain.
{{'intro.appstatus.overall-loc-description' | translate }}

<ion-list>
<ion-item ng-repeat="locCheck in locChecks">
<div class="row">
Expand All @@ -25,9 +22,8 @@
<div ng-if="fitnessPermNeeded">
<details>
<summary><h4 ng-class="overallFitnessStatusClass"> {{ overallFitnessName }} {{overallFitnessStatusIcon}} </h4></summary>
The fitness sensors distinguish between walking, bicycling and motorized modes.
We use this data in order to separate the parts of multi-modal travel such as
transit.
{{'intro.appstatus.overall-fitness-description' | translate }}

<ion-list>
<ion-item ng-repeat="fitnessCheck in fitnessChecks">
<div class="row">
Expand All @@ -46,7 +42,7 @@

<details>
<summary><h4 ng-class="overallNotificationStatusClass"> {{ 'intro.appstatus.overall-notification-name' | translate }} {{overallNotificationStatusIcon}}</h4></summary>
We need to use notifications to inform you if the settings are incorrect. We also use notifications to remind you to label your trips.
{{'intro.appstatus.overall-notification-description' | translate }}
<ion-list>
<ion-item ng-repeat="notificationCheck in notificationChecks">
<div class="row">
Expand All @@ -65,11 +61,7 @@
<div ng-if="backgroundUnrestrictionsNeeded">
<details>
<summary><h4 ng-class="overallBackgroundRestrictionStatusClass"> {{ 'intro.appstatus.overall-background-restrictions-name' | translate }} {{overallBackgroundRestrictionStatusIcon}} </h3> </summary>

The app runs in the background most of the time to make your life easier. You
only need to open it periodically to label trips. Android sometimes restricts
apps from working in the background. This prevents us from generating an
accurate trip diary. Please remove background restrictions on this app.
{{'intro.appstatus.overall-background-restrictions-description' | translate }}

<ion-list>
<ion-item ng-repeat="backgroundRestrictionCheck in backgroundRestrictionChecks">
Expand Down