Skip to content

Commit

Permalink
Merge pull request #60 from OutSystems/development
Browse files Browse the repository at this point in the history
Merge Development into Main for release of version 1.2.0
  • Loading branch information
alexgerardojacinto committed Dec 24, 2021
2 parents 3c65667 + 21ef22e commit 95092ee
Show file tree
Hide file tree
Showing 75 changed files with 1,773 additions and 557 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ The changes documented here do not include those from the original repository.

## [Version 1.1.0]

- Implemented Unit Tests for BackgroundJob operations on iOS (https://outsystemsrd.atlassian.net/browse/RMET-1210)

- Fixed ClickActivity package name on plugin.xml (https://outsystemsrd.atlassian.net/browse/RMET-1268)

- Implemented Unit Tests for UpdateBackgroundJob feature on Android (https://outsystemsrd.atlassian.net/browse/RMET-1235)

- Implemented Unit Tests for DeleteBackgroundJob feature on Android (https://outsystemsrd.atlassian.net/browse/RMET-1232)

- Implemented Unit Tests for ListBackgroundJob feature on Android (https://outsystemsrd.atlassian.net/browse/RMET-1239)

- Implementation of UpdateBackgroundJob for Android (https://outsystemsrd.atlassian.net/browse/RMET-1235)

- Implementation of DeleteBackgroundJob for Android (https://outsystemsrd.atlassian.net/browse/RMET-1232)

- Implementation of ListBackgroundJobs for Android (https://outsystemsrd.atlassian.net/browse/RMET-1239)

- Implementation of notificaiton frequency (waiting period) for Android (https://outsystemsrd.atlassian.net/browse/RMET-1240)

## [Version 1.0.2]

## 2021-11-18
- Implementation of new variables and new version of background job iOS (https://outsystemsrd.atlassian.net/browse/RMET-1138)

Expand Down
9 changes: 7 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@

<config-file target="AndroidManifest.xml" parent="/manifest/application">

<receiver android:name="com.outsystems.plugins.healthfitnesslib.background.VariableUpdateService"
<receiver android:name="com.outsystems.plugins.healthfitness.background.VariableUpdateService"
android:exported="false">
</receiver>

<activity
android:exported="false"
android:launchMode="singleTask"
android:name="com.outsystems.plugins.healthfitnesslib.background.ClickActivity"
android:name="com.outsystems.plugins.healthfitness.background.ClickActivity"
android:theme="@android:style/Theme.NoDisplay" />

</config-file>
Expand All @@ -49,6 +49,7 @@
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/HealthFitnessError.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness"/>

<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/store/HealthStore.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/store"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/store/HealthStoreInterface.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/store"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/store/GoogleFitPermission.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/store"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/store/GoogleFitVariable.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/store"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/store/GoogleFitGroupPermission.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/store"/>
Expand All @@ -62,8 +63,12 @@
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/store/HealthStoreException.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/store"/>

<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/background/BackgroundJobParameters.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/background"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/background/UpdateBackgroundJobParameters.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/background"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/background/ClickActivity.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/background"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/background/VariableUpdateService.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/background"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/background/VariableUpdateManager.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/background"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/background/BackgroundJobResponseBlock.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/background"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/background/BackgroundJobsResponse.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/background"/>

<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/background/database/AppDatabase.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/background/database"/>
<source-file src="src/android/com/outsystems/plugins/healthfitness/oshealthfitnesslibrary/background/database/BackgroundJob.kt" target-dir="app/src/main/kotlin/com/outsystems/plugins/healthfitness/background/database"/>
Expand Down
67 changes: 54 additions & 13 deletions src/android/com/outsystems/plugins/healthfitness/OSHealthFitness.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import androidx.core.content.ContextCompat
import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
import com.google.gson.Gson

import com.outsystems.plugins.healthfitnesslib.background.BackgroundJobParameters
import com.outsystems.plugins.healthfitnesslib.background.DatabaseManager
import com.outsystems.plugins.healthfitnesslib.store.AdvancedQueryParameters
import com.outsystems.plugins.healthfitnesslib.store.HealthFitnessManager
import com.outsystems.plugins.healthfitnesslib.store.HealthStore
import com.outsystems.plugins.healthfitnesslib.store.HealthStoreException
import com.outsystems.plugins.healthfitness.background.UpdateBackgroundJobParameters
import com.outsystems.plugins.healthfitness.background.BackgroundJobParameters
import com.outsystems.plugins.healthfitness.background.DatabaseManager
import com.outsystems.plugins.healthfitness.HealthFitnessError
import com.outsystems.plugins.healthfitness.store.*
import com.outsystems.plugins.oscordova.CordovaImplementation

import org.apache.cordova.*
Expand All @@ -24,7 +22,7 @@ import org.json.JSONArray
class OSHealthFitness : CordovaImplementation() {
override var callbackContext: CallbackContext? = null

var healthStore: HealthStore? = null
var healthStore: HealthStoreInterface? = null
val gson by lazy { Gson() }

override fun initialize(cordova: CordovaInterface, webView: CordovaWebView) {
Expand Down Expand Up @@ -61,13 +59,21 @@ class OSHealthFitness : CordovaImplementation() {
"setBackgroundJob" -> {
setBackgroundJob(args)
}
"deleteBackgroundJob" -> {
deleteBackgroundJob(args)
}
"listBackgroundJobs" -> {
listBackgroundJobs()
}
"updateBackgroundJob" -> {
updateBackgroundJob(args)
}
}
return true
}

//create array of permission oauth
private fun initAndRequestPermissions(args : JSONArray) {

val customPermissions = args.getString(0)
val allVariables = args.getString(1)
val fitnessVariables = args.getString(2)
Expand All @@ -88,7 +94,6 @@ class OSHealthFitness : CordovaImplementation() {
catch (hse : HealthStoreException) {
sendPluginResult(null, Pair(hse.error.code, hse.error.message))
}

}

private fun areAndroidPermissionsGranted(permissions: List<String>): Boolean {
Expand Down Expand Up @@ -188,6 +193,44 @@ class OSHealthFitness : CordovaImplementation() {
)
}

private fun deleteBackgroundJob(args: JSONArray) {
val parameters = args.getString(0)
healthStore?.deleteBackgroundJob(
parameters,
{ response ->
sendPluginResult(response)
},
{ error ->
sendPluginResult(null, Pair(error.code, error.message))
}
)
}

private fun listBackgroundJobs() {
healthStore?.listBackgroundJobs(
{ response ->
val pluginResponseJson = gson.toJson(response)
sendPluginResult(pluginResponseJson)
},
{ error ->
sendPluginResult(null, Pair(error.code, error.message))
}
)
}

private fun updateBackgroundJob(args: JSONArray) {
val parameters = gson.fromJson(args.getString(0), UpdateBackgroundJobParameters::class.java)
healthStore?.updateBackgroundJob(
parameters,
{ response ->
sendPluginResult(response)
},
{ error ->
sendPluginResult(null, Pair(error.code, error.message))
}
)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) {
//super.onActivityResult(requestCode, resultCode, intent)
try {
Expand All @@ -197,7 +240,6 @@ class OSHealthFitness : CordovaImplementation() {
val error = hse.error
sendPluginResult(null, Pair(error.code, error.message))
}

}

override fun areGooglePlayServicesAvailable(): Boolean {
Expand All @@ -221,8 +263,7 @@ class OSHealthFitness : CordovaImplementation() {
override fun onRequestPermissionResult(
requestCode: Int,
permissions: Array<String>,
grantResults: IntArray
) {
grantResults: IntArray) {
when (requestCode) {
ACTIVITY_LOCATION_PERMISSIONS_REQUEST_CODE -> {
// If request is cancelled, the result arrays are empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ enum class HealthFitnessError(val code: Int, val message: String) {
WRITE_DATA_ERROR(104, "Error while writing data."),
BACKGROUND_JOB_ALREADY_EXISTS_ERROR(105, "The background job you are trying to set already exists."),
BACKGROUND_JOB_GENERIC_ERROR(106, "The background job could not be created."),
BACKGROUND_JOB_DOES_NOT_EXISTS_ERROR(107, "The background job could not be found."),
UNSUBSCRIBE_ERROR(108, "The background job could not be deleted"),
LIST_BACKGROUND_JOBS_GENERIC_ERROR(110, "The list of background jobs could not be fetched."),
DELETE_BACKGROUND_JOB_GENERIC_ERROR(111, "The background job could not be deleted."),
UPDATE_BACKGROUND_JOB_GENERIC_ERROR(112, "The background job could not be updated."),


// Plugin Android specific errors
WRITE_VALUE_OUT_OF_RANGE_ERROR(109, "Value provided is out of range for this variable"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.outsystems.plugins.healthfitnesslib.background
package com.outsystems.plugins.healthfitness.background

import com.google.gson.annotations.SerializedName

Expand All @@ -9,6 +9,8 @@ data class BackgroundJobParameters (
@SerializedName("TimeUnit") val timeUnit : String? = null,
@SerializedName("TimeUnitGrouping") val timeUnitGrouping : Int? = 1,
@SerializedName("JobFrequency") val jobFrequency : String? = null,
@SerializedName("NotificationFrequency") val notificationFrequency : String? = null,
@SerializedName("NotificationFrequencyGrouping") val notificationFrequencyGrouping : Int? = 1,
@SerializedName("NotificationHeader") val notificationHeader : String,
@SerializedName("NotificationBody") val notificationBody : String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.outsystems.plugins.healthfitness.background

data class BackgroundJobsResponseBlock (
val variable: String?,
val condition: String?,
val value: Float?,
val notificationHeader: String?,
val notificationBody: String?,
val notificationFrequency: String?,
val notificationFrequencyGrouping: Int?,
val active: Boolean?,
val id: String?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.outsystems.plugins.healthfitness.background

data class BackgroundJobsResponse(
var results : List<BackgroundJobsResponseBlock>
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.outsystems.plugins.healthfitnesslib.background
package com.outsystems.plugins.healthfitness.background

import android.app.Activity
import android.content.Intent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.outsystems.plugins.healthfitness.background

import com.google.gson.annotations.SerializedName

data class UpdateBackgroundJobParameters (
@SerializedName("Id") val id : String,
@SerializedName("Value") val value : Float?,
@SerializedName("Condition") val condition : String?,
@SerializedName("NotificationFrequency") val notificationFrequency : String?,
@SerializedName("NotificationFrequencyGrouping") val notificationFrequencyGrouping : Int?,
@SerializedName("IsActive") val isActive : Boolean?,
@SerializedName("NotificationHeader") val notificationHeader : String?,
@SerializedName("NotificationBody") val notificationBody : String?
)
Loading

0 comments on commit 95092ee

Please sign in to comment.