From 63e5c219bb8cdb2c3b96bb1a3922d909d391c5d9 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Sun, 21 Aug 2022 20:00:44 +0200 Subject: [PATCH 01/22] added geolocation foreground listening public API without implementation --- .../src/Geolocation/Geolocation.android.cs | 8 +++++ .../src/Geolocation/Geolocation.ios.macos.cs | 9 +++++ .../Geolocation.netstandard.tvos.watchos.cs | 9 +++++ .../src/Geolocation/Geolocation.shared.cs | 34 +++++++++++++++++++ .../src/Geolocation/Geolocation.tizen.cs | 8 +++++ .../src/Geolocation/Geolocation.uwp.cs | 9 +++++ .../Geolocation/ListeningRequest.shared.cs | 27 +++++++++++++++ .../Geolocation/LocationEventArgs.shared.cs | 18 ++++++++++ .../net-android/PublicAPI.Unshipped.txt | 19 +++++++++++ .../PublicAPI/net-ios/PublicAPI.Unshipped.txt | 19 +++++++++++ .../net-maccatalyst/PublicAPI.Unshipped.txt | 19 +++++++++++ .../net-tizen/PublicAPI.Unshipped.txt | 19 +++++++++++ .../net-windows/PublicAPI.Unshipped.txt | 19 +++++++++++ .../src/PublicAPI/net/PublicAPI.Unshipped.txt | 19 +++++++++++ .../netstandard/PublicAPI.Unshipped.txt | 19 +++++++++++ 15 files changed, 255 insertions(+) create mode 100644 src/Essentials/src/Geolocation/ListeningRequest.shared.cs create mode 100644 src/Essentials/src/Geolocation/LocationEventArgs.shared.cs diff --git a/src/Essentials/src/Geolocation/Geolocation.android.cs b/src/Essentials/src/Geolocation/Geolocation.android.cs index f2f8454efd21..46b3d0067629 100644 --- a/src/Essentials/src/Geolocation/Geolocation.android.cs +++ b/src/Essentials/src/Geolocation/Geolocation.android.cs @@ -23,6 +23,8 @@ partial class GeolocationImplementation : IGeolocation static LocationManager LocationManager => locationManager ??= Application.Context.GetSystemService(Context.LocationService) as LocationManager; + public bool IsListening { get => false; } + public async Task GetLastKnownLocationAsync() { await Permissions.EnsureGrantedOrRestrictedAsync(); @@ -112,6 +114,12 @@ void RemoveUpdates() } } + public Task StartListeningForegroundAsync(ListeningRequest request) => + throw ExceptionUtils.NotSupportedOrImplementedException; + + public Task StopListeningForegroundAsync() => + throw ExceptionUtils.NotSupportedOrImplementedException; + static (string Provider, float Accuracy) GetBestProvider(LocationManager locationManager, GeolocationAccuracy accuracy) { // Criteria: https://developer.android.com/reference/android/location/Criteria diff --git a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs index 3a7ea40794bd..41b9ad7a3c8e 100644 --- a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs +++ b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs @@ -9,6 +9,9 @@ namespace Microsoft.Maui.Devices.Sensors { partial class GeolocationImplementation : IGeolocation { + public bool IsListening { get => false; } + + public async Task GetLastKnownLocationAsync() { if (!CLLocationManager.LocationServicesEnabled) @@ -91,6 +94,12 @@ void Cancel() tcs.TrySetResult(null); } } + + public Task StartListeningForegroundAsync(ListeningRequest request) => + throw ExceptionUtils.NotSupportedOrImplementedException; + + public Task StopListeningForegroundAsync() => + throw ExceptionUtils.NotSupportedOrImplementedException; } class SingleLocationListener : CLLocationManagerDelegate diff --git a/src/Essentials/src/Geolocation/Geolocation.netstandard.tvos.watchos.cs b/src/Essentials/src/Geolocation/Geolocation.netstandard.tvos.watchos.cs index 67c10b2ec813..31e7eac62eb6 100644 --- a/src/Essentials/src/Geolocation/Geolocation.netstandard.tvos.watchos.cs +++ b/src/Essentials/src/Geolocation/Geolocation.netstandard.tvos.watchos.cs @@ -1,3 +1,4 @@ +using System; using System.Threading; using System.Threading.Tasks; using Microsoft.Maui.ApplicationModel; @@ -11,5 +12,13 @@ public Task GetLastKnownLocationAsync() => public Task GetLocationAsync(GeolocationRequest request, CancellationToken cancellationToken) => throw ExceptionUtils.NotSupportedOrImplementedException; + + public bool IsListening { get => false; } + + public Task StartListeningForegroundAsync(ListeningRequest request) => + throw ExceptionUtils.NotSupportedOrImplementedException; + + public Task StopListeningForegroundAsync() => + throw ExceptionUtils.NotSupportedOrImplementedException; } } diff --git a/src/Essentials/src/Geolocation/Geolocation.shared.cs b/src/Essentials/src/Geolocation/Geolocation.shared.cs index 753d13ed5fc0..b5bec6e8183b 100644 --- a/src/Essentials/src/Geolocation/Geolocation.shared.cs +++ b/src/Essentials/src/Geolocation/Geolocation.shared.cs @@ -1,4 +1,5 @@ #nullable enable +using System; using System.Threading; using System.Threading.Tasks; @@ -27,6 +28,14 @@ public interface IGeolocation /// The location permissions will be requested at runtime if needed. You might still need to declare something in your app manifest. /// A object containing current location information or if no location could be determined. Task GetLocationAsync(GeolocationRequest request, CancellationToken cancelToken); + + bool IsListening { get; } + + event EventHandler? LocationChanged; + + Task StartListeningForegroundAsync(ListeningRequest request); + + Task StopListeningForegroundAsync(); } /// @@ -72,6 +81,20 @@ public static partial class Geolocation public static Task GetLocationAsync(GeolocationRequest request, CancellationToken cancelToken) => Current.GetLocationAsync(request, cancelToken); + public static bool IsListening { get => Current.IsListening; } + + public static event EventHandler LocationChanged + { + add => Current.LocationChanged += value; + remove => Current.LocationChanged -= value; + } + + public static Task StartListeningForegroundAsync(ListeningRequest request) => + Current.StartListeningForegroundAsync(request); + + public static Task StopListeningForegroundAsync() => + Current.StopListeningForegroundAsync(); + static IGeolocation Current => Devices.Sensors.Geolocation.Default; static IGeolocation? defaultImplementation; @@ -86,6 +109,17 @@ internal static void SetDefault(IGeolocation? implementation) => defaultImplementation = implementation; } + partial class GeolocationImplementation : IGeolocation + { + public event EventHandler? LocationChanged; + + internal void OnLocationChanged(Location location) => + OnLocationChanged(new LocationEventArgs(location)); + + internal void OnLocationChanged(LocationEventArgs e) => + LocationChanged?.Invoke(null, e); + } + /// /// Static class with extension methods for the APIs. /// diff --git a/src/Essentials/src/Geolocation/Geolocation.tizen.cs b/src/Essentials/src/Geolocation/Geolocation.tizen.cs index 70f601cedbcb..c69945b0b246 100644 --- a/src/Essentials/src/Geolocation/Geolocation.tizen.cs +++ b/src/Essentials/src/Geolocation/Geolocation.tizen.cs @@ -10,6 +10,8 @@ partial class GeolocationImplementation : IGeolocation { Location lastKnownLocation = new Location(); + public bool IsListening { get => false; } + public Task GetLastKnownLocationAsync() => Task.FromResult(lastKnownLocation); public async Task GetLocationAsync(GeolocationRequest request, CancellationToken cancellationToken) @@ -67,5 +69,11 @@ public async Task GetLocationAsync(GeolocationRequest request, Cancell return lastKnownLocation; } + + public Task StartListeningForegroundAsync(ListeningRequest request) => + throw ExceptionUtils.NotSupportedOrImplementedException; + + public Task StopListeningForegroundAsync() => + throw ExceptionUtils.NotSupportedOrImplementedException; } } diff --git a/src/Essentials/src/Geolocation/Geolocation.uwp.cs b/src/Essentials/src/Geolocation/Geolocation.uwp.cs index ce9778380055..3244cdb60d5a 100644 --- a/src/Essentials/src/Geolocation/Geolocation.uwp.cs +++ b/src/Essentials/src/Geolocation/Geolocation.uwp.cs @@ -9,6 +9,9 @@ namespace Microsoft.Maui.Devices.Sensors { partial class GeolocationImplementation : IGeolocation { + public bool IsListening { get => false; } + + public async Task GetLastKnownLocationAsync() { // no need for permissions as AllowFallbackToConsentlessPositions @@ -54,5 +57,11 @@ static void CheckStatus(PositionStatus status) } } } + + public Task StartListeningForegroundAsync(ListeningRequest request) => + throw ExceptionUtils.NotSupportedOrImplementedException; + + public Task StopListeningForegroundAsync() => + throw ExceptionUtils.NotSupportedOrImplementedException; } } diff --git a/src/Essentials/src/Geolocation/ListeningRequest.shared.cs b/src/Essentials/src/Geolocation/ListeningRequest.shared.cs new file mode 100644 index 000000000000..5dc916d89cf3 --- /dev/null +++ b/src/Essentials/src/Geolocation/ListeningRequest.shared.cs @@ -0,0 +1,27 @@ +using System; + +namespace Microsoft.Maui.Devices.Sensors +{ + public class ListeningRequest + { + public ListeningRequest() + : this(GeolocationAccuracy.Default) + { + } + + public ListeningRequest(GeolocationAccuracy accuracy) + :this(accuracy, TimeSpan.FromSeconds(1)) + { + } + + public ListeningRequest(GeolocationAccuracy accuracy, TimeSpan minimumTime) + { + DesiredAccuracy = accuracy; + MinimumTime = minimumTime; + } + + public TimeSpan MinimumTime { get; set; } = TimeSpan.FromSeconds(1); + + public GeolocationAccuracy DesiredAccuracy { get; set; } = GeolocationAccuracy.Default; + } +} diff --git a/src/Essentials/src/Geolocation/LocationEventArgs.shared.cs b/src/Essentials/src/Geolocation/LocationEventArgs.shared.cs new file mode 100644 index 000000000000..b5349267a348 --- /dev/null +++ b/src/Essentials/src/Geolocation/LocationEventArgs.shared.cs @@ -0,0 +1,18 @@ +#nullable enable +using System; + +namespace Microsoft.Maui.Devices.Sensors +{ + public class LocationEventArgs : EventArgs + { + public Location Location { get; } + + public LocationEventArgs(Location location) + { + if (location == null) + throw new ArgumentNullException(nameof(location)); + + Location = location; + } + } +} \ No newline at end of file diff --git a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 1e2c3171b21e..d82c75cda19a 100644 --- a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -3,3 +3,22 @@ *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.IsListening.get -> bool +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.ListeningRequest +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.set -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest() -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.get -> System.TimeSpan +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.set -> void +Microsoft.Maui.Devices.Sensors.LocationEventArgs +Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +static Microsoft.Maui.Devices.Sensors.Geolocation.IsListening.get -> bool +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! diff --git a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 1e2c3171b21e..d82c75cda19a 100644 --- a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -3,3 +3,22 @@ *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.IsListening.get -> bool +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.ListeningRequest +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.set -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest() -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.get -> System.TimeSpan +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.set -> void +Microsoft.Maui.Devices.Sensors.LocationEventArgs +Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +static Microsoft.Maui.Devices.Sensors.Geolocation.IsListening.get -> bool +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! diff --git a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 1e2c3171b21e..d82c75cda19a 100644 --- a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -3,3 +3,22 @@ *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.IsListening.get -> bool +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.ListeningRequest +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.set -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest() -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.get -> System.TimeSpan +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.set -> void +Microsoft.Maui.Devices.Sensors.LocationEventArgs +Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +static Microsoft.Maui.Devices.Sensors.Geolocation.IsListening.get -> bool +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! diff --git a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 1e2c3171b21e..d82c75cda19a 100644 --- a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -3,3 +3,22 @@ *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.IsListening.get -> bool +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.ListeningRequest +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.set -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest() -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.get -> System.TimeSpan +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.set -> void +Microsoft.Maui.Devices.Sensors.LocationEventArgs +Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +static Microsoft.Maui.Devices.Sensors.Geolocation.IsListening.get -> bool +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! diff --git a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 1e2c3171b21e..f992fb1d1395 100644 --- a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -3,3 +3,22 @@ *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.IsListening.get -> bool +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.ListeningRequest +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.set -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest() -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.get -> System.TimeSpan +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.set -> void +Microsoft.Maui.Devices.Sensors.LocationEventArgs +Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +static Microsoft.Maui.Devices.Sensors.Geolocation.IsListening.get -> bool +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! \ No newline at end of file diff --git a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt index 1e2c3171b21e..d82c75cda19a 100644 --- a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -3,3 +3,22 @@ *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.IsListening.get -> bool +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.ListeningRequest +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.set -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest() -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.get -> System.TimeSpan +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.set -> void +Microsoft.Maui.Devices.Sensors.LocationEventArgs +Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +static Microsoft.Maui.Devices.Sensors.Geolocation.IsListening.get -> bool +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! diff --git a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index 1e2c3171b21e..d82c75cda19a 100644 --- a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -3,3 +3,22 @@ *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.IsListening.get -> bool +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.ListeningRequest +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy +Microsoft.Maui.Devices.Sensors.ListeningRequest.DesiredAccuracy.set -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest() -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.ListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.get -> System.TimeSpan +Microsoft.Maui.Devices.Sensors.ListeningRequest.MinimumTime.set -> void +Microsoft.Maui.Devices.Sensors.LocationEventArgs +Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +static Microsoft.Maui.Devices.Sensors.Geolocation.IsListening.get -> bool +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.ListeningRequest! request) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! From 6b94c1c5271dd2e7800cd648458820f4f5648661 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Mon, 22 Aug 2022 08:23:04 +0200 Subject: [PATCH 02/22] added section on geolocation sample page for foreground listening feature --- .../samples/Samples/View/GeolocationPage.xaml | 10 +++ .../Samples/ViewModel/GeolocationViewModel.cs | 76 +++++++++++++++++++ 2 files changed, 86 insertions(+) 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" /> event EventHandler? LocationChanged; + /// + /// Occurs when an error during listening for location updates arises. When getting the event, + /// listening for further updates may have been stopped. + /// + event EventHandler? LocationError; + /// /// Starts listening to location updates using the event. Events /// may only sent when the app is in the foreground. Requests @@ -120,6 +126,15 @@ public static event EventHandler LocationChanged remove => Current.LocationChanged -= value; } + /// + /// Occurs when an error during listening for location updates arises. + /// + public static event EventHandler LocationError + { + add => Current.LocationError += value; + remove => Current.LocationError -= value; + } + /// /// Starts listening to location updates using the event. Events /// may only be sent when the app is in the foreground. Requests @@ -161,11 +176,16 @@ partial class GeolocationImplementation : IGeolocation { public event EventHandler? LocationChanged; + public event EventHandler? LocationError; + internal void OnLocationChanged(Location location) => OnLocationChanged(new LocationEventArgs(location)); internal void OnLocationChanged(LocationEventArgs e) => LocationChanged?.Invoke(null, e); + + internal void OnLocationError(GeolocationError geolocationError) => + LocationError?.Invoke(null, new GeolocationErrorEventArgs(geolocationError)); } /// diff --git a/src/Essentials/src/Geolocation/Geolocation.uwp.cs b/src/Essentials/src/Geolocation/Geolocation.uwp.cs index 0e01f622cb0e..8a71a7529902 100644 --- a/src/Essentials/src/Geolocation/Geolocation.uwp.cs +++ b/src/Essentials/src/Geolocation/Geolocation.uwp.cs @@ -104,10 +104,27 @@ void OnLocatorPositionChanged(Geolocator sender, PositionChangedEventArgs e) => async void OnLocatorStatusChanged(Geolocator sender, StatusChangedEventArgs e) { - if (IsListeningForeground) + if (!IsListeningForeground) + return; + + await StopListeningForegroundAsync(); + + GeolocationError error; + switch (e.Status) { - await StopListeningForegroundAsync(); + case PositionStatus.Disabled: + error = GeolocationError.Unauthorized; + break; + + case PositionStatus.NoData: + error = GeolocationError.PositionUnavailable; + break; + + default: + return; } + + OnLocationError(error); } } } diff --git a/src/Essentials/src/Geolocation/GeolocationError.shared.cs b/src/Essentials/src/Geolocation/GeolocationError.shared.cs new file mode 100644 index 000000000000..5008f4660953 --- /dev/null +++ b/src/Essentials/src/Geolocation/GeolocationError.shared.cs @@ -0,0 +1,30 @@ +#nullable enable + +namespace Microsoft.Maui.Devices.Sensors +{ + /// + /// Error values for listening for geolocation changes + /// + public enum GeolocationError + { + /// + /// The provider was unable to retrieve any position data. + /// + /// + /// Android: Sent when no location provider is available that satisfies the requested geolocation accuracy. + /// iOS: Getting location data has failed. + /// Windows: No location data is available from any source. + /// + PositionUnavailable, + + /// + /// The app is not, or no longer, authorized to receive location data. + /// + /// + /// Android: Not used. + /// iOS: Authorization for getting locations has changed. + /// Windows: Location sources are turned off. + /// + Unauthorized, + } +} \ No newline at end of file diff --git a/src/Essentials/src/Geolocation/GeolocationErrorEventArgs.shared.cs b/src/Essentials/src/Geolocation/GeolocationErrorEventArgs.shared.cs new file mode 100644 index 000000000000..3042538e542e --- /dev/null +++ b/src/Essentials/src/Geolocation/GeolocationErrorEventArgs.shared.cs @@ -0,0 +1,25 @@ +#nullable enable +using System; + +namespace Microsoft.Maui.Devices.Sensors +{ + /// + /// Event args for the geolocation listening error event. + /// + public class GeolocationErrorEventArgs : EventArgs + { + /// + /// The geolocation error that describes the error that occurred. + /// + public GeolocationError Error { get; } + + /// + /// Creates a new geolocation error event args object + /// + /// gelocation error to use for this object + public GeolocationErrorEventArgs(GeolocationError geolocationError) + { + Error = geolocationError; + } + } +} \ No newline at end of file diff --git a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index dc6ac1114bed..aad8e00edc62 100644 --- a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -1,7 +1,15 @@ #nullable enable *REMOVED*Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index dc6ac1114bed..aad8e00edc62 100644 --- a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -1,7 +1,15 @@ #nullable enable *REMOVED*Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index dc6ac1114bed..aad8e00edc62 100644 --- a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -1,7 +1,15 @@ #nullable enable *REMOVED*Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index dc6ac1114bed..aad8e00edc62 100644 --- a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -1,7 +1,15 @@ #nullable enable *REMOVED*Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 58c61e160300..23185f0d5bb3 100644 --- a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -1,7 +1,15 @@ #nullable enable *REMOVED*Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt index dc6ac1114bed..aad8e00edc62 100644 --- a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -1,7 +1,15 @@ #nullable enable *REMOVED*Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index dc6ac1114bed..aad8e00edc62 100644 --- a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -1,7 +1,15 @@ #nullable enable *REMOVED*Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! *REMOVED*static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? From 90ac7d5a94b1496a67d93d071cc82fd7946dbde3 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Sun, 22 Jan 2023 12:16:42 +0100 Subject: [PATCH 09/22] fixed potential leak where ContinuousLocationListener keeps the reference to the GeolocationImplementation on iOS --- src/Essentials/src/Geolocation/Geolocation.ios.macos.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs index 1c721b54c416..8ad88dbdd1e3 100644 --- a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs +++ b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs @@ -156,6 +156,13 @@ public Task StopListeningForegroundAsync() return Task.FromResult(true); listeningManager.StopUpdatingLocation(); + + if (listeningManager.Delegate is ContinuousLocationListener listener) + { + listener.LocationHandler = null; + listener.ErrorHandler = null; + } + listeningManager.Delegate = null; listeningManager = null; From e44a8bc28830703b4a606b5ab29c1330a98c3cb8 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Sun, 22 Jan 2023 12:46:31 +0100 Subject: [PATCH 10/22] changed StopListeningForegroundAsync() to StopListeningForeground() and return void --- .../samples/Samples/ViewModel/GeolocationViewModel.cs | 6 ++---- src/Essentials/src/Geolocation/Geolocation.android.cs | 8 +++----- .../src/Geolocation/Geolocation.ios.macos.cs | 6 ++---- .../Geolocation.netstandard.tvos.watchos.cs | 2 +- src/Essentials/src/Geolocation/Geolocation.shared.cs | 10 +++------- src/Essentials/src/Geolocation/Geolocation.tizen.cs | 2 +- src/Essentials/src/Geolocation/Geolocation.uwp.cs | 10 ++++------ .../src/PublicAPI/net-android/PublicAPI.Unshipped.txt | 4 ++-- .../src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | 4 ++-- .../PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | 4 ++-- .../src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | 4 ++-- .../src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | 4 ++-- .../src/PublicAPI/net/PublicAPI.Unshipped.txt | 4 ++-- .../src/PublicAPI/netstandard/PublicAPI.Unshipped.txt | 4 ++-- 14 files changed, 30 insertions(+), 42 deletions(-) diff --git a/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs b/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs index 44580f7f1949..81da08c06f96 100644 --- a/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs +++ b/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs @@ -146,11 +146,9 @@ async void OnStopListening() { Geolocation.LocationChanged -= Geolocation_LocationChanged; - var success = await Geolocation.StopListeningForegroundAsync(); + Geolocation.StopListeningForeground(); - ListeningLocationStatus = success - ? "Stopped listening for foreground location updates" - : "Couldn't stop listening"; + ListeningLocationStatus = "Stopped listening for foreground location updates"; } catch (Exception ex) { diff --git a/src/Essentials/src/Geolocation/Geolocation.android.cs b/src/Essentials/src/Geolocation/Geolocation.android.cs index e7648d588e02..f30fef3f983c 100644 --- a/src/Essentials/src/Geolocation/Geolocation.android.cs +++ b/src/Essentials/src/Geolocation/Geolocation.android.cs @@ -176,16 +176,16 @@ void HandleError(GeolocationError geolocationError) } } - public Task StopListeningForegroundAsync() + public void StopListeningForeground() { if (continuousListener == null) - return Task.FromResult(true); + return; continuousListener.LocationHandler = null; continuousListener.ErrorHandler = null; if (listeningProviders == null) - return Task.FromResult(true); + return; for (var i = 0; i < listeningProviders.Count; i++) { @@ -193,8 +193,6 @@ public Task StopListeningForegroundAsync() } continuousListener = null; - - return Task.FromResult(true); } static (string Provider, float Accuracy) GetBestProvider(LocationManager locationManager, GeolocationAccuracy accuracy) diff --git a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs index 8ad88dbdd1e3..7855551f4616 100644 --- a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs +++ b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs @@ -150,10 +150,10 @@ void HandleError(GeolocationError error) } } - public Task StopListeningForegroundAsync() + public void StopListeningForeground() { if (!IsListeningForeground) - return Task.FromResult(true); + return; listeningManager.StopUpdatingLocation(); @@ -166,8 +166,6 @@ public Task StopListeningForegroundAsync() listeningManager.Delegate = null; listeningManager = null; - - return Task.FromResult(true); } } diff --git a/src/Essentials/src/Geolocation/Geolocation.netstandard.tvos.watchos.cs b/src/Essentials/src/Geolocation/Geolocation.netstandard.tvos.watchos.cs index ec3f56d0208e..4fc89b6e5a1e 100644 --- a/src/Essentials/src/Geolocation/Geolocation.netstandard.tvos.watchos.cs +++ b/src/Essentials/src/Geolocation/Geolocation.netstandard.tvos.watchos.cs @@ -18,7 +18,7 @@ public Task GetLocationAsync(GeolocationRequest request, CancellationT public Task StartListeningForegroundAsync(GeolocationListeningRequest request) => throw ExceptionUtils.NotSupportedOrImplementedException; - public Task StopListeningForegroundAsync() => + public void StopListeningForeground() => throw ExceptionUtils.NotSupportedOrImplementedException; } } diff --git a/src/Essentials/src/Geolocation/Geolocation.shared.cs b/src/Essentials/src/Geolocation/Geolocation.shared.cs index d9ea998eda84..c338855eeae8 100644 --- a/src/Essentials/src/Geolocation/Geolocation.shared.cs +++ b/src/Essentials/src/Geolocation/Geolocation.shared.cs @@ -64,9 +64,7 @@ public interface IGeolocation /// /// Stop listening for location updates when the app is in the foreground. /// - /// if successfully stopped, or not currently listening, or - /// when an error occurred. - Task StopListeningForegroundAsync(); + void StopListeningForeground(); } /// @@ -153,10 +151,8 @@ public static Task StartListeningForegroundAsync(GeolocationListeningReque /// /// Stop listening for location updates when the app is in the foreground. /// - /// if successfully stopped, or not currently listening, or - /// when an error occurred. - public static Task StopListeningForegroundAsync() => - Current.StopListeningForegroundAsync(); + public static void StopListeningForeground() => + Current.StopListeningForeground(); static IGeolocation Current => Devices.Sensors.Geolocation.Default; diff --git a/src/Essentials/src/Geolocation/Geolocation.tizen.cs b/src/Essentials/src/Geolocation/Geolocation.tizen.cs index 04f917606d26..e32614cd9731 100644 --- a/src/Essentials/src/Geolocation/Geolocation.tizen.cs +++ b/src/Essentials/src/Geolocation/Geolocation.tizen.cs @@ -73,7 +73,7 @@ public async Task GetLocationAsync(GeolocationRequest request, Cancell public Task StartListeningForegroundAsync(GeolocationListeningRequest request) => throw ExceptionUtils.NotSupportedOrImplementedException; - public Task StopListeningForegroundAsync() => + public void StopListeningForeground() => throw ExceptionUtils.NotSupportedOrImplementedException; } } diff --git a/src/Essentials/src/Geolocation/Geolocation.uwp.cs b/src/Essentials/src/Geolocation/Geolocation.uwp.cs index 8a71a7529902..610a13b2844a 100644 --- a/src/Essentials/src/Geolocation/Geolocation.uwp.cs +++ b/src/Essentials/src/Geolocation/Geolocation.uwp.cs @@ -86,28 +86,26 @@ public async Task StartListeningForegroundAsync(GeolocationListeningReques return true; } - public Task StopListeningForegroundAsync() + public void StopListeningForeground() { if (!IsListeningForeground || listeningGeolocator == null) - return Task.FromResult(true); + return; listeningGeolocator.PositionChanged -= OnLocatorPositionChanged; listeningGeolocator.StatusChanged -= OnLocatorStatusChanged; listeningGeolocator = null; - - return Task.FromResult(true); } void OnLocatorPositionChanged(Geolocator sender, PositionChangedEventArgs e) => OnLocationChanged(e.Position.ToLocation()); - async void OnLocatorStatusChanged(Geolocator sender, StatusChangedEventArgs e) + void OnLocatorStatusChanged(Geolocator sender, StatusChangedEventArgs e) { if (!IsListeningForeground) return; - await StopListeningForegroundAsync(); + StopListeningForeground(); GeolocationError error; switch (e.Status) diff --git a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index aad8e00edc62..91237cf2ba8f 100644 --- a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -14,7 +14,7 @@ static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Thre Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.set -> void @@ -29,4 +29,4 @@ Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Mau static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void diff --git a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index aad8e00edc62..91237cf2ba8f 100644 --- a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -14,7 +14,7 @@ static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Thre Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.set -> void @@ -29,4 +29,4 @@ Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Mau static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void diff --git a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index aad8e00edc62..91237cf2ba8f 100644 --- a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -14,7 +14,7 @@ static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Thre Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.set -> void @@ -29,4 +29,4 @@ Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Mau static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void diff --git a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index aad8e00edc62..91237cf2ba8f 100644 --- a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -14,7 +14,7 @@ static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Thre Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.set -> void @@ -29,4 +29,4 @@ Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Mau static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void diff --git a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 23185f0d5bb3..91237cf2ba8f 100644 --- a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -14,7 +14,7 @@ static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Thre Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.set -> void @@ -29,4 +29,4 @@ Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Mau static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! \ No newline at end of file +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void diff --git a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt index aad8e00edc62..91237cf2ba8f 100644 --- a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -14,7 +14,7 @@ static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Thre Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.set -> void @@ -29,4 +29,4 @@ Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Mau static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void diff --git a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index aad8e00edc62..91237cf2ba8f 100644 --- a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -14,7 +14,7 @@ static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Thre Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.get -> Microsoft.Maui.Devices.Sensors.GeolocationAccuracy Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.DesiredAccuracy.set -> void @@ -29,4 +29,4 @@ Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Mau static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForegroundAsync() -> System.Threading.Tasks.Task! +static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void From 2c5448fb1aea02e987ac9d9da35442ffcb7758b0 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Sun, 22 Jan 2023 14:06:15 +0100 Subject: [PATCH 11/22] fixed error in Essentials samples where async keyword is not necessary anymore --- .../samples/Samples/ViewModel/GeolocationViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs b/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs index 81da08c06f96..499eae6ebf90 100644 --- a/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs +++ b/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs @@ -140,7 +140,7 @@ void Geolocation_LocationChanged(object sender, LocationEventArgs e) ListeningLocation = FormatLocation(e.Location); } - async void OnStopListening() + void OnStopListening() { try { From cdb1003082d88b4261cfdbd9fb292e70780b2686 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Sun, 22 Jan 2023 15:58:54 +0100 Subject: [PATCH 12/22] enabled nullable checks for GeolocationListeningRequest class --- .../src/Geolocation/GeolocationListeningRequest.shared.cs | 3 ++- .../src/Geolocation/GeolocationListeningRequest.uwp.cs | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Essentials/src/Geolocation/GeolocationListeningRequest.shared.cs b/src/Essentials/src/Geolocation/GeolocationListeningRequest.shared.cs index 2df79020ad64..35bbe107344b 100644 --- a/src/Essentials/src/Geolocation/GeolocationListeningRequest.shared.cs +++ b/src/Essentials/src/Geolocation/GeolocationListeningRequest.shared.cs @@ -1,4 +1,5 @@ -using System; +#nullable enable +using System; namespace Microsoft.Maui.Devices.Sensors { diff --git a/src/Essentials/src/Geolocation/GeolocationListeningRequest.uwp.cs b/src/Essentials/src/Geolocation/GeolocationListeningRequest.uwp.cs index a907e3a03975..d6b276d792e1 100644 --- a/src/Essentials/src/Geolocation/GeolocationListeningRequest.uwp.cs +++ b/src/Essentials/src/Geolocation/GeolocationListeningRequest.uwp.cs @@ -1,3 +1,5 @@ +#nullable enable + namespace Microsoft.Maui.Devices.Sensors { public partial class GeolocationListeningRequest From 06062db6a78179f96a038780952e1a6626ee246f Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Sat, 28 Jan 2023 11:48:03 +0100 Subject: [PATCH 13/22] renamed ListeningRequest.ios.macos.cs to match class name; no source code changes --- ...uest.ios.macos.cs => GeolocationListeningRequest.ios.macos.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Essentials/src/Geolocation/{ListeningRequest.ios.macos.cs => GeolocationListeningRequest.ios.macos.cs} (100%) diff --git a/src/Essentials/src/Geolocation/ListeningRequest.ios.macos.cs b/src/Essentials/src/Geolocation/GeolocationListeningRequest.ios.macos.cs similarity index 100% rename from src/Essentials/src/Geolocation/ListeningRequest.ios.macos.cs rename to src/Essentials/src/Geolocation/GeolocationListeningRequest.ios.macos.cs From 549269cd55e32575c554c6834d28fe8132f4a4c7 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Thu, 2 Feb 2023 20:32:08 +0100 Subject: [PATCH 14/22] call StopListeningForeground() on Android, iOS and macOS before signalling LocationError event, to make behavior consistent with Windows --- src/Essentials/src/Geolocation/Geolocation.android.cs | 1 + src/Essentials/src/Geolocation/Geolocation.ios.macos.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Essentials/src/Geolocation/Geolocation.android.cs b/src/Essentials/src/Geolocation/Geolocation.android.cs index f30fef3f983c..496801e68944 100644 --- a/src/Essentials/src/Geolocation/Geolocation.android.cs +++ b/src/Essentials/src/Geolocation/Geolocation.android.cs @@ -172,6 +172,7 @@ void HandleLocation(AndroidLocation location) void HandleError(GeolocationError geolocationError) { + StopListeningForeground(); OnLocationError(geolocationError); } } diff --git a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs index 7855551f4616..5438801608eb 100644 --- a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs +++ b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs @@ -146,6 +146,7 @@ void HandleLocation(CLLocation clLocation) void HandleError(GeolocationError error) { + StopListeningForeground(); OnLocationError(error); } } From b737cc916a41da585c696129754d6c7bcd9d7d11 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Thu, 2 Feb 2023 20:55:52 +0100 Subject: [PATCH 15/22] replaced throwing ArgumentNullException with ArgumentNullException.ThrowIfNull() --- src/Essentials/src/Geolocation/Geolocation.android.cs | 4 ++-- src/Essentials/src/Geolocation/Geolocation.ios.macos.cs | 4 ++-- src/Essentials/src/Geolocation/Geolocation.tizen.cs | 2 +- src/Essentials/src/Geolocation/Geolocation.uwp.cs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Essentials/src/Geolocation/Geolocation.android.cs b/src/Essentials/src/Geolocation/Geolocation.android.cs index 496801e68944..916e40be8aa6 100644 --- a/src/Essentials/src/Geolocation/Geolocation.android.cs +++ b/src/Essentials/src/Geolocation/Geolocation.android.cs @@ -47,7 +47,7 @@ public async Task GetLastKnownLocationAsync() public async Task GetLocationAsync(GeolocationRequest request, CancellationToken cancellationToken) { - _ = request ?? throw new ArgumentNullException(nameof(request)); + ArgumentNullException.ThrowIfNull(request); await Permissions.EnsureGrantedOrRestrictedAsync(); @@ -119,7 +119,7 @@ void RemoveUpdates() public async Task StartListeningForegroundAsync(GeolocationListeningRequest request) { - _ = request ?? throw new ArgumentNullException(nameof(request)); + ArgumentNullException.ThrowIfNull(request); if (IsListeningForeground) throw new InvalidOperationException("Already listening to location changes."); diff --git a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs index 5438801608eb..13614c8ae4f6 100644 --- a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs +++ b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs @@ -36,7 +36,7 @@ public async Task GetLastKnownLocationAsync() public async Task GetLocationAsync(GeolocationRequest request, CancellationToken cancellationToken) { - _ = request ?? throw new ArgumentNullException(nameof(request)); + ArgumentNullException.ThrowIfNull(request); if (!CLLocationManager.LocationServicesEnabled) throw new FeatureNotEnabledException("Location services are not enabled on device."); @@ -99,7 +99,7 @@ void Cancel() public async Task StartListeningForegroundAsync(GeolocationListeningRequest request) { - _ = request ?? throw new ArgumentNullException(nameof(request)); + ArgumentNullException.ThrowIfNull(request); if (IsListeningForeground) throw new InvalidOperationException("Already listening to location changes."); diff --git a/src/Essentials/src/Geolocation/Geolocation.tizen.cs b/src/Essentials/src/Geolocation/Geolocation.tizen.cs index e32614cd9731..9ed480844860 100644 --- a/src/Essentials/src/Geolocation/Geolocation.tizen.cs +++ b/src/Essentials/src/Geolocation/Geolocation.tizen.cs @@ -16,7 +16,7 @@ partial class GeolocationImplementation : IGeolocation public async Task GetLocationAsync(GeolocationRequest request, CancellationToken cancellationToken) { - _ = request ?? throw new ArgumentNullException(nameof(request)); + ArgumentNullException.ThrowIfNull(request); await Permissions.EnsureGrantedAsync(); diff --git a/src/Essentials/src/Geolocation/Geolocation.uwp.cs b/src/Essentials/src/Geolocation/Geolocation.uwp.cs index 610a13b2844a..bf448d0028a5 100644 --- a/src/Essentials/src/Geolocation/Geolocation.uwp.cs +++ b/src/Essentials/src/Geolocation/Geolocation.uwp.cs @@ -31,7 +31,7 @@ partial class GeolocationImplementation : IGeolocation public async Task GetLocationAsync(GeolocationRequest request, CancellationToken cancellationToken) { - _ = request ?? throw new ArgumentNullException(nameof(request)); + ArgumentNullException.ThrowIfNull(request); await Permissions.EnsureGrantedAsync(); @@ -61,7 +61,7 @@ static void CheckStatus(PositionStatus status) public async Task StartListeningForegroundAsync(GeolocationListeningRequest request) { - _ = request ?? throw new ArgumentNullException(nameof(request)); + ArgumentNullException.ThrowIfNull(request); if (request.MinimumTime.TotalMilliseconds < 0) throw new ArgumentOutOfRangeException(nameof(request), "MinimumTime must be positive."); From ef775d2efeb8f0505723ceb6a8285eb562475478 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Thu, 2 Feb 2023 21:31:31 +0100 Subject: [PATCH 16/22] added xml documentation for all newly added public geolocaion foreground listening APIs --- .../src/Geolocation/Geolocation.android.cs | 19 +++++++++++ .../src/Geolocation/Geolocation.ios.macos.cs | 25 ++++++++++++++ .../src/Geolocation/Geolocation.shared.cs | 33 ++++++++++--------- .../src/Geolocation/Geolocation.uwp.cs | 19 +++++++++++ 4 files changed, 80 insertions(+), 16 deletions(-) diff --git a/src/Essentials/src/Geolocation/Geolocation.android.cs b/src/Essentials/src/Geolocation/Geolocation.android.cs index 916e40be8aa6..df11ea7b967d 100644 --- a/src/Essentials/src/Geolocation/Geolocation.android.cs +++ b/src/Essentials/src/Geolocation/Geolocation.android.cs @@ -26,6 +26,9 @@ partial class GeolocationImplementation : IGeolocation static LocationManager LocationManager => locationManager ??= Application.Context.GetSystemService(Context.LocationService) as LocationManager; + /// + /// Indicates if currently listening to location updates while the app is in foreground. + /// public bool IsListeningForeground { get => continuousListener != null; } public async Task GetLastKnownLocationAsync() @@ -117,6 +120,17 @@ void RemoveUpdates() } } + /// + /// Starts listening to location updates using the + /// event or the event. Events may only sent when + /// the app is in the foreground. Requests + /// from the user. + /// + /// Thrown when is . + /// Thrown if listening is not supported on this platform. + /// Thrown if already listening and returns . + /// The listening request parameters to use. + /// when listening was started, or when listening couldn't be started. public async Task StartListeningForegroundAsync(GeolocationListeningRequest request) { ArgumentNullException.ThrowIfNull(request); @@ -177,6 +191,11 @@ void HandleError(GeolocationError geolocationError) } } + /// + /// Stop listening for location updates when the app is in the foreground. + /// Has no effect when not listening and + /// is currently . + /// public void StopListeningForeground() { if (continuousListener == null) diff --git a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs index 13614c8ae4f6..3b4e9e22c520 100644 --- a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs +++ b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs @@ -12,6 +12,9 @@ partial class GeolocationImplementation : IGeolocation { CLLocationManager listeningManager; + /// + /// Indicates if currently listening to location updates while the app is in foreground. + /// public bool IsListeningForeground { get => listeningManager != null; } public async Task GetLastKnownLocationAsync() @@ -97,6 +100,17 @@ void Cancel() } } + /// + /// Starts listening to location updates using the + /// event or the event. Events may only sent when + /// the app is in the foreground. Requests + /// from the user. + /// + /// Thrown when is . + /// Thrown if listening is not supported on this platform. + /// Thrown if already listening and returns . + /// The listening request parameters to use. + /// when listening was started, or when listening couldn't be started. public async Task StartListeningForegroundAsync(GeolocationListeningRequest request) { ArgumentNullException.ThrowIfNull(request); @@ -151,6 +165,11 @@ void HandleError(GeolocationError error) } } + /// + /// Stop listening for location updates when the app is in the foreground. + /// Has no effect when not listening and + /// is currently . + /// public void StopListeningForeground() { if (!IsListeningForeground) @@ -176,6 +195,7 @@ class SingleLocationListener : CLLocationManagerDelegate internal Action LocationHandler { get; set; } + /// public override void LocationsUpdated(CLLocationManager manager, CLLocation[] locations) { if (wasRaised) @@ -191,6 +211,7 @@ public override void LocationsUpdated(CLLocationManager manager, CLLocation[] lo LocationHandler?.Invoke(location); } + /// public override bool ShouldDisplayHeadingCalibration(CLLocationManager manager) => false; } @@ -200,6 +221,7 @@ class ContinuousLocationListener : CLLocationManagerDelegate internal Action ErrorHandler { get; set; } + /// public override void LocationsUpdated(CLLocationManager manager, CLLocation[] locations) { var location = locations?.LastOrDefault(); @@ -210,12 +232,14 @@ public override void LocationsUpdated(CLLocationManager manager, CLLocation[] lo LocationHandler?.Invoke(location); } + /// public override void Failed(CLLocationManager manager, NSError error) { if ((CLError)error.Code == CLError.Network) ErrorHandler?.Invoke(GeolocationError.PositionUnavailable); } + /// public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { if (status == CLAuthorizationStatus.Denied || @@ -223,6 +247,7 @@ public override void AuthorizationChanged(CLLocationManager manager, CLAuthoriza ErrorHandler?.Invoke(GeolocationError.Unauthorized); } + /// public override bool ShouldDisplayHeadingCalibration(CLLocationManager manager) => false; } } diff --git a/src/Essentials/src/Geolocation/Geolocation.shared.cs b/src/Essentials/src/Geolocation/Geolocation.shared.cs index c338855eeae8..6c9215fa37a7 100644 --- a/src/Essentials/src/Geolocation/Geolocation.shared.cs +++ b/src/Essentials/src/Geolocation/Geolocation.shared.cs @@ -49,20 +49,18 @@ public interface IGeolocation /// /// Starts listening to location updates using the event. Events /// may only sent when the app is in the foreground. Requests - /// from the user. + /// from the user. /// - /// - /// Will throw if request is null. - /// Will throw if listening is not supported on this platform. - /// Will throw if already listening; check - /// to see if already listening. - /// + /// Thrown when is . + /// Thrown if listening is not supported on this platform. + /// Thrown if already listening and returns . /// The listening request parameters to use. /// when listening was started, or when listening couldn't be started. Task StartListeningForegroundAsync(GeolocationListeningRequest request); /// /// Stop listening for location updates when the app is in the foreground. + /// Has no effect when is currently . /// void StopListeningForeground(); } @@ -125,7 +123,9 @@ public static event EventHandler LocationChanged } /// - /// Occurs when an error during listening for location updates arises. + /// Occurs when an error during listening for location updates arises. When the event is + /// fired, listening to locations is stopped and no further + /// events are sent. /// public static event EventHandler LocationError { @@ -134,15 +134,14 @@ public static event EventHandler LocationError } /// - /// Starts listening to location updates using the event. Events - /// may only be sent when the app is in the foreground. Requests - /// from the user. + /// Starts listening to location updates using the + /// event or the event. Events may only sent when + /// the app is in the foreground. Requests + /// from the user. /// - /// - /// Will throw if listening is not supported on this platform. - /// Will throw if already listening; check - /// to see if already listening. - /// + /// Thrown when is . + /// Thrown if listening is not supported on this platform. + /// Thrown if already listening and returns . /// The listening request parameters to use. /// when listening was started, or when listening couldn't be started. public static Task StartListeningForegroundAsync(GeolocationListeningRequest request) => @@ -150,6 +149,8 @@ public static Task StartListeningForegroundAsync(GeolocationListeningReque /// /// Stop listening for location updates when the app is in the foreground. + /// Has no effect when not listening and + /// is currently . /// public static void StopListeningForeground() => Current.StopListeningForeground(); diff --git a/src/Essentials/src/Geolocation/Geolocation.uwp.cs b/src/Essentials/src/Geolocation/Geolocation.uwp.cs index bf448d0028a5..7228ff8a91f2 100644 --- a/src/Essentials/src/Geolocation/Geolocation.uwp.cs +++ b/src/Essentials/src/Geolocation/Geolocation.uwp.cs @@ -11,6 +11,9 @@ partial class GeolocationImplementation : IGeolocation { Geolocator? listeningGeolocator; + /// + /// Indicates if currently listening to location updates while the app is in foreground. + /// public bool IsListeningForeground { get => false; } public async Task GetLastKnownLocationAsync() @@ -59,6 +62,17 @@ static void CheckStatus(PositionStatus status) } } + /// + /// Starts listening to location updates using the + /// event or the event. Events may only sent when + /// the app is in the foreground. Requests + /// from the user. + /// + /// Thrown when is . + /// Thrown if listening is not supported on this platform. + /// Thrown if already listening and returns . + /// The listening request parameters to use. + /// when listening was started, or when listening couldn't be started. public async Task StartListeningForegroundAsync(GeolocationListeningRequest request) { ArgumentNullException.ThrowIfNull(request); @@ -86,6 +100,11 @@ public async Task StartListeningForegroundAsync(GeolocationListeningReques return true; } + /// + /// Stop listening for location updates when the app is in the foreground. + /// Has no effect when not listening and + /// is currently . + /// public void StopListeningForeground() { if (!IsListeningForeground || listeningGeolocator == null) From 187f45d43ae4777c261390a692f91abb585f8f80 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Thu, 2 Feb 2023 21:38:34 +0100 Subject: [PATCH 17/22] removed duplicated code for determining GeolocationAccuracy on iOS and macOS --- ...ationAccuracyExtensionMethods.ios.macos.cs | 28 +++++++++++++++++++ .../GeolocationListeningRequest.ios.macos.cs | 22 ++------------- .../GeolocationRequest.ios.macos.cs | 22 ++------------- 3 files changed, 32 insertions(+), 40 deletions(-) create mode 100644 src/Essentials/src/Geolocation/GeolocationAccuracyExtensionMethods.ios.macos.cs diff --git a/src/Essentials/src/Geolocation/GeolocationAccuracyExtensionMethods.ios.macos.cs b/src/Essentials/src/Geolocation/GeolocationAccuracyExtensionMethods.ios.macos.cs new file mode 100644 index 000000000000..be42c328cf9a --- /dev/null +++ b/src/Essentials/src/Geolocation/GeolocationAccuracyExtensionMethods.ios.macos.cs @@ -0,0 +1,28 @@ +#nullable enable +using CoreLocation; + +namespace Microsoft.Maui.Devices.Sensors +{ + static class GeolocationAccuracyExtensionMethods + { + internal static double PlatformDesiredAccuracy(this GeolocationAccuracy desiredAccuracy) + { + switch (desiredAccuracy) + { + case GeolocationAccuracy.Lowest: + return CLLocation.AccuracyThreeKilometers; + case GeolocationAccuracy.Low: + return CLLocation.AccuracyKilometer; + case GeolocationAccuracy.Default: + case GeolocationAccuracy.Medium: + return CLLocation.AccuracyHundredMeters; + case GeolocationAccuracy.High: + return CLLocation.AccuracyNearestTenMeters; + case GeolocationAccuracy.Best: + return CLLocation.AccurracyBestForNavigation; + default: + return CLLocation.AccuracyHundredMeters; + } + } + } +} diff --git a/src/Essentials/src/Geolocation/GeolocationListeningRequest.ios.macos.cs b/src/Essentials/src/Geolocation/GeolocationListeningRequest.ios.macos.cs index 3814e4b75772..2bfa09596819 100644 --- a/src/Essentials/src/Geolocation/GeolocationListeningRequest.ios.macos.cs +++ b/src/Essentials/src/Geolocation/GeolocationListeningRequest.ios.macos.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using CoreLocation; +#nullable enable namespace Microsoft.Maui.Devices.Sensors { @@ -11,22 +8,7 @@ internal double PlatformDesiredAccuracy { get { - switch (DesiredAccuracy) - { - case GeolocationAccuracy.Lowest: - return CLLocation.AccuracyThreeKilometers; - case GeolocationAccuracy.Low: - return CLLocation.AccuracyKilometer; - case GeolocationAccuracy.Default: - case GeolocationAccuracy.Medium: - return CLLocation.AccuracyHundredMeters; - case GeolocationAccuracy.High: - return CLLocation.AccuracyNearestTenMeters; - case GeolocationAccuracy.Best: - return CLLocation.AccurracyBestForNavigation; - default: - return CLLocation.AccuracyHundredMeters; - } + return DesiredAccuracy.PlatformDesiredAccuracy(); } } } diff --git a/src/Essentials/src/Geolocation/GeolocationRequest.ios.macos.cs b/src/Essentials/src/Geolocation/GeolocationRequest.ios.macos.cs index a6a96532e782..616cffec59a9 100644 --- a/src/Essentials/src/Geolocation/GeolocationRequest.ios.macos.cs +++ b/src/Essentials/src/Geolocation/GeolocationRequest.ios.macos.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using CoreLocation; +#nullable enable namespace Microsoft.Maui.Devices.Sensors { @@ -11,22 +8,7 @@ internal double PlatformDesiredAccuracy { get { - switch (DesiredAccuracy) - { - case GeolocationAccuracy.Lowest: - return CLLocation.AccuracyThreeKilometers; - case GeolocationAccuracy.Low: - return CLLocation.AccuracyKilometer; - case GeolocationAccuracy.Default: - case GeolocationAccuracy.Medium: - return CLLocation.AccuracyHundredMeters; - case GeolocationAccuracy.High: - return CLLocation.AccuracyNearestTenMeters; - case GeolocationAccuracy.Best: - return CLLocation.AccurracyBestForNavigation; - default: - return CLLocation.AccuracyHundredMeters; - } + return DesiredAccuracy.PlatformDesiredAccuracy(); } } } From f4b46376441b983393abf766c74245e7b73ce491 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Sat, 4 Feb 2023 10:22:23 +0100 Subject: [PATCH 18/22] renamed event LocationError to ListeningFailed and GeolocationErrorEventArgs to GeolocationListeningFailedEventArgs --- .../src/Geolocation/Geolocation.android.cs | 2 +- .../src/Geolocation/Geolocation.ios.macos.cs | 2 +- .../src/Geolocation/Geolocation.shared.cs | 23 ++++++++++--------- .../src/Geolocation/Geolocation.uwp.cs | 2 +- ...ocationListeningFailedEventArgs.shared.cs} | 4 ++-- .../net-android/PublicAPI.Unshipped.txt | 10 ++++---- .../PublicAPI/net-ios/PublicAPI.Unshipped.txt | 10 ++++---- .../net-maccatalyst/PublicAPI.Unshipped.txt | 10 ++++---- .../net-tizen/PublicAPI.Unshipped.txt | 10 ++++---- .../net-windows/PublicAPI.Unshipped.txt | 10 ++++---- .../src/PublicAPI/net/PublicAPI.Unshipped.txt | 10 ++++---- .../netstandard/PublicAPI.Unshipped.txt | 10 ++++---- 12 files changed, 52 insertions(+), 51 deletions(-) rename src/Essentials/src/Geolocation/{GeolocationErrorEventArgs.shared.cs => GeolocationListeningFailedEventArgs.shared.cs} (78%) diff --git a/src/Essentials/src/Geolocation/Geolocation.android.cs b/src/Essentials/src/Geolocation/Geolocation.android.cs index df11ea7b967d..b7035227b163 100644 --- a/src/Essentials/src/Geolocation/Geolocation.android.cs +++ b/src/Essentials/src/Geolocation/Geolocation.android.cs @@ -122,7 +122,7 @@ void RemoveUpdates() /// /// Starts listening to location updates using the - /// event or the event. Events may only sent when + /// event or the event. Events may only sent when /// the app is in the foreground. Requests /// from the user. /// diff --git a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs index 3b4e9e22c520..e2c93bace244 100644 --- a/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs +++ b/src/Essentials/src/Geolocation/Geolocation.ios.macos.cs @@ -102,7 +102,7 @@ void Cancel() /// /// Starts listening to location updates using the - /// event or the event. Events may only sent when + /// event or the event. Events may only sent when /// the app is in the foreground. Requests /// from the user. /// diff --git a/src/Essentials/src/Geolocation/Geolocation.shared.cs b/src/Essentials/src/Geolocation/Geolocation.shared.cs index 6c9215fa37a7..7740803ee3dc 100644 --- a/src/Essentials/src/Geolocation/Geolocation.shared.cs +++ b/src/Essentials/src/Geolocation/Geolocation.shared.cs @@ -41,10 +41,11 @@ public interface IGeolocation event EventHandler? LocationChanged; /// - /// Occurs when an error during listening for location updates arises. When getting the event, - /// listening for further updates may have been stopped. + /// Occurs when an error during listening for location updates arises. When the event is + /// fired, listening for further location updates has been stopped and no further + /// events are sent. /// - event EventHandler? LocationError; + event EventHandler? ListeningFailed; /// /// Starts listening to location updates using the event. Events @@ -124,18 +125,18 @@ public static event EventHandler LocationChanged /// /// Occurs when an error during listening for location updates arises. When the event is - /// fired, listening to locations is stopped and no further - /// events are sent. + /// fired, listening for further location updates has been stopped and no further + /// events are sent. /// - public static event EventHandler LocationError + public static event EventHandler ListeningFailed { - add => Current.LocationError += value; - remove => Current.LocationError -= value; + add => Current.ListeningFailed += value; + remove => Current.ListeningFailed -= value; } /// /// Starts listening to location updates using the - /// event or the event. Events may only sent when + /// event or the event. Events may only sent when /// the app is in the foreground. Requests /// from the user. /// @@ -173,7 +174,7 @@ partial class GeolocationImplementation : IGeolocation { public event EventHandler? LocationChanged; - public event EventHandler? LocationError; + public event EventHandler? ListeningFailed; internal void OnLocationChanged(Location location) => OnLocationChanged(new LocationEventArgs(location)); @@ -182,7 +183,7 @@ internal void OnLocationChanged(LocationEventArgs e) => LocationChanged?.Invoke(null, e); internal void OnLocationError(GeolocationError geolocationError) => - LocationError?.Invoke(null, new GeolocationErrorEventArgs(geolocationError)); + ListeningFailed?.Invoke(null, new GeolocationListeningFailedEventArgs(geolocationError)); } /// diff --git a/src/Essentials/src/Geolocation/Geolocation.uwp.cs b/src/Essentials/src/Geolocation/Geolocation.uwp.cs index 7228ff8a91f2..9d9149b93012 100644 --- a/src/Essentials/src/Geolocation/Geolocation.uwp.cs +++ b/src/Essentials/src/Geolocation/Geolocation.uwp.cs @@ -64,7 +64,7 @@ static void CheckStatus(PositionStatus status) /// /// Starts listening to location updates using the - /// event or the event. Events may only sent when + /// event or the event. Events may only sent when /// the app is in the foreground. Requests /// from the user. /// diff --git a/src/Essentials/src/Geolocation/GeolocationErrorEventArgs.shared.cs b/src/Essentials/src/Geolocation/GeolocationListeningFailedEventArgs.shared.cs similarity index 78% rename from src/Essentials/src/Geolocation/GeolocationErrorEventArgs.shared.cs rename to src/Essentials/src/Geolocation/GeolocationListeningFailedEventArgs.shared.cs index 3042538e542e..f32ca843d6c3 100644 --- a/src/Essentials/src/Geolocation/GeolocationErrorEventArgs.shared.cs +++ b/src/Essentials/src/Geolocation/GeolocationListeningFailedEventArgs.shared.cs @@ -6,7 +6,7 @@ namespace Microsoft.Maui.Devices.Sensors /// /// Event args for the geolocation listening error event. /// - public class GeolocationErrorEventArgs : EventArgs + public class GeolocationListeningFailedEventArgs : EventArgs { /// /// The geolocation error that describes the error that occurred. @@ -17,7 +17,7 @@ public class GeolocationErrorEventArgs : EventArgs /// Creates a new geolocation error event args object /// /// gelocation error to use for this object - public GeolocationErrorEventArgs(GeolocationError geolocationError) + public GeolocationListeningFailedEventArgs(GeolocationError geolocationError) { Error = geolocationError; } diff --git a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 91237cf2ba8f..4e1fdc268168 100644 --- a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -4,12 +4,12 @@ Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.GeolocationListeningFailedEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.ListeningFailed -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 91237cf2ba8f..4e1fdc268168 100644 --- a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -4,12 +4,12 @@ Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.GeolocationListeningFailedEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.ListeningFailed -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 91237cf2ba8f..4e1fdc268168 100644 --- a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -4,12 +4,12 @@ Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.GeolocationListeningFailedEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.ListeningFailed -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 91237cf2ba8f..4e1fdc268168 100644 --- a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -4,12 +4,12 @@ Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.GeolocationListeningFailedEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.ListeningFailed -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 91237cf2ba8f..4e1fdc268168 100644 --- a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -4,12 +4,12 @@ Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.GeolocationListeningFailedEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.ListeningFailed -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt index 91237cf2ba8f..4e1fdc268168 100644 --- a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -4,12 +4,12 @@ Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.GeolocationListeningFailedEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.ListeningFailed -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? diff --git a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index 91237cf2ba8f..4e1fdc268168 100644 --- a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -4,12 +4,12 @@ Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.PositionUnavailable = 0 -> Microsoft.Maui.Devices.Sensors.GeolocationError Microsoft.Maui.Devices.Sensors.GeolocationError.Unauthorized = 1 -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError -Microsoft.Maui.Devices.Sensors.GeolocationErrorEventArgs.GeolocationErrorEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationError -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.Error.get -> Microsoft.Maui.Devices.Sensors.GeolocationError +Microsoft.Maui.Devices.Sensors.GeolocationListeningFailedEventArgs.GeolocationListeningFailedEventArgs(Microsoft.Maui.Devices.Sensors.GeolocationError geolocationError) -> void +Microsoft.Maui.Devices.Sensors.IGeolocation.ListeningFailed -> System.EventHandler? Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationError -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? From 51ebc87e51d9720e94147cd22e6c97ff81e5dfa9 Mon Sep 17 00:00:00 2001 From: Michael Fink Date: Sat, 4 Feb 2023 10:25:13 +0100 Subject: [PATCH 19/22] fixed IsListeningForeground property on Windows --- src/Essentials/src/Geolocation/Geolocation.uwp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Essentials/src/Geolocation/Geolocation.uwp.cs b/src/Essentials/src/Geolocation/Geolocation.uwp.cs index 9d9149b93012..4c80fbd0b200 100644 --- a/src/Essentials/src/Geolocation/Geolocation.uwp.cs +++ b/src/Essentials/src/Geolocation/Geolocation.uwp.cs @@ -14,7 +14,7 @@ partial class GeolocationImplementation : IGeolocation /// /// Indicates if currently listening to location updates while the app is in foreground. /// - public bool IsListeningForeground { get => false; } + public bool IsListeningForeground { get => listeningGeolocator != null; } public async Task GetLastKnownLocationAsync() { From 9dd72a28fb7483e017d3e353c4281901ad6ce051 Mon Sep 17 00:00:00 2001 From: Gerald Versluis Date: Mon, 13 Feb 2023 14:55:11 +0100 Subject: [PATCH 20/22] Fixed naming --- src/Essentials/src/Geolocation/Geolocation.shared.cs | 10 +++++----- ...s => GeolocationLocationChangedEventArgs.shared.cs} | 4 ++-- .../src/PublicAPI/net-android/PublicAPI.Unshipped.txt | 10 +++++----- .../src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | 10 +++++----- .../PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | 10 +++++----- .../src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | 10 +++++----- .../src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | 10 +++++----- .../src/PublicAPI/net/PublicAPI.Unshipped.txt | 10 +++++----- .../src/PublicAPI/netstandard/PublicAPI.Unshipped.txt | 10 +++++----- 9 files changed, 42 insertions(+), 42 deletions(-) rename src/Essentials/src/Geolocation/{LocationEventArgs.shared.cs => GeolocationLocationChangedEventArgs.shared.cs} (65%) diff --git a/src/Essentials/src/Geolocation/Geolocation.shared.cs b/src/Essentials/src/Geolocation/Geolocation.shared.cs index 7740803ee3dc..64809d25cd89 100644 --- a/src/Essentials/src/Geolocation/Geolocation.shared.cs +++ b/src/Essentials/src/Geolocation/Geolocation.shared.cs @@ -38,7 +38,7 @@ public interface IGeolocation /// /// Occurs while listening to location updates. /// - event EventHandler? LocationChanged; + event EventHandler? LocationChanged; /// /// Occurs when an error during listening for location updates arises. When the event is @@ -117,7 +117,7 @@ public static partial class Geolocation /// /// Occurs while listening to location updates. /// - public static event EventHandler LocationChanged + public static event EventHandler LocationChanged { add => Current.LocationChanged += value; remove => Current.LocationChanged -= value; @@ -172,14 +172,14 @@ internal static void SetDefault(IGeolocation? implementation) => partial class GeolocationImplementation : IGeolocation { - public event EventHandler? LocationChanged; + public event EventHandler? LocationChanged; public event EventHandler? ListeningFailed; internal void OnLocationChanged(Location location) => - OnLocationChanged(new LocationEventArgs(location)); + OnLocationChanged(new GeolocationLocationChangedEventArgs(location)); - internal void OnLocationChanged(LocationEventArgs e) => + internal void OnLocationChanged(GeolocationLocationChangedEventArgs e) => LocationChanged?.Invoke(null, e); internal void OnLocationError(GeolocationError geolocationError) => diff --git a/src/Essentials/src/Geolocation/LocationEventArgs.shared.cs b/src/Essentials/src/Geolocation/GeolocationLocationChangedEventArgs.shared.cs similarity index 65% rename from src/Essentials/src/Geolocation/LocationEventArgs.shared.cs rename to src/Essentials/src/Geolocation/GeolocationLocationChangedEventArgs.shared.cs index b5349267a348..4cb3f8bb6f06 100644 --- a/src/Essentials/src/Geolocation/LocationEventArgs.shared.cs +++ b/src/Essentials/src/Geolocation/GeolocationLocationChangedEventArgs.shared.cs @@ -3,11 +3,11 @@ namespace Microsoft.Maui.Devices.Sensors { - public class LocationEventArgs : EventArgs + public class GeolocationLocationChangedEventArgs : EventArgs { public Location Location { get; } - public LocationEventArgs(Location location) + public GeolocationLocationChangedEventArgs(Location location) { if (location == null) throw new ArgumentNullException(nameof(location)); diff --git a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 9b64d8883ac6..c64aedf4601a 100644 --- a/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -18,7 +18,7 @@ Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading. static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest @@ -29,11 +29,11 @@ Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningR Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.get -> System.TimeSpan Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.set -> void -Microsoft.Maui.Devices.Sensors.LocationEventArgs -Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! -Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.GeolocationLocationChangedEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void *REMOVED*static Microsoft.Maui.ApplicationModel.Communication.PhoneDialer.Current.get -> Microsoft.Maui.ApplicationModel.Communication.IPhoneDialer! diff --git a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 9b64d8883ac6..c64aedf4601a 100644 --- a/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -18,7 +18,7 @@ Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading. static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest @@ -29,11 +29,11 @@ Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningR Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.get -> System.TimeSpan Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.set -> void -Microsoft.Maui.Devices.Sensors.LocationEventArgs -Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! -Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.GeolocationLocationChangedEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void *REMOVED*static Microsoft.Maui.ApplicationModel.Communication.PhoneDialer.Current.get -> Microsoft.Maui.ApplicationModel.Communication.IPhoneDialer! diff --git a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 9b64d8883ac6..c64aedf4601a 100644 --- a/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -18,7 +18,7 @@ Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading. static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest @@ -29,11 +29,11 @@ Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningR Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.get -> System.TimeSpan Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.set -> void -Microsoft.Maui.Devices.Sensors.LocationEventArgs -Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! -Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.GeolocationLocationChangedEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void *REMOVED*static Microsoft.Maui.ApplicationModel.Communication.PhoneDialer.Current.get -> Microsoft.Maui.ApplicationModel.Communication.IPhoneDialer! diff --git a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 9b64d8883ac6..c64aedf4601a 100644 --- a/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -18,7 +18,7 @@ Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading. static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest @@ -29,11 +29,11 @@ Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningR Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.get -> System.TimeSpan Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.set -> void -Microsoft.Maui.Devices.Sensors.LocationEventArgs -Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! -Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.GeolocationLocationChangedEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void *REMOVED*static Microsoft.Maui.ApplicationModel.Communication.PhoneDialer.Current.get -> Microsoft.Maui.ApplicationModel.Communication.IPhoneDialer! diff --git a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 9b64d8883ac6..c64aedf4601a 100644 --- a/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -18,7 +18,7 @@ Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading. static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest @@ -29,11 +29,11 @@ Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningR Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.get -> System.TimeSpan Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.set -> void -Microsoft.Maui.Devices.Sensors.LocationEventArgs -Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! -Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.GeolocationLocationChangedEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void *REMOVED*static Microsoft.Maui.ApplicationModel.Communication.PhoneDialer.Current.get -> Microsoft.Maui.ApplicationModel.Communication.IPhoneDialer! diff --git a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt index 9b64d8883ac6..c64aedf4601a 100644 --- a/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -18,7 +18,7 @@ Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading. static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest @@ -29,11 +29,11 @@ Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningR Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.get -> System.TimeSpan Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.set -> void -Microsoft.Maui.Devices.Sensors.LocationEventArgs -Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! -Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.GeolocationLocationChangedEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void *REMOVED*static Microsoft.Maui.ApplicationModel.Communication.PhoneDialer.Current.get -> Microsoft.Maui.ApplicationModel.Communication.IPhoneDialer! diff --git a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index 9b64d8883ac6..c64aedf4601a 100644 --- a/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -18,7 +18,7 @@ Microsoft.Maui.Storage.ISecureStorage.GetAsync(string! key) -> System.Threading. static Microsoft.Maui.Devices.Sensors.Geolocation.ListeningFailed -> System.EventHandler! static Microsoft.Maui.Storage.SecureStorage.GetAsync(string! key) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.IsListeningForeground.get -> bool -Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? +Microsoft.Maui.Devices.Sensors.IGeolocation.LocationChanged -> System.EventHandler? Microsoft.Maui.Devices.Sensors.IGeolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! Microsoft.Maui.Devices.Sensors.IGeolocation.StopListeningForeground() -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest @@ -29,11 +29,11 @@ Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningR Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.GeolocationListeningRequest(Microsoft.Maui.Devices.Sensors.GeolocationAccuracy accuracy, System.TimeSpan minimumTime) -> void Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.get -> System.TimeSpan Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest.MinimumTime.set -> void -Microsoft.Maui.Devices.Sensors.LocationEventArgs -Microsoft.Maui.Devices.Sensors.LocationEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! -Microsoft.Maui.Devices.Sensors.LocationEventArgs.LocationEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.Location.get -> Microsoft.Maui.Devices.Sensors.Location! +Microsoft.Maui.Devices.Sensors.GeolocationLocationChangedEventArgs.GeolocationLocationChangedEventArgs(Microsoft.Maui.Devices.Sensors.Location! location) -> void static Microsoft.Maui.Devices.Sensors.Geolocation.IsListeningForeground.get -> bool -static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! +static Microsoft.Maui.Devices.Sensors.Geolocation.LocationChanged -> System.EventHandler! static Microsoft.Maui.Devices.Sensors.Geolocation.StartListeningForegroundAsync(Microsoft.Maui.Devices.Sensors.GeolocationListeningRequest! request) -> System.Threading.Tasks.Task! static Microsoft.Maui.Devices.Sensors.Geolocation.StopListeningForeground() -> void *REMOVED*static Microsoft.Maui.ApplicationModel.Communication.PhoneDialer.Current.get -> Microsoft.Maui.ApplicationModel.Communication.IPhoneDialer! From 6ed2ac790d735ca8afecef45cf0e8942be8db309 Mon Sep 17 00:00:00 2001 From: Gerald Versluis Date: Mon, 13 Feb 2023 16:17:35 +0100 Subject: [PATCH 21/22] Update GeolocationViewModel.cs --- .../samples/Samples/ViewModel/GeolocationViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs b/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs index 499eae6ebf90..ed9d3c0275f4 100644 --- a/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs +++ b/src/Essentials/samples/Samples/ViewModel/GeolocationViewModel.cs @@ -135,7 +135,7 @@ async void OnStartListening() OnPropertyChanged(nameof(IsNotListening)); } - void Geolocation_LocationChanged(object sender, LocationEventArgs e) + void Geolocation_LocationChanged(object sender, GeolocationLocationChangedEventArgs e) { ListeningLocation = FormatLocation(e.Location); } From 35fdb1886960e711baf4134fbe21d721126bfe7e Mon Sep 17 00:00:00 2001 From: GitHub Actions Autoformatter Date: Mon, 13 Feb 2023 15:21:28 +0000 Subject: [PATCH 22/22] Thank you for your pull request. We are auto-formating your source code to follow our code guidelines. --- .../src/Geolocation/GeolocationListeningRequest.shared.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Essentials/src/Geolocation/GeolocationListeningRequest.shared.cs b/src/Essentials/src/Geolocation/GeolocationListeningRequest.shared.cs index 35bbe107344b..7420ca575551 100644 --- a/src/Essentials/src/Geolocation/GeolocationListeningRequest.shared.cs +++ b/src/Essentials/src/Geolocation/GeolocationListeningRequest.shared.cs @@ -21,7 +21,7 @@ public GeolocationListeningRequest() /// /// The desired geolocation accuracy. public GeolocationListeningRequest(GeolocationAccuracy accuracy) - :this(accuracy, TimeSpan.FromSeconds(1)) + : this(accuracy, TimeSpan.FromSeconds(1)) { }