From d69f3a50bfacf52a63f5a0c134650831c6ad1962 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Thu, 10 Feb 2022 15:52:25 -0800 Subject: [PATCH] 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");