From dd4e3a2e2025aea3964b6d465a192d326f71bff7 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Thu, 2 May 2024 12:52:04 +0300 Subject: [PATCH] 5/2/pass3 --- android/app/src/main/AndroidManifest.xml | 42 ++++--- .../location_background_controller.dart | 116 +++++++++--------- lib/main.dart | 16 +-- 3 files changed, 91 insertions(+), 83 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 876e845..89ece84 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,16 +1,17 @@ - + - + - - - - + + + + @@ -32,27 +33,34 @@ - - + + - + - - + + - + - - + + - - + + - + \ No newline at end of file diff --git a/lib/controller/functions/location_background_controller.dart b/lib/controller/functions/location_background_controller.dart index f00ca97..b04928e 100644 --- a/lib/controller/functions/location_background_controller.dart +++ b/lib/controller/functions/location_background_controller.dart @@ -1,67 +1,67 @@ -import 'dart:async'; -import 'package:background_location/background_location.dart'; -import 'package:get/get.dart'; -import 'package:permission_handler/permission_handler.dart'; +// import 'dart:async'; +// import 'package:background_location/background_location.dart'; +// import 'package:get/get.dart'; +// import 'package:permission_handler/permission_handler.dart'; -class LocationBackgroundController extends GetxController { - @override - void onInit() { - super.onInit(); - requestLocationPermission(); - configureBackgroundLocation(); - } +// class LocationBackgroundController extends GetxController { +// @override +// void onInit() { +// super.onInit(); +// requestLocationPermission(); +// configureBackgroundLocation(); +// } - Future requestLocationPermission() async { - var status = await Permission.locationAlways.status; - if (!status.isGranted) { - await Permission.locationAlways.request(); - } - } +// Future requestLocationPermission() async { +// var status = await Permission.locationAlways.status; +// if (!status.isGranted) { +// await Permission.locationAlways.request(); +// } +// } - Future configureBackgroundLocation() async { - await BackgroundLocation.setAndroidNotification( - title: "Background Location", - message: "Tracking location...", - icon: "@mipmap/ic_launcher", - ); +// Future configureBackgroundLocation() async { +// await BackgroundLocation.setAndroidNotification( +// title: "Background Location", +// message: "Tracking location...", +// icon: "@mipmap/ic_launcher", +// ); - BackgroundLocation.setAndroidConfiguration(1000); - BackgroundLocation.startLocationService(); - BackgroundLocation.getLocationUpdates((location) { - // Handle location updates here - print("New location: ${location.latitude}, ${location.longitude}"); - }); - } +// BackgroundLocation.setAndroidConfiguration(1000); +// BackgroundLocation.startLocationService(); +// BackgroundLocation.getLocationUpdates((location) { +// // Handle location updates here +// print("New location: ${location.latitude}, ${location.longitude}"); +// }); +// } - startBackLocation() async { - Timer.periodic(const Duration(seconds: 5), (timer) { - getBackgroundLocation(); - }); - } +// startBackLocation() async { +// Timer.periodic(const Duration(seconds: 5), (timer) { +// getBackgroundLocation(); +// }); +// } - getBackgroundLocation() async { - var status = await Permission.locationAlways.status; - if (status.isGranted) { - await BackgroundLocation.startLocationService( - distanceFilter: 20, forceAndroidLocationManager: true); - BackgroundLocation.setAndroidConfiguration( - Duration.microsecondsPerSecond); // Set interval to 5 seconds +// getBackgroundLocation() async { +// var status = await Permission.locationAlways.status; +// if (status.isGranted) { +// await BackgroundLocation.startLocationService( +// distanceFilter: 20, forceAndroidLocationManager: true); +// BackgroundLocation.setAndroidConfiguration( +// Duration.microsecondsPerSecond); // Set interval to 5 seconds - BackgroundLocation.getLocationUpdates((location1) { - print('''\n - Latitude: ${location1.latitude.toString()} - Longitude: ${location1.longitude.toString()} - Altitude: ${location1.altitude.toString()} - Accuracy: ${location1.accuracy.toString()} - Bearing: ${location1.bearing.toString()} - Speed: ${location1.speed.toString()} +// BackgroundLocation.getLocationUpdates((location1) { +// print('''\n +// Latitude: ${location1.latitude.toString()} +// Longitude: ${location1.longitude.toString()} +// Altitude: ${location1.altitude.toString()} +// Accuracy: ${location1.accuracy.toString()} +// Bearing: ${location1.bearing.toString()} +// Speed: ${location1.speed.toString()} - '''); - }); - } else { - await Permission.locationAlways.request(); - print('Location permission not granted'); - } - } -} +// '''); +// }); +// } else { +// await Permission.locationAlways.request(); +// print('Location permission not granted'); +// } +// } +// } diff --git a/lib/main.dart b/lib/main.dart index 3134ddc..d106ba1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -58,14 +58,14 @@ void main() async { print(Get.deviceLocale!.countryCode); Stripe.publishableKey = AK.publishableKey; if (box.read(BoxName.driverID) != null) { - Get.defaultDialog( - title: 'Gps required', - middleText: '', - confirm: MyElevatedButton( - title: 'ok'.tr, - onPressed: () { - Get.put(LocationBackgroundController()); - })); + // Get.defaultDialog( + // title: 'Gps required', + // middleText: '', + // confirm: MyElevatedButton( + // title: 'ok'.tr, + // onPressed: () { + // Get.put(LocationBackgroundController()); + // })); } if (Platform.isAndroid || Platform.isIOS) { await Firebase.initializeApp(