Adds code for the callback for floating app window, and fixes Trip End time not being initialized.

This commit is contained in:
zontreck 2025-05-24 18:46:12 -07:00
parent 35863780f6
commit aedde74e77
5 changed files with 30 additions and 2 deletions

View file

@ -13,6 +13,8 @@
<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_SPECIAL_USE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:label="Time Tracker"

View file

@ -9,7 +9,7 @@ class TTConsts {
static get SESSION_SERVER =>
"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 UpdateChannel UPDATE_CHANNEL = UpdateChannel.beta;

View file

@ -4,6 +4,7 @@ import 'dart:math' as math;
import 'dart:ui';
import 'package:dio/dio.dart';
import 'package:floating_window_android/floating_window_android.dart';
import 'package:flutter/material.dart';
import 'package:flutter_background/flutter_background.dart';
import 'package:geolocator/geolocator.dart';
@ -164,6 +165,13 @@ class SessionData {
return false;
}
bool granted = await FloatingWindowAndroid.isPermissionGranted();
if (!granted) {
success = await FloatingWindowAndroid.requestPermission();
if (!success) return false;
}
StartTime = DateTime.now();
IsOnTheClock = true;
@ -319,6 +327,9 @@ class SessionData {
}
static Trip GetNewTrip() {
if (currentTrip != null) {
currentTrip!.EndTime = DateTime.now();
}
currentTrip = Trip();
Trips.add(currentTrip!);
return currentTrip!;
@ -335,6 +346,9 @@ class SessionData {
}
static void EndTrip() {
if (currentTrip != null) {
currentTrip!.EndTime = DateTime.now();
}
currentDelivery = null;
currentTrip = null;
}

View file

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
@ -6,6 +7,16 @@ import 'package:timetrack/consts.dart';
import 'package:timetrack/data.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 {
WidgetsFlutterBinding.ensureInitialized();

View file

@ -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
# 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.
version: 1.0.0-beta.13
version: 1.0.0-beta.14
environment:
sdk: ^3.7.2
@ -48,6 +48,7 @@ dependencies:
flutter_map_tile_caching: ^10.1.1
url_launcher: ^6.3.1
flutter_background: ^1.3.0+1
floating_window_android: ^1.0.0
dev_dependencies:
flutter_test: