Commit e1ea0caa authored by Nicolas Richard Walter Boeckh's avatar Nicolas Richard Walter Boeckh 💬
Browse files

QOL edits to BatteryService, train of thought

parent bc031921
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"battery","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\battery-0.3.1+7\\\\","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":"plugin_scaffold","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\plugin_scaffold-1.2.0\\\\","dependencies":[]},{"name":"rx_ble","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\rx_ble-0.6.1\\\\","dependencies":["plugin_scaffold"]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"battery","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\battery-0.3.1+7\\\\","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":"plugin_scaffold","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\plugin_scaffold-1.2.0\\\\","dependencies":[]},{"name":"rx_ble","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\rx_ble-0.6.1\\\\","dependencies":["plugin_scaffold"]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"battery","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":"plugin_scaffold","dependencies":[]},{"name":"rx_ble","dependencies":["plugin_scaffold"]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-02-06 15:03:57.583144","version":"1.14.7-pre.83"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"battery","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\battery-0.3.1+7\\\\","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":"plugin_scaffold","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\plugin_scaffold-1.2.0\\\\","dependencies":[]},{"name":"rx_ble","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\rx_ble-0.6.1\\\\","dependencies":["plugin_scaffold"]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"android":[{"name":"battery","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\battery-0.3.1+7\\\\","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":"plugin_scaffold","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\plugin_scaffold-1.2.0\\\\","dependencies":[]},{"name":"rx_ble","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\rx_ble-0.6.1\\\\","dependencies":["plugin_scaffold"]},{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"macos":[{"name":"sqflite","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\sqflite-1.2.0\\\\","dependencies":[]}],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"battery","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":"plugin_scaffold","dependencies":[]},{"name":"rx_ble","dependencies":["plugin_scaffold"]},{"name":"sqflite","dependencies":[]}],"date_created":"2020-02-06 16:34:56.089969","version":"1.14.7-pre.83"}
\ No newline at end of file
......@@ -9,11 +9,14 @@ Dates are in the sensible `DD/MM/YYYY` format.
## Upcoming Features
- Add | (UX) Accessibility options
- Add | (Func) Param for download maps on Wifi
- Add | (Func) Param for data push on Wifi
- Add | (UI) Options menu
- Push data only on WiFi option
- Pre download maps (range (optional, min 25km))
- Pre download only on WiFi
- Prefs stored from one session to the next.
- Language switch possible (not just locale).
- Add | (UI) Leaflet (flutter_map) | just the map (6h) + (overlay data || )
- Bluetooth (recents list.s)
- Add | (Func) Cache file for data | 2+3-4h
......
# Collection of thoughts and general development process.
## [0.0.2] - current
The idea for BLE is to use Platform specific code, ie `Platform channels`...
| Platform Specific | Cross OS |
| ------------------------ | ------------------------:|
| Bluetooth Read | Scan named MAC addresses |
| Stay Alive | Write to File |
| | |
| Get Battery level ✅ | |
Testing procedure for background will include the backup system as well.
### Resources
- [Permissions aaS](https://www.filledstacks.com/snippet/request-permissions-in-flutter-as-a-service/)
- [Toasts](https://www.filledstacks.com/snippet/easy-toasts-with-ok-toast/)
- [Splash Screen](https://www.filledstacks.com/snippet/setting-up-your-splash-screen-in-flutter/)
- [Dialogs](https://www.filledstacks.com/snippet/quick-and-easy-dialogs-in-flutter-with-rf-flutter/)
- [Platform Channels](https://flutter.dev/docs/development/platform-integration/platform-channels?tab=ios-channel-swift-tab) \[[Code](https://github.com/flutter/flutter/tree/master/examples/platform_channel_swift)\]
- [Networking in the background](https://flutter.dev/docs/cookbook/networking/background-parsing)
## [0.0.1] - 05/02/2020
UI basis : a card carousel system, with a revealable options / stats pane.
```nil
+---------------+
| |
| |
| |
| Options |
+-------------> | | <-------------+
| | Stats | |
| | | |
| | | |
| | | |
| +---------------+ |
| ^ |
| | |
∨ ∨ ∨
+---------------+ +---------------+ +---------------+
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| Map | <---> | Data | <---> | Social |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
+---------------+ +---------------+ +---------------+
^ ^
| |
+-----------------------------------------------+
```
# Collection of thoughts and general development process.
## [0.0.2] - current
The idea for BLE is to use Platform specific code, ie `Platform channels`...
| Platform Specific | Cross OS |
| ------------------------ | ------------------------:|
| Bluetooth Read | Scan named MAC addresses |
| Stay Alive | Write to File |
| | |
| Get Battery level ✅ | |
Testing procedure for background will include the backup system as well (ie. writing to files).
`BatteryService`, `BTLEHandler`, `WebsocketHandler` and the likes should be `Singletons`, to reduce load on the platform.
Also, `BTLEHandler` needs to follow an inverse paradigm to `BatteryService`, ie. it shouldn't request updates but listen to them.
Also also, the UI and service elements of battery, bluetooth or web should be distinct.
Check on whether or not a listener can be affixed to whatever the platform is doing, consider the Kotlin/Swift equivalents to `TimerTask's`, but in the background.
Bluetooth should have at least a few tasks (discovery -> pump all MAC's and display), (connect <- ) (read ->).
### Resources
- [Permissions aaS](https://www.filledstacks.com/snippet/request-permissions-in-flutter-as-a-service/)
- [Toasts](https://www.filledstacks.com/snippet/easy-toasts-with-ok-toast/)
- [Splash Screen](https://www.filledstacks.com/snippet/setting-up-your-splash-screen-in-flutter/)
- [Dialogs](https://www.filledstacks.com/snippet/quick-and-easy-dialogs-in-flutter-with-rf-flutter/)
- [Platform Channels](https://flutter.dev/docs/development/platform-integration/platform-channels?tab=ios-channel-swift-tab) \[[Code](https://github.com/flutter/flutter/tree/master/examples/platform_channel_swift)\]
- [Networking in the background](https://flutter.dev/docs/cookbook/networking/background-parsing)
## [0.0.1] - 05/02/2020
UI basis : a card carousel system, with a revealable options / stats pane (see [Annex 1](#annex-1))
Internationalization : Context dependant display of text, defaults to base language (en) if not implemented.
Useful to implement at the beginning because otherwise refactoring becomes painful.
Based on the intl package, and uses it's generators to convert the `.arb` files (text, description, etc. in JSON format) to `.dart` files, of which only one is loaded at launch (also possible to force reload on language switch).
### Annex 1
```nil
+---------------+
| |
| |
| |
| Options |
+-------------> | | <-------------+
| | Stats | |
| | | |
| | | |
| | | |
| +---------------+ |
| ^ |
| | |
∨ ∨ ∨
+---------------+ +---------------+ +---------------+
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| Map | <---> | Data | <---> | Social |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
+---------------+ +---------------+ +---------------+
^ ^
| |
+-----------------------------------------------+
```
connection.project.dir=
eclipse.preferences.version=1
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
connection.project.dir=..
eclipse.preferences.version=1
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.source=1.8
import 'package:flutter/services.dart';
class BatteryHandler {
int _batteryLevel;
static const platform = const MethodChannel('logair.application/battery');
Future<int> _getBatteryLevel() async {
int batteryLevel;
try {
batteryLevel = await platform.invokeMethod('getBatteryLevel');
} on PlatformException catch (e) { }
return batteryLevel;
}
Future<int> get batteryLevel async {
return await _getBatteryLevel();
}
}
import 'package:flutter/services.dart';
class BatteryService {
static const platform = const MethodChannel('logair.application/battery');
Future<int> get batteryLevel async {
int batteryLevel;
try {
batteryLevel = await platform.invokeMethod('getBatteryLevel');
} on PlatformException catch (e) {
print('BATTERY_SERVICE : $e');
}
return batteryLevel;
}
}
import 'package:flutter/services.dart';
class BTLEHandler {
static const platform = const MethodChannel('logair.application/btle');
}
\ No newline at end of file
import 'package:flutter/material.dart';
import 'package:logair_application/localization/localization.dart';
import 'package:logair_application/ui/permission_dialog.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:rx_ble/rx_ble.dart';
Function wrapper(Function f) {
return () async {
var value, error;
try {
value = await f();
print('Returned $value');
} catch (e, trace) {
print('Error $e\nTrace : $trace');
error = e;
} finally {
}
}
}
Future<void> requestAccess() async {
return await RxBle.requestAccess(
showRationale: () async {
return await showDialog(
context: context,
builder: (context) => PermissionDialog(
title: InternalLocalization.of(context).locationPromptTitle,
dialogText: InternalLocalization.of(context).locationPromptReason ,
permissionGroup: PermissionGroup.locationAlways,
),
) ?? false;
}
);
}
......@@ -16,12 +16,12 @@ class CarouselCard extends StatelessWidget {
builder: (context, sizingInfo) => new Container(
color: color,
width: sizingInfo.localWidgetSize.width,
padding: EdgeInsets.all(5),
padding: EdgeInsets.only(right: 2, left: 2, bottom: 2, top:1),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.grey.shade500),
borderRadius: BorderRadius.all(Radius.circular(10)),
borderRadius: BorderRadius.only(topLeft: Radius.circular(2), topRight: Radius.circular(2), bottomLeft: Radius.circular(40), bottomRight: Radius.circular(40)),
),
child: child
),
......
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:logair_application/ui/carousel_card.dart';
import 'package:logair_application/platform/battery.dart';
import 'package:logair_application/platform/battery_service.dart';
class DataWidget extends StatelessWidget {
DataWidget();
......@@ -13,7 +13,7 @@ class DataWidget extends StatelessWidget {
children: [
RaisedButton(
onPressed: () => {
BatteryHandler().batteryLevel.then((value) => print(value))
BatteryService().batteryLevel.then((value) => print(value))
},
child: Text(
'Do whatever',
......
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