From 918d1cec708a2c926dbd47cac156ef8d1554ede1 Mon Sep 17 00:00:00 2001 From: vividos Date: Mon, 13 Feb 2023 19:22:29 +0100 Subject: [PATCH] [Essentials] Geolocation foreground listening (#9572) * added geolocation foreground listening public API without implementation * added section on geolocation sample page for foreground listening feature * implemented geolocation foreground listening for Android, iOS, MacOS and UWP * moved common code for determining DesiredAccuracy on UWP to extension method * renamed class ListeningRequest to GeolocationListeningRequest * renamed property IsListening to IsListeningForeground * added xml documentation for all new public methods and properties * implemented event LocationError, using enum GeolocationError and class GeolocationErrorEventArgs * fixed potential leak where ContinuousLocationListener keeps the reference to the GeolocationImplementation on iOS * changed StopListeningForegroundAsync() to StopListeningForeground() and return void * fixed error in Essentials samples where async keyword is not necessary anymore * enabled nullable checks for GeolocationListeningRequest class * renamed ListeningRequest.ios.macos.cs to match class name; no source code changes * call StopListeningForeground() on Android, iOS and macOS before signalling LocationError event, to make behavior consistent with Windows * replaced throwing ArgumentNullException with ArgumentNullException.ThrowIfNull() * added xml documentation for all newly added public geolocaion foreground listening APIs * removed duplicated code for determining GeolocationAccuracy on iOS and macOS * renamed event LocationError to ListeningFailed and GeolocationErrorEventArgs to GeolocationListeningFailedEventArgs * fixed IsListeningForeground property on Windows * Fixed naming --------- Co-authored-by: Gerald Versluis --- .../samples/Samples/View/GeolocationPage.xaml | 10 ++ .../Samples/ViewModel/GeolocationViewModel.cs | 74 ++++++++ .../src/Geolocation/Geolocation.android.cs | 169 +++++++++++++++++- .../src/Geolocation/Geolocation.ios.macos.cs | 136 +++++++++++++- .../Geolocation.netstandard.tvos.watchos.cs | 9 + .../src/Geolocation/Geolocation.shared.cs | 100 +++++++++++ .../src/Geolocation/Geolocation.tizen.cs | 10 +- .../src/Geolocation/Geolocation.uwp.cs | 105 ++++++++++- ...ationAccuracyExtensionMethods.ios.macos.cs | 28 +++ ...GeolocationAccuracyExtensionMethods.uwp.cs | 25 +++ .../Geolocation/GeolocationError.shared.cs | 30 ++++ ...locationListeningFailedEventArgs.shared.cs | 25 +++ .../GeolocationListeningRequest.ios.macos.cs | 15 ++ .../GeolocationListeningRequest.shared.cs | 51 ++++++ .../GeolocationListeningRequest.uwp.cs | 15 ++ ...locationLocationChangedEventArgs.shared.cs | 18 ++ .../GeolocationRequest.ios.macos.cs | 22 +-- .../src/Geolocation/GeolocationRequest.uwp.cs | 21 +-- .../net-android/PublicAPI.Unshipped.txt | 29 ++- .../PublicAPI/net-ios/PublicAPI.Unshipped.txt | 29 ++- .../net-maccatalyst/PublicAPI.Unshipped.txt | 29 ++- .../net-tizen/PublicAPI.Unshipped.txt | 29 ++- .../net-windows/PublicAPI.Unshipped.txt | 29 ++- .../src/PublicAPI/net/PublicAPI.Unshipped.txt | 27 +++ .../netstandard/PublicAPI.Unshipped.txt | 29 ++- 25 files changed, 1007 insertions(+), 57 deletions(-) create mode 100644 src/Essentials/src/Geolocation/GeolocationAccuracyExtensionMethods.ios.macos.cs create mode 100644 src/Essentials/src/Geolocation/GeolocationAccuracyExtensionMethods.uwp.cs create mode 100644 src/Essentials/src/Geolocation/GeolocationError.shared.cs create mode 100644 src/Essentials/src/Geolocation/GeolocationListeningFailedEventArgs.shared.cs create mode 100644 src/Essentials/src/Geolocation/GeolocationListeningRequest.ios.macos.cs create mode 100644 src/Essentials/src/Geolocation/GeolocationListeningRequest.shared.cs create mode 100644 src/Essentials/src/Geolocation/GeolocationListeningRequest.uwp.cs create mode 100644 src/Essentials/src/Geolocation/GeolocationLocationChangedEventArgs.shared.cs diff --git a/src/Essentials/samples/Samples/View/GeolocationPage.xaml b/src/Essentials/samples/Samples/View/GeolocationPage.xaml index c10eeb38c638..67475e119435 100644 --- a/src/Essentials/samples/Samples/View/GeolocationPage.xaml +++ b/src/Essentials/samples/Samples/View/GeolocationPage.xaml @@ -27,6 +27,16 @@ IsEnabled="{Binding IsNotBusy}" HorizontalOptions="FillAndExpand" />