Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMET-3048 :: Migrate GetLastRecord to HealthConnect #98

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The changes documented here do not include those from the original repository.

## [Unreleased]

## 2024-02-08
- Re-implement `GetLastRecord` feature:
- GetFitnessData (https://outsystemsrd.atlassian.net/browse/RMET-3048)
- GetHealthData (https://outsystemsrd.atlassian.net/browse/RMET-3065)
- GetProfileData (https://outsystemsrd.atlassian.net/browse/RMET-3066)

## 2024-02-05
- Re-implemented WriteProfieleData feature (https://outsystemsrd.atlassian.net/browse/RMET-3049).

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:1.2.0@aar")
implementation("com.github.outsystems:oshealthfitness-android:1.2.0.5@aar")
implementation("com.github.outsystems:oshealthfitness-android:1.2.0.8@aar")
implementation("com.github.outsystems:osnotificationpermissions-android:0.0.4@aar")

def roomVersion = "2.4.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,52 +178,42 @@ class OSHealthFitness : CordovaImplementation() {
}

private fun writeData(args: JSONArray) {
val variable = args.getString(0)
val value = args.getDouble(1)
val healthRecordName: HealthRecordName
try {
val variable = args.getString(0)
val healthRecordName = HealthRecordName.valueOf(variable)
val value = args.getDouble(1)

when (variable) {
HealthRecordName.WEIGHT.name -> {
healthRecordName = HealthRecordName.WEIGHT
}
HealthRecordName.HEIGHT.name -> {
healthRecordName = HealthRecordName.HEIGHT
}
HealthRecordName.BODY_FAT_PERCENTAGE.name -> {
healthRecordName = HealthRecordName.BODY_FAT_PERCENTAGE
}
HealthRecordName.BASAL_METABOLIC_RATE.name -> {
healthRecordName = HealthRecordName.BASAL_METABOLIC_RATE
}
else -> {
sendPluginResult(
null,
Pair(
HealthFitnessError.WRITE_DATA_NOT_PROFILE_ERROR.code.toString(),
HealthFitnessError.WRITE_DATA_NOT_PROFILE_ERROR.message
)
)
return
}
healthConnectViewModel.writeData(
healthRecordName,
value,
getActivity().packageName,
{
sendPluginResult("success", null)
},
{
sendPluginResult(null, Pair(it.code.toString(), it.message))
}
)
} catch (e: Exception) {
sendPluginResult(null, Pair(HealthFitnessError.VARIABLE_NOT_AVAILABLE_ERROR.code.toString(), HealthFitnessError.VARIABLE_NOT_AVAILABLE_ERROR.message))
}

healthConnectViewModel.writeData(
healthRecordName,
value,
getActivity().packageName,
{
sendPluginResult("success", null)
},
{
sendPluginResult(null, Pair(it.code.toString(), it.message))
}
)
}

private fun getLastRecord(args: JSONArray) {
//process parameters
val variable = args.getString(0)
healthConnectViewModel.getLastRecord()
try {
healthConnectViewModel.getLastRecord(
HealthRecordName.valueOf(args.getString(0)),
{
sendPluginResult(it, null)
},
{
sendPluginResult(null, Pair(it.code.toString(), it.message))
}
)
} catch (e: Exception) {
sendPluginResult(null, Pair(HealthFitnessError.VARIABLE_NOT_AVAILABLE_ERROR.code.toString(), HealthFitnessError.VARIABLE_NOT_AVAILABLE_ERROR.message))
}

}

private fun setBackgroundJob(args: JSONArray) {
Expand Down
Loading