Skip to content

Commit

Permalink
Merge branch 'health-dev' into feature/upgrade_gradle_to_8
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmatteo authored Jan 23, 2024
2 parents 6486230 + 72651fe commit 0ea6378
Show file tree
Hide file tree
Showing 26 changed files with 193 additions and 86 deletions.
1 change: 1 addition & 0 deletions packages/activity_recognition_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ android {
lintOptions {
disable 'InvalidPackage'
}
namespace "dk.cachet.activity_recognition_flutter"
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions packages/app_usage/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ android {
lintOptions {
disable 'InvalidPackage'
}
namespace "dk.cachet.app_usage"
}

dependencies {
Expand Down
4 changes: 4 additions & 0 deletions packages/audio_streamer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.1.1

* enable AGP 8.0

## 4.0.0

* removal of permission_handler dependency - handling permission should take place in the app, not the plugin.
Expand Down
20 changes: 16 additions & 4 deletions packages/audio_streamer/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'plugins.cachet.audio_streamer'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.7.20'
ext.kotlin_version = '1.9.22'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle:8.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -25,8 +25,16 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 33
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
Expand All @@ -37,8 +45,12 @@ android {
lintOptions {
disable 'InvalidPackage'
}

if (project.android.hasProperty("namespace")) {
namespace 'plugins.cachet.audio_streamer'
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
21 changes: 14 additions & 7 deletions packages/audio_streamer/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
compileSdk 34

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "plugins.cachet.audio_streamer_example"
minSdkVersion 16
targetSdkVersion 31
minSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -53,15 +56,19 @@ android {
lint {
disable 'InvalidPackage'
}
kotlinOptions {
jvmTarget = '1.8'
}
namespace 'plugins.cachet.audio_streamer_example'
}

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="plugins.cachet.audio_streamer_example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="plugins.cachet.audio_streamer_example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name="${applicationName}"
android:label="audio_streamer_example"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="plugins.cachet.audio_streamer_example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
4 changes: 2 additions & 2 deletions packages/audio_streamer/example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.7.20'
ext.kotlin_version = '1.9.22'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.android.tools.build:gradle:8.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/audio_streamer/example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Mar 12 17:19:03 CST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
3 changes: 2 additions & 1 deletion packages/audio_streamer/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: audio_streamer
description: Streaming of Pulse-code modulation (PCM) audio from Android and iOS
version: 4.0.0
version: 4.1.1
homepage: https://github.com/cph-cachet/flutter-plugins/tree/master/packages/

environment:
sdk: ">=2.17.0 <4.0.0"
flutter: ">=3.0.0"

dependencies:
permission_handler: ^11.0.0
flutter:
sdk: flutter

Expand Down
1 change: 1 addition & 0 deletions packages/empatica_e4link/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ android {
minifyEnabled true
}
}
namespace "dk.cachet.empatica_e4link"
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions packages/esense_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ android {
defaultConfig {
minSdkVersion 16
}
namespace "dk.cachet.esense_flutter"
}
1 change: 1 addition & 0 deletions packages/flutter_foreground_service/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ android {
lintOptions {
disable 'InvalidPackage'
}
namespace "dk.cachet.flutter_foreground_service"
}

dependencies {
Expand Down
39 changes: 36 additions & 3 deletions packages/health/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,24 @@ Health Connect requires the following lines in the `AndroidManifest.xml` file (a
</queries>
```

In the Health Connect permissions activity there is a link to your privacy policy. You need to grant the Health Connect app access in order to link back to your privacy policy. In the example below, you should either replace `.MainActivity` with an activity that presents the privacy policy or have the Main Activity route the user to the policy. This step may be required to pass Google app review when requesting access to sensitive permissions.

```
<activity-alias
android:name="ViewPermissionUsageActivity"
android:exported="true"
android:targetActivity=".MainActivity"
android:permission="android.permission.START_VIEW_PERMISSION_USAGE">
<intent-filter>
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE" />
<category android:name="android.intent.category.HEALTH_PERMISSIONS" />
</intent-filter>
</activity-alias>
```

### Android Permissions

Starting from API level 28 (Android 9.0) acessing some fitness data (e.g. Steps) requires a special permission.
Starting from API level 28 (Android 9.0) accessing some fitness data (e.g. Steps) requires a special permission.

To set it add the following line to your `AndroidManifest.xml` file.

Expand All @@ -147,7 +162,7 @@ To set it add the following line to your `AndroidManifest.xml` file.

#### Health Connect

If using Health Connect on Android it requires speciel permissions in the `AndroidManifest.xml` file.
If using Health Connect on Android it requires special permissions in the `AndroidManifest.xml` file.
The permissions can be found here: https://developer.android.com/guide/health-and-fitness/health-connect/data-and-data-types/data-types

Example shown here (can also be found in the example app):
Expand All @@ -168,7 +183,7 @@ Additionally, for Workouts: If the distance of a workout is requested then the l

There's a `debug`, `main` and `profile` version which are chosen depending on how you start your app. In general, it's sufficient to add permission only to the `main` version.

Beacuse this is labled as a `dangerous` protection level, the permission system will not grant it automaticlly and it requires the user's action.
Because this is labeled as a `dangerous` protection level, the permission system will not grant it automaticlly and it requires the user's action.
You can prompt the user for it using the [permission_handler](https://pub.dev/packages/permission_handler) plugin.
Follow the plugin setup instructions and add the following line before requsting the data:

Expand All @@ -177,6 +192,24 @@ await Permission.activityRecognition.request();
await Permission.location.request();
```

### Android 14

This plugin uses the new `registerForActivityResult` when requesting permissions from Health Connect.
In order for that to work, the Main app's activity should extend `FlutterFragmentActivity` instead of `FlutterActivity`.
This adjustment allows casting from `Activity` to `ComponentActivity` for accessing `registerForActivityResult`.

In your MainActivity.kt file, update the `MainActivity` class so that it extends `FlutterFragmentActivity` instead of the default `FlutterActivity`:

```
...
import io.flutter.embedding.android.FlutterFragmentActivity
...
class MainActivity: FlutterFragmentActivity() {
...
}
```

### Android X

Replace the content of the `android/gradle.properties` file with the following lines:
Expand Down
5 changes: 4 additions & 1 deletion packages/health/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ dependencies {
implementation("com.google.android.gms:play-services-auth:20.2.0")

// The new health connect api
implementation("androidx.health.connect:connect-client:1.1.0-alpha03")
implementation("androidx.health.connect:connect-client:1.1.0-alpha06")
def fragment_version = "1.6.2"
implementation "androidx.fragment:fragment-ktx:$fragment_version"

}
3 changes: 1 addition & 2 deletions packages/health/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cachet.plugins.health">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
Loading

0 comments on commit 0ea6378

Please sign in to comment.