From e1d7f6415da7f3e37444e021733390d62d7538fa Mon Sep 17 00:00:00 2001 From: Alexandre Jacinto Date: Fri, 22 Mar 2024 14:36:42 +0000 Subject: [PATCH 1/4] test: check if file name contains string --- hooks/androidCopyPrivacyUrlEnv.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/hooks/androidCopyPrivacyUrlEnv.js b/hooks/androidCopyPrivacyUrlEnv.js index caa22068..e1c5a17a 100644 --- a/hooks/androidCopyPrivacyUrlEnv.js +++ b/hooks/androidCopyPrivacyUrlEnv.js @@ -11,9 +11,11 @@ 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}`); - if (fileExists(platformPath)) { + if (fileExists(platformPath) || policyFileExists()) { const configXML = path.join(projectRoot, 'config.xml'); const configParser = new ConfigParser(configXML); + + console.log("file exists"); setPrivacyPolicyUrl(configParser, projectRoot); } else { @@ -26,6 +28,10 @@ function setPrivacyPolicyUrl(configParser, projectRoot) { const applicationNameUrl = configParser.getPreference('DefaultApplicationURL', 'android'); if (hostname && applicationNameUrl) { + + + console.log("inside if"); + const url = `https://${hostname}/${applicationNameUrl}/${fileNamePrivacyPolicy}`; const stringsPath = path.join(projectRoot, 'platforms/android/app/src/main/res/values/strings.xml'); const stringsFile = fs.readFileSync(stringsPath).toString(); @@ -43,3 +49,23 @@ function setPrivacyPolicyUrl(configParser, projectRoot) { throw new Error("Error getting the environment variables."); } } + +function policyFileExists() { + const directoryPath = 'platforms/android/app/src/main/assets/www'; + const searchString = 'HealthConnect_PrivacyPolicy'; + + console.log("about to readdirSync"); + + try { + const files = fs.readdirSync(directoryPath); + const matchingFiles = files.filter(fileName => fileName.includes(searchString)); + + console.log("about to return policyFileExists"); + + // return true if there are matching files, false otherwise + return matchingFiles.length > 0; + } catch (error) { + console.error('An error occurred:', error); + return false; + } +} From 82d2ee660edd89cd371988cc60f49932878afed3 Mon Sep 17 00:00:00 2001 From: Alexandre Jacinto Date: Fri, 22 Mar 2024 16:04:09 +0000 Subject: [PATCH 2/4] chore: update dependency to H&F Android Lib --- src/android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/build.gradle b/src/android/build.gradle index a1f6596c..2cf88bfe 100644 --- a/src/android/build.gradle +++ b/src/android/build.gradle @@ -26,7 +26,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:1.2.0.26@aar") + implementation("com.github.outsystems:oshealthfitness-android:1.2.0.27@aar") implementation("com.github.outsystems:osnotificationpermissions-android:0.0.4@aar") // activity From f9c3b31b219a2a98b38d5c2e1baf28b8a9718832 Mon Sep 17 00:00:00 2001 From: Alexandre Jacinto Date: Fri, 22 Mar 2024 16:11:46 +0000 Subject: [PATCH 3/4] refactor: remove console logs --- hooks/androidCopyPrivacyUrlEnv.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/hooks/androidCopyPrivacyUrlEnv.js b/hooks/androidCopyPrivacyUrlEnv.js index e1c5a17a..ec290c29 100644 --- a/hooks/androidCopyPrivacyUrlEnv.js +++ b/hooks/androidCopyPrivacyUrlEnv.js @@ -14,8 +14,6 @@ module.exports = async function (context) { if (fileExists(platformPath) || policyFileExists()) { const configXML = path.join(projectRoot, 'config.xml'); const configParser = new ConfigParser(configXML); - - console.log("file exists"); setPrivacyPolicyUrl(configParser, projectRoot); } else { @@ -28,10 +26,6 @@ function setPrivacyPolicyUrl(configParser, projectRoot) { const applicationNameUrl = configParser.getPreference('DefaultApplicationURL', 'android'); if (hostname && applicationNameUrl) { - - - console.log("inside if"); - const url = `https://${hostname}/${applicationNameUrl}/${fileNamePrivacyPolicy}`; const stringsPath = path.join(projectRoot, 'platforms/android/app/src/main/res/values/strings.xml'); const stringsFile = fs.readFileSync(stringsPath).toString(); @@ -53,15 +47,10 @@ function setPrivacyPolicyUrl(configParser, projectRoot) { function policyFileExists() { const directoryPath = 'platforms/android/app/src/main/assets/www'; const searchString = 'HealthConnect_PrivacyPolicy'; - - console.log("about to readdirSync"); - try { const files = fs.readdirSync(directoryPath); const matchingFiles = files.filter(fileName => fileName.includes(searchString)); - - console.log("about to return policyFileExists"); - + // return true if there are matching files, false otherwise return matchingFiles.length > 0; } catch (error) { From 9f5814fbd2e6f653dfeb2ead61d599508efd78a1 Mon Sep 17 00:00:00 2001 From: Alexandre Jacinto Date: Fri, 22 Mar 2024 16:17:55 +0000 Subject: [PATCH 4/4] chore: update changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b56c9b17..721de862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,11 @@ The changes documented here do not include those from the original repository. ## [Unreleased] +## 2024-03-22 +- Fixed hook for ODC (https://outsystemsrd.atlassian.net/browse/RMET-3191). + ## 2024-03-18 -- Implemented the usage of the Activity Transition Recognition API for background jobs (https://outsystemsrd.atlassian.net/browse/RMET-3191). +- Implemented the usage of the Activity Transition Recognition API for background jobs (https://outsystemsrd.atlassian.net/browse/RMET-3246). ## 2024-03-14 - Implemented the usage of exact alarms for background jobs (https://outsystemsrd.atlassian.net/browse/RMET-3190).