From d69f3a50bfacf52a63f5a0c134650831c6ad1962 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Thu, 10 Feb 2022 15:52:25 -0800 Subject: [PATCH 1/6] Create the iOS version of the status screen - Replace placeholders with appropriate text - Add `scope.setupIOSLocChecks` and `scope.setupIOSFitnessChecks` - For notifications, we re-use the android settings - For background restrictions, we disable them since they don't exist (or at least, are not user controllable) on iOS --- www/i18n/en.json | 9 ++-- www/js/appstatus/permissioncheck.js | 82 ++++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 12 deletions(-) diff --git a/www/i18n/en.json b/www/i18n/en.json index 09cd115e1..1b434ad3f 100644 --- a/www/i18n/en.json +++ b/www/i18n/en.json @@ -321,7 +321,7 @@ "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": { @@ -331,11 +331,12 @@ "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", "fitnessperms": { "name": "Fitness Permission", "description": { @@ -350,7 +351,7 @@ "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", diff --git a/www/js/appstatus/permissioncheck.js b/www/js/appstatus/permissioncheck.js index 2c9861a0a..2e55688b9 100644 --- a/www/js/appstatus/permissioncheck.js +++ b/www/js/appstatus/permissioncheck.js @@ -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) { @@ -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"); } @@ -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); @@ -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"); From 8d8210aea033ad687ef5d7afd71223183186f1f7 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 22 Feb 2022 21:33:43 -0800 Subject: [PATCH 2/6] Ensure that the phone app headers are large enough If they are too narrow, they cause the actual footprint to be hidden. There is no known reason why they are an absolute, instead of a relative value. They are only used in this one place, so changing them should not break anything else. So we just change them back to a relative value More details: https://github.com/e-mission/e-mission-phone/pull/812#issuecomment-1048328735 https://github.com/e-mission/e-mission-phone/pull/812#issuecomment-1048359270 https://github.com/e-mission/e-mission-phone/pull/812#issuecomment-1048365598 https://github.com/e-mission/e-mission-phone/pull/812#issuecomment-1048461640 --- www/css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/css/style.css b/www/css/style.css index 0a507da52..618da4977 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -1370,7 +1370,7 @@ span.rz-bar-wrapper { /*Change later*/ .metric-second-half { - width: 105px; + width: 90%; margin: auto; } .metric-current-title { From 30c3173c0a98c0afb9e759f45fb8794dce807ea5 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 22 Feb 2022 23:09:49 -0800 Subject: [PATCH 3/6] Add instructions on enabling cleartext traffic For my future reference, if not for others :) --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b932685a..0c611181f 100644 --- a/README.md +++ b/README.md @@ -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 +``` + + + +``` -Run in the emulator +### Run in the emulator ``` $ npx cordova emulate ios From 353b2838e9e2b6d286bdf692689a248ab0e356b0 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 22 Feb 2022 23:11:29 -0800 Subject: [PATCH 4/6] Internationalize all the text This allows the Spanish and French groups to incorporate the changes as well + Modify some of the text at the same time to make it more clear --- www/i18n/en.json | 5 +++++ www/templates/appstatus/permissioncheck.html | 22 +++++++------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/www/i18n/en.json b/www/i18n/en.json index 1b434ad3f..dde9d8827 100644 --- a/www/i18n/en.json +++ b/www/i18n/en.json @@ -315,7 +315,9 @@ "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": { @@ -337,6 +339,7 @@ }, "overall-fitness-name-android": "Physical activity", "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": { @@ -345,6 +348,7 @@ } }, "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", @@ -355,6 +359,7 @@ } }, "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": { diff --git a/www/templates/appstatus/permissioncheck.html b/www/templates/appstatus/permissioncheck.html index b498b21a3..b2099bb81 100644 --- a/www/templates/appstatus/permissioncheck.html +++ b/www/templates/appstatus/permissioncheck.html @@ -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 }}

{{ 'intro.appstatus.overall-loc-name' | translate }} {{overallLocStatusIcon}}

-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 }} +
@@ -25,9 +22,8 @@

{{ overallFitnessName }} {{overallFitnessStatusIcon}}

-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 }} +
@@ -46,7 +42,7 @@

{{ 'intro.appstatus.overall-notification-name' | translate }} {{overallNotificationStatusIcon}}

-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 }}
@@ -65,11 +61,7 @@

{{ 'intro.appstatus.overall-background-restrictions-name' | translate }} {{overallBackgroundRestrictionStatusIcon}}

- -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 }} From b12de6127125a8ac62e55eb118e3bad380527b55 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 22 Feb 2022 23:27:29 -0800 Subject: [PATCH 5/6] Ensure that we refresh the status when the app resumes For example, after opening the app settings page to change settings and then coming back to the app. --- www/js/appstatus/permissioncheck.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/www/js/appstatus/permissioncheck.js b/www/js/appstatus/permissioncheck.js index 2e55688b9..dfe136343 100644 --- a/www/js/appstatus/permissioncheck.js +++ b/www/js/appstatus/permissioncheck.js @@ -371,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() { From 598071535905fea9f13ee98ca56aff5e575331d4 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 22 Feb 2022 23:53:13 -0800 Subject: [PATCH 6/6] Bump up version numbers to reflect the new changes - Bump up overall app version - Also bump up versions for the following plugins: - data collection: bulk of the changes, bump up a full minor version - server sync: move the fitness permission init code into the new permissions module - unified logger: add a new method to generate plugin compatible notifications so we can tell the user when their status is bad and automatically open the page to fix it. - usercache: includes code that calls the local notifications, so needed to change method signature to match the notification state. This pretty much concludes https://github.com/e-mission/e-mission-docs/issues/680 --- config.cordovabuild.xml | 2 +- package.cordovabuild.json | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/config.cordovabuild.xml b/config.cordovabuild.xml index e422e89d0..dc0165871 100644 --- a/config.cordovabuild.xml +++ b/config.cordovabuild.xml @@ -1,5 +1,5 @@ - + emission A commute pattern tracker and carbon footprint estimator. diff --git a/package.cordovabuild.json b/package.cordovabuild.json index ee45c9289..d89250549 100644 --- a/package.cordovabuild.json +++ b/package.cordovabuild.json @@ -1,6 +1,6 @@ { "name": "edu.berkeley.eecs.emission", - "version": "3.1.0", + "version": "3.2.0", "displayName": "emission", "license": "BSD-3-Clause", "repository": { @@ -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": {}, @@ -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",