From 5211a7866a6c4b2994661edda21e19b1b15340f7 Mon Sep 17 00:00:00 2001 From: Alexandre Jacinto Date: Thu, 29 Feb 2024 09:31:52 +0000 Subject: [PATCH] RMET-3158 H&F Plugin - Open Health Connect App (#107) * feat: first implementation of androidCopyPreferencesPermissions hook References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: fix path to hook file References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: add dependency to xmldom References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * feat: implement first version of hook processing preferences References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * refactor: remove unnecessary code References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: fix comparator in condition References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * test: add log for troubleshooting References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * test: add log for troubleshooting References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * test: add log for troubleshooting References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: use "" instead of null in comparison References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * refactor: remove logs References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * refactor: remove logs and comments References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * feat: add permissions code for Android <= 13 References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: fix variable name References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * feat: add background permissions to AndroidManifest.xml file References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: properly pass DOMParser to functions References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: fix condition in if for background job permissions References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * feat: remove unnecessary permissions Context: The new version of the H&F plugin, which uses Health Connect, no longer needs these permissions by default. References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * test: add logs for troubleshooting References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: fix if condition Context: We only want to not include the permissions if DisableBackgroundJobs is exactly equal to "true" References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * feat: copy notification content to strings.xml References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: fix query selector References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: properly look for string tags References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * test: add logs for troubleshooting References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * misc: add log for troubleshooting References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * misc: add logs for troubleshooting References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * feat: use different way of setting texts in strings.xml References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * refactor: remove logs and comments References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: replace const with var References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * feat: add PermissionsRationaleActivity to AndroidManifest.xml References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * feat: also use default value for notificationDescription References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: add missing permissions for background jobs References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * chore: update changelog References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * refactor: use correct english term References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: include necessary dependencies Context: Because dependencies from our Health and Fitness Android library are not being transitive, we need to include them in the plugin's build.gradle file so that they're included in the app's build gradle. References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * fix: include dependencies for Jetpack Compose in build.gradle References: https://outsystemsrd.atlassian.net/browse/RMET-3142 * feat: implement openHealthConnect References: https://outsystemsrd.atlassian.net/browse/RMET-3158 * chore: update changelog References: https://outsystemsrd.atlassian.net/browse/RMET-3158 * chore: update dependency version References: https://outsystemsrd.atlassian.net/browse/RMET-3158 * chore: remove code from other branch References: https://outsystemsrd.atlassian.net/browse/RMET-3158 * chore: remove changes from other branch References: https://outsystemsrd.atlassian.net/browse/RMET-3158 * refactor: fix spacing References: https://outsystemsrd.atlassian.net/browse/RMET-3158 --- CHANGELOG.md | 3 +++ src/android/build.gradle | 2 +- .../plugins/healthfitness/OSHealthFitness.kt | 15 +++++++++++++++ www/OSHealthFitness.js | 4 ++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0106b9d..645ad292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ The changes documented here do not include those from the original repository. ## [Unreleased] +## 2024-02-28 +- Implemented `Open Health Connect App` (https://outsystemsrd.atlassian.net/browse/RMET-3158). + ## 2024-02-26 - Implemented `Show app's privacy policy dialog` (https://outsystemsrd.atlassian.net/browse/RMET-3145). diff --git a/src/android/build.gradle b/src/android/build.gradle index a6e90a5b..44865c92 100644 --- a/src/android/build.gradle +++ b/src/android/build.gradle @@ -25,7 +25,7 @@ dependencies{ implementation("com.github.outsystems:oscore-android:1.2.0@aar") implementation("com.github.outsystems:oscordova-android:1.2.0@aar") - implementation("com.github.outsystems:oshealthfitness-android:1.2.0.18@aar") + implementation("com.github.outsystems:oshealthfitness-android:1.2.0.19@aar") implementation("com.github.outsystems:osnotificationpermissions-android:0.0.4@aar") def roomVersion = "2.4.2" diff --git a/src/android/com/outsystems/plugins/healthfitness/OSHealthFitness.kt b/src/android/com/outsystems/plugins/healthfitness/OSHealthFitness.kt index 16a5b7d5..a2854b0a 100755 --- a/src/android/com/outsystems/plugins/healthfitness/OSHealthFitness.kt +++ b/src/android/com/outsystems/plugins/healthfitness/OSHealthFitness.kt @@ -86,6 +86,9 @@ class OSHealthFitness : CordovaImplementation() { "disconnectFromGoogleFit" -> { disconnectFromGoogleFit() } + "openHealthConnect" -> { + openHealthConnect() + } } return true } @@ -299,6 +302,18 @@ class OSHealthFitness : CordovaImplementation() { ) } + private fun openHealthConnect() { + healthConnectViewModel.openHealthConnect( + getContext(), + { + sendPluginResult("success", null) + }, + { + sendPluginResult(null, Pair(it.code.toString(), it.message)) + } + ) + } + override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) { super.onActivityResult(requestCode, resultCode, intent) healthConnectViewModel.handleActivityResult(requestCode, resultCode, intent, diff --git a/www/OSHealthFitness.js b/www/OSHealthFitness.js index a1b23040..5ce97931 100644 --- a/www/OSHealthFitness.js +++ b/www/OSHealthFitness.js @@ -60,3 +60,7 @@ exports.updateBackgroundJob = function (success, error, params) { exports.disconnectFromGoogleFit = function (success, error) { exec(success, error, 'OSHealthFitness', 'disconnectFromGoogleFit'); }; + +exports.openHealthConnect = function (success, error) { + exec(success, error, 'OSHealthFitness', 'openHealthConnect'); +};