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

chore: bump androidx.health.connect:connect-client to alpha06 #53

Merged
merged 3 commits into from
Dec 21, 2023
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
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.18.1
18.18.2
14 changes: 2 additions & 12 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,8 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation "androidx.health.connect:connect-client:1.1.0-alpha04"

// Issue: https://youtrack.jetbrains.com/issue/KT-54136/Duplicated-classes-cause-build-failure-if-a-dependency-to-kotlin-stdlib-specified-in-an-android-project
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
implementation "androidx.health.connect:connect-client:1.1.0-alpha06"
}

if (isNewArchitectureEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HealthConnect_kotlinVersion=1.8.10
HealthConnect_kotlinVersion=1.8.0
HealthConnect_minSdkVersion=26
HealthConnect_targetSdkVersion=34
HealthConnect_compileSdkVersion=34
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class HealthConnectManager(private val applicationContext: ReactApplicationConte
applicationContext.currentActivity?.startActivity(intent)
}

fun openHealthConnectDataManagement(providerPackageName: String?) {
val intent = providerPackageName?.let {
HealthConnectClient.getHealthConnectManageDataIntent(applicationContext, it)
} ?: HealthConnectClient.getHealthConnectManageDataIntent(applicationContext)
applicationContext.currentActivity?.startActivity(intent)
}

fun getSdkStatus(providerPackageName: String, promise: Promise) {
val status = HealthConnectClient.getSdkStatus(applicationContext, providerPackageName)
return promise.resolve(status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class HealthConnectModule internal constructor(context: ReactApplicationContext)
manager.openHealthConnectSettings()
}

@ReactMethod
override fun openHealthConnectDataManagement(providerPackageName: String?) {
manager.openHealthConnectDataManagement(providerPackageName)
}

@ReactMethod
override fun initialize(providerPackageName: String, promise: Promise) {
return manager.initialize(providerPackageName, promise)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import kotlin.reflect.KClass
fun <T : Record> convertReactRequestOptionsFromJS(
recordType: KClass<T>, options: ReadableMap
): ReadRecordsRequest<T> {
// Move to refined version
// inline fun <reified T : Record> ReadRecordsRequest()
// link: https://android-review.googlesource.com/#/q/If58a5c2c9acea1c22b322537daa4fa513065e393
return ReadRecordsRequest(
recordType,
timeRangeFilter = options.getTimeRangeFilter("timeRangeFilter"),
Expand Down
7 changes: 5 additions & 2 deletions android/src/oldarch/HealthConnectSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ abstract class HealthConnectSpec internal constructor(context: ReactApplicationC
@ReactMethod
abstract fun openHealthConnectSettings();

@ReactMethod
abstract fun openHealthConnectDataManagement(providerPackageName: String?);

@ReactMethod
abstract fun requestPermission(permissions: ReadableArray, providerPackageName: String, promise: Promise);

Expand All @@ -28,13 +31,13 @@ abstract class HealthConnectSpec internal constructor(context: ReactApplicationC

@ReactMethod
abstract fun readRecords(recordType: String, options: ReadableMap, promise: Promise);

@ReactMethod
abstract fun readRecord(recordType: String, recordId: String, promise: Promise);

@ReactMethod
abstract fun aggregateRecord(record: ReadableMap, promise: Promise);

@ReactMethod
abstract fun deleteRecordsByUuids(recordType: String, recordIdsList: ReadableArray, clientRecordIdsList: ReadableArray, promise: Promise);

Expand Down
22 changes: 22 additions & 0 deletions docs/docs/api/methods/13-openHealthConnectSettings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: openHealthConnectDataManagement
---

# `openHealthConnectDataManagement`

Opens Health Connect data management screen

# Method

```ts
openHealthConnectDataManagement(providerPackageName?: string): void
```

# Example

```ts
import { openHealthConnectDataManagement } from 'react-native-health-connect';

// ...
openHealthConnectDataManagement();
```
1 change: 1 addition & 0 deletions docs/docs/api/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ title: Overview
| getSdkStatus | Determines whether an implementation of HealthConnectClient is available on the device at the moment. If none is available, apps may choose to redirect to package installers to find suitable providers. |
| initialize | Initialize the health connect client. |
| openHealthConnectSettings | Opens Health Connect app's settings app. |
| openHealthConnectDataManagement | Opens Health Connect data management screen app. |
| requestPermission | Request permission for specified record types and access types. |
| getGrantedPermissions | Returns a set of all health permissions granted by the user to the calling provider app. |
| revokeAllPermissions | Revokes all previously granted permissions by the user to the calling app. |
Expand Down
1 change: 0 additions & 1 deletion example/.node-version

This file was deleted.

66 changes: 7 additions & 59 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

import com.android.build.OutputFile

/**
* This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
Expand All @@ -12,9 +11,9 @@ react {
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node-modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
// codegenDir = file("../node-modules/react-native-codegen")
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")

Expand Down Expand Up @@ -52,14 +51,6 @@ react {
// hermesFlags = ["-O", "-output-source-map"]
}

/**
* Set this to true to create four separate APKs instead of one,
* one for each native architecture. This is useful if you don't
* use App Bundles (https://developer.android.com/guide/app-bundle/)
* and want to have separate APKs to upload to the Play Store.
*/
def enableSeparateBuildPerCPUArchitecture = false

/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
Expand All @@ -78,20 +69,10 @@ def enableProguardInReleaseBuilds = false
*/
def jscFlavor = 'org.webkit:android-jsc:+'

/**
* Private function to get the list of Native Architectures you want to build.
* This reads the value from reactNativeArchitectures in your gradle.properties
* file and works together with the --active-arch-only flag of react-native run-android.
*/
def reactNativeArchitectures() {
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion

namespace "com.healthconnectexample"
defaultConfig {
Expand All @@ -101,15 +82,6 @@ android {
versionCode 1
versionName "1.0"
}

splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include (*reactNativeArchitectures())
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
Expand All @@ -130,41 +102,17 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}

}
}
}

dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
8 changes: 2 additions & 6 deletions example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application
android:usesCleartextTraffic="true"
tools:targetApi="28"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
</application>
</manifest>
tools:ignore="GoogleAppIndexingWarning"/>
</manifest>

This file was deleted.

4 changes: 2 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.health.READ_ACTIVE_CALORIES_BURNED" />
<uses-permission android:name="android.permission.health.WRITE_ACTIVE_CALORIES_BURNED" />
<uses-permission android:name="android.permission.health.READ_STEPS" />
<uses-permission android:name="android.permission.health.WRITE_STEPS" />

<application
android:name=".MainApplication"
Expand Down

This file was deleted.

Loading