Commit 0600addd authored by Nicolas Richard Walter Boeckh's avatar Nicolas Richard Walter Boeckh 💬

rm BatteryVis, Added header components, tweaks

Removed:
- Battery Visualizer -> Too much real estate taken, not so useful, device battery visible in main header and overview panel.
- Dash Separator -> Useless
- Growing text -> Relic from early testing days
- Header -> Replaced by `main_header` and `main_footer`.

Added:
- Documentation
- Main header components (battery and db, WIP: map and network)
- Main footer
- Locations of interest database (and related data classes).

Changed:
- DataHandler (WIP, remove reliance on latest packet, use database)
- Renamed DatabaseHandler to MainDatabaseHandler (only storing LogAir device data).
- Tweaks in overview widgets to remove tree clutter.
parent a41e44a8
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-0.4.9+2\\\\","dependencies":[]},{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-0.4.9+2\\\\","dependencies":[]},{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_macos-0.1.0+4\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+8\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"connectivity_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_for_web-0.3.1+2\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+5\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos","connectivity_for_web"]},{"name":"connectivity_for_web","dependencies":[]},{"name":"connectivity_macos","dependencies":[]},{"name":"flutter_blue","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-09-09 14:34:23.725205","version":"1.22.0-2.0.pre.18"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-0.4.9+2\\\\","dependencies":[]},{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"connectivity","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity-0.4.9+2\\\\","dependencies":[]},{"name":"flutter_blue","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_blue-0.7.2\\\\","dependencies":[]},{"name":"geolocator","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\geolocator-5.2.1\\\\","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_api_availability-2.0.2\\\\","dependencies":[]},{"name":"location_permissions","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\location_permissions-2.0.4+1\\\\","dependencies":[]},{"name":"path_provider","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider-1.6.0\\\\","dependencies":[]},{"name":"permission_handler","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-4.2.0+hotfix.3\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.5.7+2\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_macos-0.1.0+4\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-0.0.1+8\\\\","dependencies":[]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"connectivity_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\connectivity_for_web-0.3.1+2\\\\","dependencies":[]},{"name":"shared_preferences_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-0.1.2+5\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos","connectivity_for_web"]},{"name":"connectivity_for_web","dependencies":[]},{"name":"connectivity_macos","dependencies":[]},{"name":"flutter_blue","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-09-11 01:27:58.536487","version":"1.21.0-10.0.pre.193"}
\ No newline at end of file
......@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:latlong/latlong.dart';
import 'package:logair_application/logic/handlers/data_handler.dart';
import 'package:logair_application/logic/handlers/database_handler.dart';
import 'package:logair_application/logic/handlers/main_database_handler.dart';
import 'package:logair_application/logic/handlers/network_handler.dart';
import 'package:logair_application/logic/data_header.dart';
import 'package:logair_application/logic/data_packet.dart';
......@@ -35,7 +35,7 @@ class MapDisplayController {
Marker _marker;
Future<void> _rebuildMarkers() async {
List<DataPacket> packets = await DatabaseHandler().getLastPackets(200);
List<DataPacket> packets = await MainDatabaseHandler().getLastPackets(200);
packets.forEach((DataPacket packet) {
switch (_pmSymbol) {
case PMSymbol.PM1:
......
import 'package:logair_application/logic/handlers/bluetooth_le_handler.dart';
import 'package:logair_application/logic/data_header.dart';
import 'package:logair_application/logic/data_packet.dart';
import 'package:logair_application/logic/handlers/database_handler.dart';
import 'package:logair_application/logic/handlers/main_database_handler.dart';
import 'package:logair_application/logic/handlers/network_handler.dart';
class DataHandler {
......@@ -58,14 +58,14 @@ class DataHandler {
DataHeader().setHeader(packet);
/// Retroactively add all previous packets
if (!wasSet && DataHeader().headerSet)
_sortedData.forEach((packet) => DatabaseHandler().insertData(packet, DataHeader().deviceID, DataHeader().url));
_sortedData.forEach((packet) => MainDatabaseHandler().insertData(packet, DataHeader().deviceID, DataHeader().url));
/// Or if it is a [DataPacket] instance.
} else if (packet[0] == 91) {
_sortedData.add(DataPacket(packet));
print('PACKET ${String.fromCharCodes(packet)}');
if (DataHeader().headerSet)
DatabaseHandler().insertData(_sortedData.last, DataHeader().deviceID, DataHeader().url);
MainDatabaseHandler().insertData(_sortedData.last, DataHeader().deviceID, DataHeader().url);
}
}
/// TODO Used for debugging, later
......
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:logair_application/logic/data_packet.dart';
import 'package:logair_application/utils/location_of_interest.dart';
import 'package:path/path.dart';
import 'package:rxdart/rxdart.dart';
import 'package:sqflite/sqflite.dart';
/// Handler that integrates a mysqli database into the application's workflow.
class LocationsOfInterestDatabaseHandler {
factory LocationsOfInterestDatabaseHandler() => _singleton;
LocationsOfInterestDatabaseHandler._internal();
static final LocationsOfInterestDatabaseHandler _singleton = new LocationsOfInterestDatabaseHandler._internal();
/// Reference to the internalized [Database] within this instance.
Future<Database> _loidb;
/// [Database] initialization string, to reduce repetition.
final String _createLOIDBString = '''CREATE TABLE loi(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT, latitude REAL, longitude REAL
)''';
/// Retrieves the internal [Database] instance, and if not instantiated, instantiates it.
Future<Database> get _loiDatabase async {
if (_loidb == null)
this._loidb = openDatabase(
join((await getDatabasesPath()), 'logair_loi.db'),
version: 0,
onCreate: (db, version) => db.execute(this._createLOIDBString),
);
return this._loidb;
}
/// Purges the [Database] of all internal data.
Future<void> recreateDB() async {
final Database database = await _loiDatabase;
await database.rawQuery('DROP TABLE IF EXISTS loi');
await database.rawQuery(this._createLOIDBString);
this.onUpdate.value = 1;
}
/// Inserts data into the [Database].
Future<void> insertData({@required String name, @required double latitude, @required double longitude}) async {
final Database database = await this._loiDatabase;
Map<String, dynamic> insert = {
'name': name,
'latitude': latitude,
'longitude': longitude
};
await database.insert(
'loi',
insert,
conflictAlgorithm: ConflictAlgorithm.replace
);
this.onUpdate.value = 1;
}
/// Retrieves all of the [DataPacket]s inserted into the [Database].
Future<List<LocationOfInterest>> get data async {
final Database database = await this._loiDatabase;
final List<Map<String, dynamic>> data = await database.query('loi');
return List.generate(data.length, (i) => LocationOfInterest(
id: data[i]['id'],
name: data[i]['name'],
latitude: data[i]['latitude'],
longitude: data[i]['longitude']
));
}
/// Closes the [Database] instance.
Future<void> close() async => (await this._loiDatabase).close();
/// Async capable variable used to trigger updates.
BehaviorSubject<void> onUpdate = BehaviorSubject<void>();
LocationsOfInterestDatabaseHandler.dispose() {
onUpdate.close();
this.close();
}
}
\ No newline at end of file
......@@ -5,61 +5,51 @@ import 'package:sqflite/sqflite.dart';
import 'package:tuple/tuple.dart';
/// Handler that integrates a mysqli database into the application's workflow.
// TODO: Table for data locations
class DatabaseHandler {
factory DatabaseHandler() => _singleton;
class MainDatabaseHandler {
factory MainDatabaseHandler() => _singleton;
DatabaseHandler._internal();
MainDatabaseHandler._internal();
static final DatabaseHandler _singleton = new DatabaseHandler._internal();
static final MainDatabaseHandler _singleton = new MainDatabaseHandler._internal();
/// Reference to the internalized [Database] within this instance.
Future<Database> _db;
Future<Database> _maindb;
/// [Database] initialization string, to reduce repetition.
final String createString = '''CREATE TABLE data(
final String _createMainDBString = '''CREATE TABLE data(
id INTEGER PRIMARY KEY AUTOINCREMENT,
device_id TEXT,
url TEXT,
device_id TEXT, url TEXT,
timestamp_nix INTEGER,
latitude REAL,
longitude REAL,
altitude INTEGER,
speed REAL,
heading INTEGER,
temperature FLOAT,
relative_humidity FLOAT,
pressure FLOAT,
pm_1 FLOAT,
pm_2_5 FLOAT,
pm_4 FLOAT,
pm_10 FLOAT,
latitude REAL, longitude REAL,
altitude INTEGER, speed REAL, heading INTEGER,
temperature FLOAT, relative_humidity FLOAT, pressure FLOAT,
pm_1 FLOAT, pm_2_5 FLOAT, pm_4 FLOAT, pm_10 FLOAT,
extra TEXT,
exported TINYINT DEFAULT 0
)''';
/// Retrieves the internal [Database] instance, and if not instantiated, instantiates it.
Future<Database> get _database async {
if (_db == null)
this._db = openDatabase(
Future<Database> get _mainDatabase async {
if (_maindb == null)
this._maindb = openDatabase(
join((await getDatabasesPath()), 'logair_data.db'),
version: 2,
onCreate: (db, version) => db.execute(createString)
version: 3,
onCreate: (db, version) => db.execute(this._createMainDBString)
);
return this._db;
return this._maindb;
}
/// Purges the [Database] of all internal data.
Future<void> recreateDB() async {
final Database database = await _database;
final Database database = await _mainDatabase;
await database.rawQuery('DROP TABLE IF EXISTS data');
await database.rawQuery(createString);
await database.rawQuery(this._createMainDBString);
}
/// Inserts data into the [Database].
Future<void> insertData(DataPacket packet, String deviceId, String url) async {
final Database database = await _database;
final Database database = await this._mainDatabase;
Map<String, dynamic> insert = packet.toMap();
insert['device_id'] = deviceId;
insert['url'] = url;
......@@ -72,7 +62,7 @@ class DatabaseHandler {
/// Retrieves all of the [DataPacket]s inserted into the [Database].
Future<List<DataPacket>> get data async {
final Database database = await _database;
final Database database = await this._mainDatabase;
final List<Map<String, dynamic>> data = await database.query('data');
......@@ -80,11 +70,11 @@ class DatabaseHandler {
}
/// Closes the [Database] instance.
Future<void> close() async => (await this._database).close();
Future<void> close() async => (await this._mainDatabase).close();
/// Streams the amount of elements contained within the [Database].
Stream<int> getDBSize() async* {
final Database database = await _database;
final Database database = await this._mainDatabase;
while (true) {
final List<Map<String, dynamic>> data = await database.query('data', columns: ['COUNT(*) AS count']);
yield data[0]['count'] ?? 0;
......@@ -94,7 +84,7 @@ class DatabaseHandler {
/// Retrieves all of the unsent packets in the [DataPacket].
Future<List<Tuple2<int, DataPacket>>> getUnsent(int limit) async {
final Database database = await _database;
final Database database = await this._mainDatabase;
final List<Map<String, dynamic>> data = await database.query('data',
where: 'exported = ?',
whereArgs: [0],
......@@ -107,7 +97,7 @@ class DatabaseHandler {
/// This flags all of the internal packets that are given as [ids] as exported to the external servers.
Future<void> setExported(List<int> ids) async {
final Database database = await _database;
final Database database = await this._mainDatabase;
int count = await database.rawUpdate('UPDATE data SET exported = 1 WHERE id IN (${ids.join(', ')})');
......@@ -116,7 +106,7 @@ class DatabaseHandler {
/// Used to monitor the amount of unsent [DataPacket]s.
Stream<int> getUnsentPacketsLength() async* {
final Database database = await _database;
final Database database = await this._mainDatabase;
while (true) {
final List<Map<String, dynamic>> data = await database.query('data',
columns: ['COUNT(*) AS count'],
......@@ -130,7 +120,7 @@ class DatabaseHandler {
/// Retrieves the latest 5 seconds of data every 5 seconds.
Stream<Map<String, dynamic>> getLatest() async* {
final Database database = await _database;
final Database database = await _mainDatabase;
while (true) {
final List<Map<String, dynamic>> data = await database.rawQuery('SELECT MIN(timestamp_nix) AS start, AVG(pm_1) AS pm_1, AVG(pm_2_5) AS pm_2_5, AVG(pm_4) AS pm_4, AVG(pm_10) AS pm_10 FROM (SELECT * FROM data WHERE timestamp_nix >= ${DateTime.now().millisecondsSinceEpoch - 10000} ORDER BY id DESC LIMIT 5)');
yield data[0] ?? Map();
......@@ -140,7 +130,7 @@ class DatabaseHandler {
/// Retrieves the latest [maxResults] packets inserted into the [Database].
Future<List<DataPacket>> getLastPackets(int maxResults) async {
final Database database = await _database;
final Database database = await this._mainDatabase;
final List<Map<String, dynamic>> data = await database.rawQuery('SELECT * FROM data ORDER BY id DESC LIMIT $maxResults;');
......
......@@ -9,7 +9,7 @@ import 'package:http/http.dart' as http;
import 'package:logair_application/logic/data_header.dart';
import 'package:logair_application/logic/data_packet.dart';
import 'package:logair_application/logic/handlers/data_handler.dart';
import 'package:logair_application/logic/handlers/database_handler.dart';
import 'package:logair_application/logic/handlers/main_database_handler.dart';
import 'package:logair_application/logic/handlers/preference_handler.dart';
import 'package:logair_application/utils/enums/preference_keys.dart';
import 'package:rxdart/rxdart.dart';
......@@ -101,8 +101,8 @@ class NetworkHandler {
String url = 'https://api.logair.unige.ch/v1/service';
// Send data in a serialized manner (FIFO)
if (await DatabaseHandler().getUnsentPacketsLength().first > 0) {
DataPacket source = (await DatabaseHandler().getUnsent(_pushAmount.value ?? PreferenceKeys.NET__MAX_ITEMS_PER_PUSH.defaultValue))[0].item2;
if (await MainDatabaseHandler().getUnsentPacketsLength().first > 0) {
DataPacket source = (await MainDatabaseHandler().getUnsent(_pushAmount.value ?? PreferenceKeys.NET__MAX_ITEMS_PER_PUSH.defaultValue))[0].item2;
// TODO set url / clean up
DataHeader().setHeaderFromExisting(deviceId: source.deviceId, url: '');
}
......@@ -114,7 +114,7 @@ class NetworkHandler {
Map<String, dynamic> headerData = DataHeader().jsonify();
/// The indexed [DataPacket]s to be sent (user set or default value @see [PreferenceKeys.NET__MAX_ITEMS_PER_PUSH]).
List<Tuple2<int, DataPacket>> databaseData = await DatabaseHandler().getUnsent(_pushAmount.value ?? PreferenceKeys.NET__MAX_ITEMS_PER_PUSH.defaultValue);
List<Tuple2<int, DataPacket>> databaseData = await MainDatabaseHandler().getUnsent(_pushAmount.value ?? PreferenceKeys.NET__MAX_ITEMS_PER_PUSH.defaultValue);
/// The [DataPacket]s to be sent.
List<DataPacket> packets = databaseData.map((x) => x.item2).toList();
......@@ -149,7 +149,7 @@ class NetworkHandler {
for (int i = 0; i < packets.length; i++)
DataHandler().pop(packets[i].timestamp);
await DatabaseHandler().setExported(databaseData.map((x) => x.item1).toList());
await MainDatabaseHandler().setExported(databaseData.map((x) => x.item1).toList());
print('RESPONSE ${response.statusCode}');
this._lastServerTransmission = DateTime.now();
}
......
......@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'package:device_preview/device_preview.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:logair_application/logic/handlers/locations_interest_database_handler.dart';
import 'package:logair_application/logic/handlers/main_database_handler.dart';
import 'package:logair_application/logic/handlers/network_handler.dart';
import 'package:logair_application/logic/handlers/preference_handler.dart';
......@@ -27,6 +29,9 @@ class LogAirApplication extends StatelessWidget {
PreferencesHandler();
NetworkHandler();
MainDatabaseHandler();
LocationsOfInterestDatabaseHandler();
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
......
import 'package:fl_chart/fl_chart.dart';
import 'package:logair_application/logic/handlers/database_handler.dart';
import 'package:logair_application/logic/handlers/main_database_handler.dart';
import 'package:logair_application/ui/components/body/data/data_widget.dart';
/// This Controller type class serves to remove the data aspect of the [LineChart] from Flutter's build tree,
......@@ -12,7 +12,7 @@ class GraphController {
GraphController._internal() {
/// Every 5 seconds, averaged values are taken from the database and streamed.
/// This listener appends the data to the storage.
DatabaseHandler().getLatest().listen((newData) {
MainDatabaseHandler().getLatest().listen((newData) {
this.start = this.start ?? DateTime.now().millisecondsSinceEpoch * 1.0;
this.now = (DateTime.now().millisecondsSinceEpoch - this.start) / 1000;
// Get max y value to avoid out of bounding on y-axis
......
......@@ -59,7 +59,7 @@ class MapContainer extends BaseWidget {
children: [
BaseWidget(
builder: (ctx, sizingInformation) => Container(
height: sizingInformation.unnotchedHeight() * 33/40 * 0.16,
height: sizingInformation.unnotchedHeight * 33/40 * 0.16,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
......@@ -132,7 +132,7 @@ class MapContainer extends BaseWidget {
),
BaseWidget(
builder: (ctx, sizingInformation) => Container(
height: sizingInformation.unnotchedHeight() * 33/40 * 0.05,
height: sizingInformation.unnotchedHeight * 33/40 * 0.05,
child: Row(
children: [
_buildMapLayerSelection('PM 1', () => MapDisplayController().setPMKeyIndex(PMSymbol.PM1)),
......@@ -148,7 +148,7 @@ class MapContainer extends BaseWidget {
children: [
BaseWidget(
builder: (ctx, sizingInformation) => Container(
height: sizingInformation.unnotchedHeight() * 33/40 * 0.75,
height: sizingInformation.unnotchedHeight * 33/40 * 0.75,
child: Listener(
behavior: HitTestBehavior.deferToChild,
child: _buildMap()
......
......@@ -6,7 +6,7 @@ import 'package:logair_application/ui/components/body/overview/overview_widgets/
import 'package:logair_application/ui/components/body/overview/overview_widgets/network_overview_widget.dart';
import 'package:logair_application/ui/components/body/overview/overview_navigation_button.dart';
import 'package:logair_application/ui/components/dialog/bluetooth_dialog/dialog.dart';
import 'package:logair_application/ui/components/header/header.dart';
import 'package:logair_application/ui/components/footer/main_footer.dart';
import 'package:logair_application/ui/routes/preferences.dart';
import 'package:logair_application/ui/components/common/base_widget.dart';
......@@ -127,7 +127,7 @@ class OverviewWidget extends StatelessWidget {
onLongPress: () {
Navigator.of(context).pop();
},
child: HeaderWidget(false)
child: MainFooter(),
),
),
),
......
......@@ -3,6 +3,7 @@ import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_blue/flutter_blue.dart';
import 'package:intersperse/intersperse.dart';
import 'package:logair_application/logic/data_header.dart';
import 'package:logair_application/ui/components/body/overview/overview_widgets/common/overview_data_cell.dart';
import 'package:logair_application/ui/components/body/overview/overview_widgets/common/decorations.dart';
......@@ -40,34 +41,35 @@ class BTOverviewWidget extends StatelessWidget {
),
Text((l >= 0) ? '$l%' : 'Unknown', style: TextStyle(color: Colors.white))
]
);
);
}
);
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
width: 50,
height: 50,
decoration: iconContainerNeumorphicDecoration,
child: Icon(
Icons.bluetooth,
color: Colors.white,
size: 30,
return SingleChildScrollView(
child: Column(
children: intersperse(SizedBox(height: 10), [
Container(
width: 50,
height: 50,
decoration: iconContainerNeumorphicDecoration,
child: Icon(
Icons.bluetooth,
color: Colors.white,
size: 30,
),
),
OverviewDataCell(
label: 'Connected to',
builder: _buildDeviceIdWidget(),
),
),
OverviewDataCell(
label: 'Connected to',
builder: _buildDeviceIdWidget(),
),
OverviewDataCell(
label: 'Device battery',
builder: _buildDeviceBatteryLevelWidget(),
),
]
OverviewDataCell(
label: 'Device battery',
builder: _buildDeviceBatteryLevelWidget(),
),
]).toList()
)
);
}
}
\ No newline at end of file
......@@ -3,8 +3,9 @@ import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttericon/linecons_icons.dart';
import 'package:intersperse/intersperse.dart';
import 'package:intl/intl.dart';
import 'package:logair_application/logic/handlers/database_handler.dart';
import 'package:logair_application/logic/handlers/main_database_handler.dart';
import 'package:logair_application/ui/components/body/overview/overview_widgets/common/decorations.dart';
import 'package:logair_application/ui/components/body/overview/overview_widgets/common/overview_data_cell.dart';
......@@ -13,7 +14,7 @@ class DBOverviewWidget extends StatelessWidget {
/// Builds a [Text] containing the number of elements stored in the internal database.
StreamBuilder<int> _buildDBSizeWidget() => StreamBuilder<int>(
stream: DatabaseHandler().getDBSize(),
stream: MainDatabaseHandler().getDBSize(),
initialData: 0,
builder: (BuildContext context, AsyncSnapshot snapshot) => Text(
'${NumberFormat.compact().format(snapshot.data)}',
......@@ -26,7 +27,7 @@ class DBOverviewWidget extends StatelessWidget {
/// Builds a [Text] containing the number of unsent elements stored in the internal database.
StreamBuilder<int> _buildDBUnsentQuantityWidget() => StreamBuilder<int>(
stream: DatabaseHandler().getUnsentPacketsLength(),
stream: MainDatabaseHandler().getUnsentPacketsLength(),
initialData: 0,
builder: (BuildContext context, AsyncSnapshot snapshot) => Text(
'${NumberFormat.compact().format(snapshot.data)}',
......@@ -39,28 +40,29 @@ class DBOverviewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
width: 50,
height: 50,
decoration: iconContainerNeumorphicDecoration,
child: Icon(
Linecons.database,
color: Colors.white,
size: 30,
return SingleChildScrollView(
child: Column(
children: intersperse(SizedBox(height: 10), [
Container(
width: 50,
height: 50,
decoration: iconContainerNeumorphicDecoration,
child: Icon(
Linecons.database,
color: Colors.white,
size: 30,
),
),
),
OverviewDataCell(
label: 'Packets stored',
builder: _buildDBSizeWidget(),
),
OverviewDataCell(
label: 'Unsent packets',
builder: _buildDBUnsentQuantityWidget(),
),
],
OverviewDataCell(
label: 'Packets stored',
builder: _buildDBSizeWidget(),
),
OverviewDataCell(
label: 'Unsent packets',
builder: _buildDBUnsentQuantityWidget(),
),
]).toList(),
)
);
}
}
\ No newline at end of file
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intersperse/intersperse.dart';
import 'package:intl/intl.dart';
import 'package:logair_application/logic/handlers/preference_handler.dart';
import 'package:logair_application/ui/components/body/overview/overview_widgets/common/overview_data_cell.dart';
......@@ -53,28 +54,29 @@ class MapPositionOverviewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
width: 50,
height: 50,
decoration: iconContainerNeumorphicDecoration,
child: Icon(
Icons.location_on,
color: Colors.white,
size: 30,
return SingleChildScrollView(
child: Column(
children: intersperse(SizedBox(height: 10), [
Container(
width: 50,
height: 50,
decoration: iconContainerNeumorphicDecoration,
child: Icon(
Icons.location_on,
color: Colors.white,
size: 30,
),
),