Skip to content

Commit

Permalink
Merge pull request #140 from OutSystems/development
Browse files Browse the repository at this point in the history
RMET-3367 H&F Plugin - Prepare to release version `2.1.0`
  • Loading branch information
alexgerardojacinto authored May 20, 2024
2 parents 025674c + 84540d5 commit 4c4c99b
Show file tree
Hide file tree
Showing 36 changed files with 11,449 additions and 3,112 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

The changes documented here do not include those from the original repository.

## [2.1.0]

### 2024-05-09
- Fix: Add format verification for Android's Privacy Policy file (https://outsystemsrd.atlassian.net/browse/RMET-3406).
- Feat: Implemented support for `OxygenSaturation` variable when using requestPermissions, advancedQuery, getHealthData, and background jobs (https://outsystemsrd.atlassian.net/browse/RMET-3363).

### 2024-05-09
- Fix: Use proper unit for percentage values (https://outsystemsrd.atlassian.net/browse/RMET-3414).

### 2024-04-24
- Chore: Update cordova hooks with new OutSystems specific errors. (https://outsystemsrd.atlassian.net/browse/RMET-3388).

## [2.0.0]

### 2024-04-05
Expand Down
9 changes: 8 additions & 1 deletion hooks/androidCopyPreferencesPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ let permissions = {
writePermission: "android.permission.health.WRITE_DISTANCE",
configValue: undefined,
wasSet: false
},
OxygenSaturation: {
variableName: "OxygenSaturation",
readPermission: "android.permission.health.READ_OXYGEN_SATURATION",
writePermission: "android.permission.health.WRITE_OXYGEN_SATURATION",
configValue: undefined,
wasSet: false
}
}

Expand All @@ -114,7 +121,7 @@ let groupPermissions = {
variableName: "HealthVariables",
configValue: undefined,
wasSet: false,
groupVariables: ["HeartRate", "Sleep", "BloodPressure", "BloodGlucose"]
groupVariables: ["HeartRate", "Sleep", "BloodPressure", "BloodGlucose", "OxygenSaturation"]
},
ProfileVariables: {
variableName: "ProfileVariables",
Expand Down
30 changes: 17 additions & 13 deletions hooks/androidCopyPrivacyUrlEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ const path = require('path');
const { ConfigParser } = require('cordova-common');
const et = require('elementtree');
const { fileExists } = require('./utils');

let fileNamePrivacyPolicy = "HealthConnect_PrivacyPolicy.txt";
let mainFolder = "platforms/android/app/src/main/";

module.exports = async function (context) {
const projectRoot = context.opts.cordova.project ? context.opts.cordova.project.root : context.opts.projectRoot;
const platformPath = path.join(projectRoot, `platforms/android/app/src/main/assets/www/${fileNamePrivacyPolicy}`);
const directoryPath = path.join(projectRoot, mainFolder);
const platformPath = path.join(directoryPath, `assets/www/${fileNamePrivacyPolicy}`);

if (fileExists(platformPath) || policyFileExists()) {
if (fileExists(platformPath) || policyFileExists(directoryPath)) {
const configXML = path.join(projectRoot, 'config.xml');
const configParser = new ConfigParser(configXML);

setPrivacyPolicyUrl(configParser, projectRoot);
} else {
throw new Error("Privacy Policy file not found in the resources folder.");
throw new Error("OUTSYSTEMS_PLUGIN_ERROR: Privacy Policy file not found in the resources folder.");
}
};

Expand All @@ -27,34 +30,35 @@ function setPrivacyPolicyUrl(configParser, projectRoot) {

if (hostname && applicationNameUrl) {
const url = `https://${hostname}/${applicationNameUrl}/${fileNamePrivacyPolicy}`;
const stringsPath = path.join(projectRoot, 'platforms/android/app/src/main/res/values/strings.xml');
const stringsPath = path.join(projectRoot, mainFolder, 'res/values/strings.xml');
const stringsFile = fs.readFileSync(stringsPath).toString();
const etreeStrings = et.parse(stringsFile);

let privacyPolicyUrl = etreeStrings.find('./string[@name="privacy_policy_url"]');
if (!privacyPolicyUrl) {
console.error('Privacy policy URL string not found in strings.xml');
return;
throw new Error (`OUTSYSTEMS_PLUGIN_ERROR: Privacy policy URL string not found in strings.xml.`)
}
privacyPolicyUrl.text = url;
const resultXmlStrings = etreeStrings.write({method: 'xml'});
fs.writeFileSync(stringsPath, resultXmlStrings);
} else {
throw new Error("Error getting the environment variables.");
throw new Error(`OUTSYSTEMS_PLUGIN_ERROR: Error getting the environment variables.`);
}
}

function policyFileExists() {
const directoryPath = 'platforms/android/app/src/main/assets/www';
const searchString = 'HealthConnect_PrivacyPolicy';
function policyFileExists(platformPath) {
const directoryPath = path.join(platformPath, 'assets/www');
// splits the file in name & format.
const searchStrings = fileNamePrivacyPolicy.split('.');

try {
const files = fs.readdirSync(directoryPath);
const matchingFiles = files.filter(fileName => fileName.includes(searchString));
const matchingFiles = files.filter(fileName => fileName.startsWith(searchStrings[0]) && fileName.endsWith(searchStrings[1]));

// return true if there are matching files, false otherwise
return matchingFiles.length > 0;
} catch (error) {
console.error('An error occurred:', error);
return false;
console.error(error);
throw new Error(`OUTSYSTEMS_PLUGIN_ERROR: An expected error occurred - Please check the logs for more information.`);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.outsystems.plugins.healthfitness",
"version": "2.0.0",
"version": "2.1.0",
"description": "Health & Fitness cordova plugin for OutSystems applications.",
"keywords": [
"ecosystem:cordova",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<plugin id="com.outsystems.plugins.healthfitness" version="2.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<plugin id="com.outsystems.plugins.healthfitness" version="2.1.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>HealthFitness</name>
<description>Health &amp; Fitness cordova plugin for OutSystems applications.</description>
<author>OutSystems Inc</author>
Expand Down
2 changes: 1 addition & 1 deletion src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies{

implementation("com.github.outsystems:oscore-android:1.2.0@aar")
implementation("com.github.outsystems:oscordova-android:2.0.1@aar")
implementation("com.github.outsystems:oshealthfitness-android:2.0.0@aar")
implementation("com.github.outsystems:oshealthfitness-android:2.1.0@aar")
implementation("com.github.outsystems:osnotificationpermissions-android:0.0.4@aar")

// activity
Expand Down
4 changes: 4 additions & 0 deletions src/ios/frameworks/OSHealthFitnessLib.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>OSHealthFitnessLib.framework/OSHealthFitnessLib</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
Expand All @@ -20,6 +22,8 @@
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>OSHealthFitnessLib.framework/OSHealthFitnessLib</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 4c4c99b

Please sign in to comment.