Skip to content

Commit

Permalink
Merge branch 'development' into feat/RMET-3367/solve-conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgerardojacinto authored May 20, 2024
2 parents 6c60d21 + c876ff5 commit 42104fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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
Expand Down
19 changes: 12 additions & 7 deletions hooks/androidCopyPrivacyUrlEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ 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);

Expand All @@ -27,7 +30,7 @@ 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);

Expand All @@ -43,12 +46,14 @@ function setPrivacyPolicyUrl(configParser, projectRoot) {
}
}

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;
Expand Down

0 comments on commit 42104fb

Please sign in to comment.