Adds code for the callback for floating app window, and fixes Trip End time not being initialized.
This commit is contained in:
parent
35863780f6
commit
aedde74e77
5 changed files with 30 additions and 2 deletions
|
@ -13,6 +13,8 @@
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="Time Tracker"
|
android:label="Time Tracker"
|
||||||
|
|
|
@ -9,7 +9,7 @@ class TTConsts {
|
||||||
static get SESSION_SERVER =>
|
static get SESSION_SERVER =>
|
||||||
"https://api.zontreck.com/timetrack/$UPDATE_CHANNEL/timetrack.php";
|
"https://api.zontreck.com/timetrack/$UPDATE_CHANNEL/timetrack.php";
|
||||||
|
|
||||||
static const VERSION = "1.0.0-beta.13";
|
static const VERSION = "1.0.0-beta.14";
|
||||||
|
|
||||||
static bool UPDATE_AVAILABLE = false;
|
static bool UPDATE_AVAILABLE = false;
|
||||||
static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta;
|
static UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'dart:math' as math;
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:floating_window_android/floating_window_android.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_background/flutter_background.dart';
|
import 'package:flutter_background/flutter_background.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
@ -164,6 +165,13 @@ class SessionData {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool granted = await FloatingWindowAndroid.isPermissionGranted();
|
||||||
|
if (!granted) {
|
||||||
|
success = await FloatingWindowAndroid.requestPermission();
|
||||||
|
|
||||||
|
if (!success) return false;
|
||||||
|
}
|
||||||
|
|
||||||
StartTime = DateTime.now();
|
StartTime = DateTime.now();
|
||||||
IsOnTheClock = true;
|
IsOnTheClock = true;
|
||||||
|
|
||||||
|
@ -319,6 +327,9 @@ class SessionData {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Trip GetNewTrip() {
|
static Trip GetNewTrip() {
|
||||||
|
if (currentTrip != null) {
|
||||||
|
currentTrip!.EndTime = DateTime.now();
|
||||||
|
}
|
||||||
currentTrip = Trip();
|
currentTrip = Trip();
|
||||||
Trips.add(currentTrip!);
|
Trips.add(currentTrip!);
|
||||||
return currentTrip!;
|
return currentTrip!;
|
||||||
|
@ -335,6 +346,9 @@ class SessionData {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EndTrip() {
|
static void EndTrip() {
|
||||||
|
if (currentTrip != null) {
|
||||||
|
currentTrip!.EndTime = DateTime.now();
|
||||||
|
}
|
||||||
currentDelivery = null;
|
currentDelivery = null;
|
||||||
currentTrip = null;
|
currentTrip = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -6,6 +7,16 @@ import 'package:timetrack/consts.dart';
|
||||||
import 'package:timetrack/data.dart';
|
import 'package:timetrack/data.dart';
|
||||||
import 'package:timetrack/pages/MainApp.dart';
|
import 'package:timetrack/pages/MainApp.dart';
|
||||||
|
|
||||||
|
@pragma("vm:entry-point")
|
||||||
|
void serviceEntry() {
|
||||||
|
// This is where both the Background service and the Floating app window would enter the app.
|
||||||
|
Timer.periodic(Duration(seconds: 5), (timer) async {
|
||||||
|
// Run the location fetch, add to list, etc, etc.
|
||||||
|
});
|
||||||
|
|
||||||
|
// Run the floater app here.
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.0.0-beta.13
|
version: 1.0.0-beta.14
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.7.2
|
sdk: ^3.7.2
|
||||||
|
@ -48,6 +48,7 @@ dependencies:
|
||||||
flutter_map_tile_caching: ^10.1.1
|
flutter_map_tile_caching: ^10.1.1
|
||||||
url_launcher: ^6.3.1
|
url_launcher: ^6.3.1
|
||||||
flutter_background: ^1.3.0+1
|
flutter_background: ^1.3.0+1
|
||||||
|
floating_window_android: ^1.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue