-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,339 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-keep class com.lib.flutter_blue_plus.* { *; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,93 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.zenithaerospace.monitor"> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
package="com.zenithaerospace.monitor"> | ||
|
||
<application | ||
android:label="zenith_monitor" | ||
android:icon="@mipmap/ic_launcher"> | ||
<meta-data android:name="com.google.android.geo.API_KEY" | ||
android:value="${MAPS_API_KEY}"/> | ||
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> | ||
<activity android:name="com.facebook.FacebookActivity" android:configChanges= "keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" /> | ||
<activity android:name="com.facebook.CustomTabActivity" android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
<data android:scheme="@string/fb_login_protocol_scheme" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name="com.yalantis.ucrop.UCropActivity" | ||
android:screenOrientation="portrait" | ||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/> | ||
<activity | ||
android:name=".MainActivity" | ||
android:launchMode="singleTop" | ||
android:exported="true" | ||
android:theme="@style/LaunchTheme" | ||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" | ||
android:hardwareAccelerated="true" | ||
android:windowSoftInputMode="adjustResize"> | ||
<!-- Specifies an Android theme to apply to this Activity as soon as | ||
the Android process has started. This theme is visible to the user | ||
while the Flutter UI initializes. After that, this theme continues | ||
to determine the Window background behind the Flutter UI. --> | ||
<meta-data | ||
android:name="io.flutter.embedding.android.NormalTheme" | ||
android:resource="@style/NormalTheme" | ||
/> | ||
<!-- Displays an Android View that continues showing the launch screen | ||
Drawable until Flutter paints its first frame, then this splash | ||
screen fades out. A splash screen is useful to avoid any visual | ||
gap between the end of Android's launch screen and the painting of | ||
Flutter's first frame. --> | ||
<meta-data | ||
android:name="io.flutter.embedding.android.SplashScreenDrawable" | ||
android:resource="@drawable/launch_background" | ||
/> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> | ||
</intent-filter> | ||
<!-- Permissions and features should be at this level --> | ||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
|
||
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" | ||
android:resource="@xml/device_filter" /> | ||
</activity> | ||
<!-- Don't delete the meta-data below. | ||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> | ||
<meta-data | ||
android:name="flutterEmbedding" | ||
android:value="2" /> | ||
</application> | ||
<!-- Tell Google Play Store that your app uses Bluetooth LE --> | ||
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" /> | ||
|
||
<!-- New Bluetooth permissions in Android 12 --> | ||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/> | ||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" /> | ||
|
||
<!-- legacy for Android 11 or lower --> | ||
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> | ||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" /> | ||
|
||
<!-- legacy for Android 9 or lower --> | ||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" /> | ||
|
||
<application | ||
android:label="zenith_monitor" | ||
android:icon="@mipmap/ic_launcher"> | ||
|
||
<meta-data android:name="com.google.android.geo.API_KEY" | ||
android:value="${MAPS_API_KEY}"/> | ||
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> | ||
|
||
<activity android:name="com.facebook.FacebookActivity" | ||
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" | ||
android:label="@string/app_name" /> | ||
<activity android:name="com.facebook.CustomTabActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
<data android:scheme="@string/fb_login_protocol_scheme" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity | ||
android:name="com.yalantis.ucrop.UCropActivity" | ||
android:screenOrientation="portrait" | ||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/> | ||
<activity | ||
android:name=".MainActivity" | ||
android:launchMode="singleTop" | ||
android:exported="true" | ||
android:theme="@style/LaunchTheme" | ||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" | ||
android:hardwareAccelerated="true" | ||
android:windowSoftInputMode="adjustResize"> | ||
<!-- Specifies an Android theme to apply to this Activity as soon as | ||
the Android process has started. This theme is visible to the user | ||
while the Flutter UI initializes. After that, this theme continues | ||
to determine the Window background behind the Flutter UI. --> | ||
<meta-data | ||
android:name="io.flutter.embedding.android.NormalTheme" | ||
android:resource="@style/NormalTheme" | ||
/> | ||
<!-- Displays an Android View that continues showing the launch screen | ||
Drawable until Flutter paints its first frame, then this splash | ||
screen fades out. A splash screen is useful to avoid any visual | ||
gap between the end of Android's launch screen and the painting of | ||
Flutter's first frame. --> | ||
<meta-data | ||
android:name="io.flutter.embedding.android.SplashScreenDrawable" | ||
android:resource="@drawable/launch_background" | ||
/> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> | ||
</intent-filter> | ||
|
||
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" | ||
android:resource="@xml/device_filter" /> | ||
</activity> | ||
|
||
<!-- Don't delete the meta-data below. | ||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> | ||
<meta-data | ||
android:name="flutterEmbedding" | ||
android:value="2" /> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import './BackgroundCollectingTask.dart'; | ||
import './helpers/LineChart.dart'; | ||
import './helpers/PaintStyle.dart'; | ||
|
||
class BackgroundCollectedPage extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
final BackgroundCollectingTask task = | ||
BackgroundCollectingTask.of(context, rebuildOnChange: true); | ||
|
||
// Arguments shift is needed for timestamps as miliseconds in double could loose precision. | ||
final int argumentsShift = | ||
task.samples.first.timestamp.millisecondsSinceEpoch; | ||
|
||
final Duration showDuration = | ||
Duration(hours: 2); // @TODO . show duration should be configurable | ||
final Iterable<DataSample> lastSamples = task.getLastOf(showDuration); | ||
|
||
final Iterable<double> arguments = lastSamples.map((sample) { | ||
return (sample.timestamp.millisecondsSinceEpoch - argumentsShift) | ||
.toDouble(); | ||
}); | ||
|
||
// Step for argument labels | ||
final Duration argumentsStep = | ||
Duration(minutes: 15); // @TODO . step duration should be configurable | ||
|
||
// Find first timestamp floored to step before | ||
final DateTime beginningArguments = lastSamples.first.timestamp; | ||
DateTime beginningArgumentsStep = DateTime(beginningArguments.year, | ||
beginningArguments.month, beginningArguments.day); | ||
while (beginningArgumentsStep.isBefore(beginningArguments)) { | ||
beginningArgumentsStep = beginningArgumentsStep.add(argumentsStep); | ||
} | ||
beginningArgumentsStep = beginningArgumentsStep.subtract(argumentsStep); | ||
final DateTime endingArguments = lastSamples.last.timestamp; | ||
|
||
// Generate list of timestamps of labels | ||
final Iterable<DateTime> argumentsLabelsTimestamps = () sync* { | ||
DateTime timestamp = beginningArgumentsStep; | ||
yield timestamp; | ||
while (timestamp.isBefore(endingArguments)) { | ||
timestamp = timestamp.add(argumentsStep); | ||
yield timestamp; | ||
} | ||
}(); | ||
|
||
// Map strings for labels | ||
final Iterable<LabelEntry> argumentsLabels = | ||
argumentsLabelsTimestamps.map((timestamp) { | ||
return LabelEntry( | ||
(timestamp.millisecondsSinceEpoch - argumentsShift).toDouble(), | ||
((timestamp.hour <= 9 ? '0' : '') + | ||
timestamp.hour.toString() + | ||
':' + | ||
(timestamp.minute <= 9 ? '0' : '') + | ||
timestamp.minute.toString())); | ||
}); | ||
|
||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text('Collected data'), | ||
actions: <Widget>[ | ||
// Progress circle | ||
(task.inProgress | ||
? FittedBox( | ||
child: Container( | ||
margin: new EdgeInsets.all(16.0), | ||
child: CircularProgressIndicator( | ||
valueColor: | ||
AlwaysStoppedAnimation<Color>(Colors.white)))) | ||
: Container(/* Dummy */)), | ||
// Start/stop buttons | ||
(task.inProgress | ||
? IconButton(icon: Icon(Icons.pause), onPressed: task.pause) | ||
: IconButton( | ||
icon: Icon(Icons.play_arrow), onPressed: task.reasume)), | ||
], | ||
), | ||
body: ListView( | ||
children: <Widget>[ | ||
Divider(), | ||
ListTile( | ||
leading: const Icon(Icons.brightness_7), | ||
title: const Text('Temperatures'), | ||
subtitle: const Text('In Celsius'), | ||
), | ||
LineChart( | ||
constraints: const BoxConstraints.expand(height: 350), | ||
arguments: arguments, | ||
argumentsLabels: argumentsLabels, | ||
values: [ | ||
lastSamples.map((sample) => sample.temperature1), | ||
lastSamples.map((sample) => sample.temperature2), | ||
], | ||
verticalLinesStyle: const PaintStyle(color: Colors.grey), | ||
additionalMinimalHorizontalLabelsInterval: 0, | ||
additionalMinimalVerticalLablesInterval: 0, | ||
seriesPointsStyles: [ | ||
null, | ||
null, | ||
//const PaintStyle(style: PaintingStyle.stroke, strokeWidth: 1.7*3, color: Colors.indigo, strokeCap: StrokeCap.round), | ||
], | ||
seriesLinesStyles: [ | ||
const PaintStyle( | ||
style: PaintingStyle.stroke, | ||
strokeWidth: 1.7, | ||
color: Colors.indigoAccent), | ||
const PaintStyle( | ||
style: PaintingStyle.stroke, | ||
strokeWidth: 1.7, | ||
color: Colors.redAccent), | ||
], | ||
), | ||
Divider(), | ||
ListTile( | ||
leading: const Icon(Icons.filter_vintage), | ||
title: const Text('Water pH level'), | ||
), | ||
LineChart( | ||
constraints: const BoxConstraints.expand(height: 200), | ||
arguments: arguments, | ||
argumentsLabels: argumentsLabels, | ||
values: [ | ||
lastSamples.map((sample) => sample.waterpHlevel), | ||
], | ||
verticalLinesStyle: const PaintStyle(color: Colors.grey), | ||
additionalMinimalHorizontalLabelsInterval: 0, | ||
additionalMinimalVerticalLablesInterval: 0, | ||
seriesPointsStyles: [ | ||
null, | ||
], | ||
seriesLinesStyles: [ | ||
const PaintStyle( | ||
style: PaintingStyle.stroke, | ||
strokeWidth: 1.7, | ||
color: Colors.greenAccent), | ||
], | ||
), | ||
], | ||
)); | ||
} | ||
} |
Oops, something went wrong.