Skip to content

Commit f95f25a

Browse files
authored
[pedometer] Fix file/folder links and cleanup instructions (#1988)
- Fixes links to specific files/folders - Adds more file links where relevant - Uses more specific link text than "here" - Add links to relevant apps when mentioned - Slightly expands on some instructions - Cleans up formatting Fixes #1978
1 parent 398d7e3 commit f95f25a

File tree

2 files changed

+64
-36
lines changed

2 files changed

+64
-36
lines changed

experimental/pedometer/README.md

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,93 @@
11
# FFIgen + JNIgen pedometer
22

3-
This is a demo for some of our tooling around calling platform APIs directly from dart code. This repository represents a demo of a plugin that leverages FFIgen & JNIgen. There is also an example pedometer app that uses the bindings generated from these tools.
3+
This is a demo for some of our tooling around
4+
calling platform APIs directly from dart code.
5+
This repository represents a demo of a plugin that leverages FFIgen & JNIgen.
6+
There is also an example pedometer app that
7+
uses the bindings generated from these tools.
48

5-
- [FFIgen](https://pub.dev/packages/ffigen) is used to generate bindings for C, Objective-C and Swift APIs
6-
- [JNIgen](https://pub.dev/packages/jnigen) is used to generate bindings for Java and Kotlin APIs
7-
8-
**These tools are both experimental and are currently a work in progress.** If you find any issues or have feedback, please file it on the corresponding Github repositories.
9+
- [FFIgen](https://pub.dev/packages/ffigen) is used to generate
10+
bindings for C, Objective-C and Swift APIs.
11+
- [JNIgen](https://pub.dev/packages/jnigen) is used to generate
12+
bindings for Java and Kotlin APIs.
913

14+
**These tools are both experimental and are currently a work in progress.**
15+
If you find any issues or have feedback,
16+
please file it on the corresponding GitHub repositories.
1017

1118
## Re-generating bindings
12-
The bindings that allow the dart code to call the platform code have already been generated [here](/lib). You can regenerate them by following the steps below.
19+
20+
The bindings that allow the Dart code to call the platform code have
21+
already been generated in the [`\lib` folder](./lib).
22+
You can regenerate them by following the steps below:
1323

1424
### FFIgen
15-
Configuration for FFIgen is [here](/ffigen.yaml) for the [CoreMotion](https://developer.apple.com/documentation/coremotion) framework. FFIgen currently does not support autogenerating the code to handle callbacks. So, there were a few steps needed to appropriately handle callbacks in Objective-C. You can [read more here](https://dart.dev/guides/libraries/objective-c-interop#callbacks-and-multithreading-limitations).
1625

17-
`dart run ffigen --config ffigen.yaml`
26+
Configuration of FFIgen for the
27+
[CoreMotion framework](https://developer.apple.com/documentation/coremotion)
28+
is in the [`ffigen.yaml` file](./ffigen.yaml).
29+
FFIgen currently does not support autogenerating code to handle callbacks.
30+
So, there are a few extra steps needed to
31+
appropriately handle callbacks in Objective-C.
32+
You can read more about this limitation on
33+
[dart.dev]((https://dart.dev/guides/libraries/objective-c-interop#callbacks-and-multithreading-limitations).
34+
35+
```bash
36+
dart run ffigen --config ffigen.yaml
37+
```
38+
1839

1940
### JNIgen
20-
Configuration for JNIgen is [here](/jnigen.yaml) for the [HealthConnect API](https://developer.android.com/guide/health-and-fitness/health-connect).
2141

22-
1. `cd Example && flutter build apk`
23-
2. `cd .. && dart run jnigen --config jnigen.yaml`
42+
Configuration of JNIgen for the
43+
[HealthConnect API](https://developer.android.com/guide/health-and-fitness/health-connect)
44+
is in the [`jnigen.yaml` file](./jnigen.yaml).
45+
46+
1. Build an Android APK file from the example app.
47+
Currently, JNIgen requires at least one APK build
48+
to obtain the classpaths of Android Gradle libraries.
49+
50+
```bash
51+
cd example && flutter build apk
52+
```
2453

54+
2. Return to the `/pedometer` directory and run `jnigen`:
55+
56+
```bash
57+
cd .. && dart run jnigen --config jnigen.yaml
58+
```
2559

2660
## Running the example app
27-
The example app is located in the `experimental/pedometer/example` directory,
28-
and the commands below assume they are being run from that location.
61+
62+
The example app is located in the [`/example`](./example) directory,
63+
and the following commands assume they are being run from that location.
2964

3065
Note that step counting is only available on physical devices.
3166

3267
### iOS
33-
- `flutter run`
34-
- Allow *pedometer* app access to step counting
68+
69+
- Run `flutter run` and choose your physical device.
70+
- Allow the *pedometer* app access to step counting.
3571

3672
### Android
37-
- Make sure that Google Fit is installed (to ensure that steps are being counted)
38-
- `flutter run`
39-
- Install Health Connect and grant access to Google Fit and the *jni_demo* app
4073

74+
- Make sure that [Google Fit](https://play.google.com/store/apps/details?id=com.google.android.apps.fitness)
75+
is installed (to ensure that steps are being counted).
76+
- Run `flutter run` and choose your physical device.
77+
- Install [Health Connect](https://play.google.com/store/apps/details?id=com.google.android.apps.healthdata)
78+
and grant access to Google Fit and the *jni_demo* app.
4179

42-
## Project stucture
4380

44-
* `src`: Contains the native source code, and a CMakeLists.txt file for building
45-
that source code into a dynamic library.
81+
## Project structure
82+
83+
* `src`: Contains the native source code, and a `CMakeLists.txt` file for
84+
building that source code into a dynamic library.
4685

47-
* `lib`: Contains the Dart code that defines the API of the plugin, and which
86+
* `lib`: Contains the Dart code that defines the API of the plugin and
4887
calls into the native code using `dart:ffi`.
4988

50-
* platform folders (`ios` etc.): Contains the build files
51-
for building and bundling the native code library with the platform application.
89+
* platform folders (`ios` etc.): Contain the build files for
90+
building and bundling the native code library with the platform application.
5291

5392
* `example`: Contains the native source code for building
5493
that source code into a dynamic library.

experimental/pedometer/example/README.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,4 @@
22

33
Demonstrates how to use the pedometer plugin.
44

5-
## Getting Started
6-
7-
This project is a starting point for a Flutter application.
8-
9-
A few resources to get you started if this is your first Flutter project:
10-
11-
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12-
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13-
14-
For help getting started with Flutter development, view the
15-
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16-
samples, guidance on mobile development, and a full API reference.
5+
Visit the primary [pedometer README](../README.md) for more information.

0 commit comments

Comments
 (0)