Commit 48cabbac authored by Administrator's avatar Administrator

progress on local upload

parent f4964956
......@@ -7,10 +7,7 @@ import 'dart:io';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Db.create().connect();
var directories = await getExternalStorageDirectories();
var hintFile = File('${directories[0].path}/put_your_fit_files_here.txt');
await hintFile.writeAsString('This is the directory where Encrateia can pickup .fit-files from.');
await createHintFile();
runApp(MyApp());
}
......@@ -26,3 +23,10 @@ class MyApp extends StatelessWidget {
);
}
}
createHintFile() async {
var directories = await getExternalStorageDirectories();
var hintFile = File('${directories[0].path}/put_your_fit_files_here.txt');
await hintFile.writeAsString(
'This is the directory where Encrateia can pickup .fit-files from.');
}
......@@ -46,6 +46,12 @@ class Activity extends ChangeNotifier {
..movingTime = summaryActivity.movingTime;
}
Activity.fromLocalDirectory({Athlete athlete}) {
db = DbActivity()
..athletesId = athlete.db.id
..name = "t.b.d.";
}
String toString() => '$db.name $db.startTime';
Duration movingDuration() => Duration(seconds: db.movingTime ?? 0);
......@@ -93,6 +99,16 @@ class Activity extends ChangeNotifier {
setState("downloaded");
}
Future<bool> copyFromLocalDir() async {
//TODO: copy single file over
//TODO: if copied...
if (true == true) {
setState("downloaded");
return true;
} else
return false;
}
setState(String state) async {
db.state = state;
await db.save();
......@@ -178,7 +194,7 @@ class Activity extends ChangeNotifier {
db.sdevStrideRatio = Lap.calculateSdevStrideRatio(records: records);
var laps = await this.laps;
for(Lap lap in laps) {
for (Lap lap in laps) {
var records = await lap.records;
lap.db.avgPower = Lap.calculateAveragePower(records: records);
await lap.db.save();
......@@ -235,9 +251,7 @@ class Activity extends ChangeNotifier {
yield 100;
}
handleDataMessage({
DataMessage dataMessage,
}) async {
handleDataMessage({DataMessage dataMessage}) async {
if (dataMessage.definitionMessage.globalMessageName == null) {
switch (dataMessage.definitionMessage.globalMessageNumber) {
case 13:
......@@ -429,6 +443,14 @@ class Activity extends ChangeNotifier {
});
}
static importFromLocalDirectory({Athlete athlete}) async {
var activity = Activity.fromLocalDirectory(athlete: athlete);
bool copied = await activity.copyFromLocalDir();
if (copied == true) {
await activity.db.save();
}
}
static Future<List<Activity>> all({@required Athlete athlete}) async {
var dbActivityList =
await athlete.db.getDbActivities().orderByDesc('stravaId').toList();
......
......@@ -3,7 +3,6 @@ import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/lap.dart';
import 'package:encrateia/screens/show_lap_screen.dart';
import 'package:encrateia/utils/date_time_utils.dart';
import 'package:encrateia/utils/icon_utils.dart';
import 'package:encrateia/utils/num_utils.dart';
class LapsListWidget extends StatelessWidget {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment