Skip to content

Commit

Permalink
Create the iOS version of the status screen
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
shankari committed Feb 10, 2022
1 parent 78fc6ea commit d69f3a5
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 12 deletions.
9 changes: 5 additions & 4 deletions www/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -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",
Expand Down
82 changes: 74 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

0 comments on commit d69f3a5

Please sign in to comment.