Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #20 from Plangora/master
Browse files Browse the repository at this point in the history
add source of fitdata from devices
  • Loading branch information
krokyze authored Sep 27, 2019
2 parents 7b834ef + d426d2c commit 988f51d
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 127 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
.pub/

build/
.idea/
*.iml
19 changes: 0 additions & 19 deletions .idea/libraries/Dart_SDK.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/libraries/Flutter_for_Android.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/runConfigurations/example_lib_main_dart.xml

This file was deleted.

45 changes: 0 additions & 45 deletions .idea/workspace.xml

This file was deleted.

2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.android.gms:play-services-fitness:17.0.0'
implementation 'com.google.android.gms:play-services-fitness:18.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class FitKitPlugin(private val registrar: Registrar) : MethodCallHandler {
}
map["date_from"] = dataPoint.getStartTime(TimeUnit.MILLISECONDS)
map["date_to"] = dataPoint.getEndTime(TimeUnit.MILLISECONDS)
map["source"] = dataPoint.originalDataSource.streamName
return map
}
}
14 changes: 7 additions & 7 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
version: "2.3.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
charcode:
dependency: transitive
description:
Expand Down Expand Up @@ -66,28 +66,28 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.1.7"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0+1"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.5"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -120,7 +120,7 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
term_glyph:
dependency: transitive
description:
Expand Down
19 changes: 0 additions & 19 deletions fit_kit.iml

This file was deleted.

11 changes: 10 additions & 1 deletion ios/Classes/SwiftFitKitPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,22 @@ public class SwiftFitKitPlugin: NSObject, FlutterPlugin {

print(samples)
result(samples.map { sample -> NSDictionary in
return [
[
"value": sample.quantity.doubleValue(for: request.unit),
"date_from": Int(sample.startDate.timeIntervalSince1970 * 1000),
"date_to": Int(sample.endDate.timeIntervalSince1970 * 1000),
"source": self.readSource(sample: sample),
]
})
}
healthStore!.execute(query)
}

private func readSource(sample: HKQuantitySample) -> String {
if #available(iOS 9, *) {
return sample.sourceRevision.source.name;
}

return sample.source.name;
}
}
8 changes: 5 additions & 3 deletions lib/src/fit_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ class FitData {
final num value;
final DateTime dateFrom;
final DateTime dateTo;
final String source;

FitData(this.value, this.dateFrom, this.dateTo);
FitData(this.value, this.dateFrom, this.dateTo, this.source);

FitData.fromJson(Map<dynamic, dynamic> json)
: value = json['value'],
dateFrom = DateTime.fromMillisecondsSinceEpoch(json['date_from']),
dateTo = DateTime.fromMillisecondsSinceEpoch(json['date_to']);
dateTo = DateTime.fromMillisecondsSinceEpoch(json['date_to']),
source = json['source'];

@override
String toString() =>
'FitData(value: $value, dateFrom: $dateFrom, dateTo: $dateTo)';
'FitData(value: $value, dateFrom: $dateFrom, dateTo: $dateTo, source: $source)';
}
14 changes: 7 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
version: "2.3.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
charcode:
dependency: transitive
description:
Expand Down Expand Up @@ -52,28 +52,28 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.1.7"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
version: "1.6.4"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0+1"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.5"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -106,7 +106,7 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
term_glyph:
dependency: transitive
description:
Expand Down

0 comments on commit 988f51d

Please sign in to comment.