In support of the Nature 4.0 project an app was developed for collecting nature data and making them available to researchers.
This project is split into three different repositories:
To get to know the other components of the project visit the corresponding git-repositories.
This repository covers the application component.
The application requests authorization for your location while it is running to determine your position on the map. Furthermore, when doing a photo capturing task, you are asked to allow access to the camera and microphone of the device. Apart from that the user can run the application as a background service to passively download and upload data.
You can download a working version of the project in the releases tab.
Before you begin, make sure that the following requirements are met:
- android-sdk version 28 with android-studio.
- working flutter installation (we tested with version 1.22.4). You can either install flutter manually or use the provided nix-shell by executing
nix-shell
in CLI. - You either have a mobile device (at the moment only android is supported) connected to your workstation in debug mode or an android emulator setup.
- clone the git-repository:
git clone https://github.com/remunds/data-offloading-app/
cd data-offloading-app
- get all flutter dependencies
flutter pub get
- start the application with flutter
flutter run
You have to configure the following parameters to run the project
-
modify the class
Task
inlib/data/task.dart
class Task { final String id; final String title; final String description; final String imageId; // you can add another attribute here final String myNewAttribute; Task({this.id, this.title, this.description, this.imageId, this.myNewAttribute}); factory Task.fromJson(Map<String, dynamic> json) { return Task( id: json['_id'], title: json['title'], description: json['description'], imageId: json['imageId'], //remember to add the new attribute in schema.js on the sensorbox myNewAttribute: json['myNewAttribute']); } Map<String, dynamic> toJson() { return { '_id': id, 'title': title, 'description': description, 'imageId': imageId, // also add your new attribute here 'myNewAttribute': myNewAttribute, }; } }
-
add a condition in
lib/widgets/task_widget.dart
to process the new task -
delete the task by calling
_deleteTask(widget.task)
when the task is done -
increase the count of tasks of type
<type>
by callingStats.increaseTask("<taskName>")
-
if the tasks includes communication with the sensor box you might want to add a function in
lib/logic/box_communicator.dart
and call it inlib/widgets/task_widget.dart
class _TaskWidgetState extends State<TaskWidget> { ... ... @override Widget build(BuildContext context) { ... ... //You can change the condition to identify your task to anything you like else if (widget.task.title.compareTo("MyNewTask") == 0){ //process your new task here ... //maybe call a function from box_communicator.dart BoxCommunicator().myNewProcessingAndCommunicationFunction(); ... //delete the task so that it is marked as done _deleteTask(widget.task); //increase the counter of finished tasks of type MyNewTask Stats.increaseTask("MyNewTask"); } } }
-
modify
List<String> taskList
inlib/widgets/finished_tasks_widget.dart
by adding the new Task'myNewTask'
List<String> taskList = [ 'imageTask', 'cleaningTask', 'myNewTask', ];
-
in
lib/logic/box_communicator.dart
changestatic final String backendRawIP
to the IP of the back end server.
-
in
lib/logic/box_communicator
changestatic final String boxRawIP
to the IP of the box.
-
in
android/app/src/main/AndroidManifest.xml
changeandroid:label
<application android:name="io.flutter.app.FlutterApplication" android:label="myAppName" android:icon="@mipmap/ic_launcher">
This project's code is licensed under the GNU General Public License version 3 (GPL-3.0-or-later).