Skip to content
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ These are the available plugins in this repository.
| [notifications](./packages/notifications) | Track device notifications. | ✔️ | ❌ | [![pub package](https://img.shields.io/pub/v/notifications.svg)](https://pub.dartlang.org/packages/notifications) |
| [movisens_flutter](./packages/movisens_flutter) | Movisens sensor communication. | ✔️ | ✔️ | [![pub package](https://img.shields.io/pub/v/movisens_flutter.svg)](https://pub.dartlang.org/packages/movisens_flutter) |
| [esense_flutter](./packages/esense_flutter) | eSense ear sensor plugin. | ✔️ | ✔️ | [![pub package](https://img.shields.io/pub/v/esense_flutter.svg)](https://pub.dartlang.org/packages/esense_flutter) |
| [health](./packages/health) | Apple HealthKit and Google Fit interface plugin. | ✔️ | ✔️ | [![pub package](https://img.shields.io/pub/v/health.svg)](https://pub.dartlang.org/packages/health) |
| [health](https://github.com/carp-dk/carp-health-flutter) | Apple HealthKit and Google Fit interface plugin. | ✔️ | ✔️ | [![pub package](https://img.shields.io/pub/v/health.svg)](https://pub.dartlang.org/packages/health) |
| [activity_recognition](./packages/activity_recognition_flutter) | Activity Recognition | ✔️ | ✔️ | [![pub package](https://img.shields.io/pub/v/activity_recognition_flutter.svg)](https://pub.dartlang.org/packages/activity_recognition_flutter) |
| [audio_streamer](./packages/audio_streamer) | Stream audio as PCM from mic| ✔️ | ✔️ | [![pub package](https://img.shields.io/pub/v/audio_streamer.svg)](https://pub.dartlang.org/packages/audio_streamer) |
| [mobility_features](./packages/mobility_features) | Compute daily mobility features from location data | ✔️ | ✔️ | [![pub package](https://img.shields.io/pub/v/mobility_features.svg)](https://pub.dartlang.org/packages/mobility_features) |
Expand Down
4 changes: 4 additions & 0 deletions packages/mobility_features/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.1.0

* upgrade of stats package

## 6.0.0

* using carp_serialization for JSON serialization resulting in a new JSON schema for serialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
applicationId = "com.example.example"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = 23
minSdkVersion = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
# distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
4 changes: 2 additions & 2 deletions packages/mobility_features/example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "com.android.application" version '8.10.1' apply false
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
}

include ":app"
119 changes: 61 additions & 58 deletions packages/mobility_features/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library mobility_app;
library;

import 'dart:async';
import 'package:flutter/material.dart';
Expand All @@ -14,13 +14,10 @@ void main() => runApp(const MyApp());

Widget entry(String key, String value, Icon icon) {
return Container(
padding: const EdgeInsets.all(2),
margin: const EdgeInsets.all(3),
child: ListTile(
leading: icon,
title: Text(key),
trailing: Text(value),
));
padding: const EdgeInsets.all(2),
margin: const EdgeInsets.all(3),
child: ListTile(leading: icon, title: Text(key), trailing: Text(value)),
);
}

String formatDate(DateTime date) => '${date.year}/${date.month}/${date.day}';
Expand Down Expand Up @@ -55,9 +52,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Mobility Features Example',
theme: ThemeData(
primarySwatch: Colors.blue,
),
theme: ThemeData(primarySwatch: Colors.blue),
home: const HomePage(title: 'Mobility Features Example'),
);
}
Expand Down Expand Up @@ -123,16 +118,19 @@ class HomePageState extends State<HomePage> {

// map from [LocationDto] to [LocationSample]
Stream<LocationSample> locationSampleStream = locationStream.map(
(location) => LocationSample(
GeoLocation(location.latitude, location.longitude),
DateTime.now()));
(location) => LocationSample(
GeoLocation(location.latitude, location.longitude),
DateTime.now(),
),
);

// provide the [MobilityFeatures] instance with the LocationSample stream
await MobilityFeatures().startListening(locationSampleStream);

// start listening to incoming MobilityContext objects
mobilitySubscription =
MobilityFeatures().contextStream.listen(onMobilityContext);
mobilitySubscription = MobilityFeatures().contextStream.listen(
onMobilityContext,
);
}

Future<bool> isLocationAlwaysGranted() async {
Expand Down Expand Up @@ -204,55 +202,63 @@ class HomePageState extends State<HomePage> {
children: <Widget>[
entry("Stops", "${_mobilityContext.stops?.length}", stopIcon),
entry("Moves", "${_mobilityContext.moves?.length}", moveIcon),
entry("Significant Places",
"${_mobilityContext.numberOfSignificantPlaces}", placeIcon),
entry(
"Home Stay",
_mobilityContext.homeStay == null || _mobilityContext.homeStay! < 0
? "?"
: "${(_mobilityContext.homeStay! * 100).toStringAsFixed(1)}%",
homeStayIcon),
"Significant Places",
"${_mobilityContext.numberOfSignificantPlaces}",
placeIcon,
),
entry(
"Home Stay",
_mobilityContext.homeStay == null || _mobilityContext.homeStay! < 0
? "?"
: "${(_mobilityContext.homeStay! * 100).toStringAsFixed(1)}%",
homeStayIcon,
),
entry(
"Distance Traveled",
"${(_mobilityContext.distanceTraveled! / 1000).toStringAsFixed(2)} km",
distanceTraveledIcon),
"Distance Traveled",
"${(_mobilityContext.distanceTraveled! / 1000).toStringAsFixed(2)} km",
distanceTraveledIcon,
),
entry(
"Normalized Entropy",
"${_mobilityContext.normalizedEntropy?.toStringAsFixed(2)}",
entropyIcon),
"Normalized Entropy",
"${_mobilityContext.normalizedEntropy?.toStringAsFixed(2)}",
entropyIcon,
),
entry(
"Location Variance",
"${(111.133 * _mobilityContext.locationVariance!).toStringAsFixed(5)} km",
varianceIcon),
"Location Variance",
"${(111.133 * _mobilityContext.locationVariance!).toStringAsFixed(5)} km",
varianceIcon,
),
],
);
}

List<Widget> get contentNoFeatures {
return [
Container(
margin: const EdgeInsets.all(25),
child: const Text(
'Move around to start generating features',
style: TextStyle(fontSize: 20),
))
margin: const EdgeInsets.all(25),
child: const Text(
'Move around to start generating features',
style: TextStyle(fontSize: 20),
),
),
];
}

List<Widget> get contentFeaturesReady {
return [
Container(
margin: const EdgeInsets.all(25),
child: Column(children: [
const Text(
'Statistics for today,',
style: TextStyle(fontSize: 20),
),
margin: const EdgeInsets.all(25),
child: Column(
children: [
const Text('Statistics for today,', style: TextStyle(fontSize: 20)),
Text(
formatDate(_mobilityContext.date!),
style: const TextStyle(fontSize: 20, color: Colors.blue),
),
])),
],
),
),
Expanded(child: featuresOverview),
];
}
Expand All @@ -274,16 +280,16 @@ class HomePageState extends State<HomePage> {
}

Widget get navBar => BottomNavigationBar(
onTap: onTabTapped,
currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed,
items: const [
BottomNavigationBarItem(icon: featuresIcon, label: 'Features'),
BottomNavigationBarItem(icon: stopIcon, label: 'Stops'),
BottomNavigationBarItem(icon: placeIcon, label: 'Places'),
BottomNavigationBarItem(icon: moveIcon, label: 'Moves')
],
);
onTap: onTabTapped,
currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed,
items: const [
BottomNavigationBarItem(icon: featuresIcon, label: 'Features'),
BottomNavigationBarItem(icon: stopIcon, label: 'Stops'),
BottomNavigationBarItem(icon: placeIcon, label: 'Places'),
BottomNavigationBarItem(icon: moveIcon, label: 'Moves'),
],
);

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -312,10 +318,7 @@ class HomePageState extends State<HomePage> {
];

return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
title: Text(widget.title),
),
appBar: AppBar(backgroundColor: Colors.teal, title: Text(widget.title)),
body: pages[_currentIndex],
bottomNavigationBar: navBar,
);
Expand Down
6 changes: 3 additions & 3 deletions packages/mobility_features/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ description: An example app for the Mobility Features package.
publish_to: "none"

environment:
sdk: ">=3.2.0 <4.0.0"
flutter: ">=3.16.0"
sdk: ">=3.8.0 <4.0.0"
flutter: ">=3.19.0"

dependencies:
flutter:
sdk: flutter
permission_handler: ^11.3.1
carp_background_location: ^4.0.0

mobility_features:
path: ../

Expand Down
Loading