Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
1.5.0 Changes (#1124)
Browse files Browse the repository at this point in the history
* Implement vertical accuracy in GeoLocation API (#1103)

* Location: add property 'VerticalAccuracy' (#1099)

* vertical accuracy is only available in Android API level 26 and above (#1099)

* update Samples app to show vertical accuracy on GeolocationPage

* add missing documentation bits for Location.VerticalAccuracy

* .gitattributes: get better diff context for C# code (#1115)

* Location.VerticalAccuracy: add runtime check for Android version (#1099) (#1116)

* the compile-time check is not enough
* it crashed on old Android versions (<8.0)

* GH-1102 Fix launcher on older devices (#1120)

* Update Launcher.ios.tvos.cs

* OpenUrlAsync was introduced in iOS 10 not 12

https://docs.microsoft.com/en-us/dotnet/api/uikit.uiapplication.openurlasync?view=xamarin-ios-sdk-12

* Fix trailing whitespace

* Really? fix whitespace

* Really! Fix whitespace

Co-authored-by: Janus Weil <[email protected]>
Co-authored-by: James Montemagno <[email protected]>
  • Loading branch information
3 people authored Feb 26, 2020
1 parent 5e0b655 commit 634e74f
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
Expand Down
3 changes: 2 additions & 1 deletion Samples/Samples/ViewModel/GeolocationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ string FormatLocation(Location location, Exception ex = null)
return
$"Latitude: {location.Latitude}\n" +
$"Longitude: {location.Longitude}\n" +
$"Accuracy: {location.Accuracy}\n" +
$"HorizontalAccuracy: {location.Accuracy}\n" +
$"Altitude: {(location.Altitude.HasValue ? location.Altitude.Value.ToString() : notAvailable)}\n" +
$"VerticalAccuracy: {(location.VerticalAccuracy.HasValue ? location.VerticalAccuracy.Value.ToString() : notAvailable)}\n" +
$"Heading: {(location.Course.HasValue ? location.Course.Value.ToString() : notAvailable)}\n" +
$"Speed: {(location.Speed.HasValue ? location.Speed.Value.ToString() : notAvailable)}\n" +
$"Date (UTC): {location.Timestamp:d}\n" +
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Essentials/Browser/Browser.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static async Task<bool> PlatformOpenAsync(Uri uri, BrowserLaunchOptions options)
await vc.PresentViewControllerAsync(sfViewController, true);
break;
case BrowserLaunchMode.External:
if (Platform.HasOSVersion(12, 0))
if (Platform.HasOSVersion(10, 0))
{
return await UIApplication.SharedApplication.OpenUrlAsync(nativeUrl, new UIApplicationOpenUrlOptions());
}
Expand Down
7 changes: 6 additions & 1 deletion Xamarin.Essentials/Launcher/Launcher.ios.tvos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ static Task<bool> PlatformTryOpenAsync(Uri uri)
var canOpen = UIApplication.SharedApplication.CanOpenUrl(nativeUrl);

if (canOpen)
return UIApplication.SharedApplication.OpenUrlAsync(nativeUrl, new UIApplicationOpenUrlOptions());
{
if (Platform.HasOSVersion(10, 0))
return UIApplication.SharedApplication.OpenUrlAsync(nativeUrl, new UIApplicationOpenUrlOptions());

UIApplication.SharedApplication.OpenUrl(nativeUrl);
}

return Task.FromResult(canOpen);
}
Expand Down
3 changes: 3 additions & 0 deletions Xamarin.Essentials/Types/Location.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public Location(Location point)

public double? Accuracy { get; set; }

public double? VerticalAccuracy { get; set; }

public double? Speed { get; set; }

public double? Course { get; set; }
Expand Down Expand Up @@ -88,6 +90,7 @@ public static double CalculateDistance(
public override string ToString() =>
$"{nameof(Latitude)}: {Latitude}, {nameof(Longitude)}: {Longitude}, " +
$"{nameof(Altitude)}: {Altitude ?? 0}, {nameof(Accuracy)}: {Accuracy ?? 0}, " +
$"{nameof(VerticalAccuracy)}: {VerticalAccuracy ?? 0}, " +
$"{nameof(Speed)}: {Speed ?? 0}, {nameof(Course)}: {Course ?? 0}, " +
$"{nameof(Timestamp)}: {Timestamp}";
}
Expand Down
6 changes: 6 additions & 0 deletions Xamarin.Essentials/Types/LocationExtensions.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ internal static Location ToLocation(this AndroidLocation location) =>
Altitude = location.HasAltitude ? location.Altitude : default(double?),
Timestamp = location.GetTimestamp().ToUniversalTime(),
Accuracy = location.HasAccuracy ? location.Accuracy : default(float?),
VerticalAccuracy =
#if __ANDROID_26__
Platform.HasApiLevelO && location.HasVerticalAccuracy ? location.VerticalAccuracyMeters : default(float?),
#else
default(float?),
#endif
Course = location.HasBearing ? location.Bearing : default(double?),
Speed = location.HasSpeed ? location.Speed : default(double?),
IsFromMockProvider = Platform.HasApiLevel(global::Android.OS.BuildVersionCodes.JellyBeanMr2) ? location.IsFromMockProvider : false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal static Location ToLocation(this CLLocation location) =>
Longitude = location.Coordinate.Longitude,
Altitude = location.VerticalAccuracy < 0 ? default(double?) : location.Altitude,
Accuracy = location.HorizontalAccuracy,
VerticalAccuracy = location.VerticalAccuracy,
Timestamp = location.Timestamp.ToDateTime(),
#if __iOS__ || __WATCHOS__
Course = location.Course < 0 ? default(double?) : location.Course,
Expand Down
2 changes: 2 additions & 0 deletions Xamarin.Essentials/Types/LocationExtensions.uwp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal static Location ToLocation(this Geoposition location) =>
Timestamp = location.Coordinate.Timestamp,
Altitude = location.Coordinate.Point.Position.Altitude,
Accuracy = location.Coordinate.Accuracy,
VerticalAccuracy = location.Coordinate.AltitudeAccuracy,
Speed = (!location.Coordinate.Speed.HasValue || double.IsNaN(location.Coordinate.Speed.Value)) ? default : location.Coordinate.Speed,
Course = (!location.Coordinate.Heading.HasValue || double.IsNaN(location.Coordinate.Heading.Value)) ? default : location.Coordinate.Heading,
IsFromMockProvider = false
Expand All @@ -44,6 +45,7 @@ internal static Location ToLocation(this Geocoordinate coordinate) =>
Timestamp = coordinate.Timestamp,
Altitude = coordinate.Point.Position.Altitude,
Accuracy = coordinate.Accuracy,
VerticalAccuracy = coordinate.AltitudeAccuracy,
Speed = (!coordinate.Speed.HasValue || double.IsNaN(coordinate.Speed.Value)) ? default : coordinate.Speed,
Course = (!coordinate.Heading.HasValue || double.IsNaN(coordinate.Heading.Value)) ? default : coordinate.Heading
};
Expand Down
1 change: 1 addition & 0 deletions docs/en/FrameworksIndex/xamarin-essentials-android.xml
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
<Member Id="P:Xamarin.Essentials.Location.Speed" />
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
</Type>
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />
Expand Down
1 change: 1 addition & 0 deletions docs/en/FrameworksIndex/xamarin-essentials-ios.xml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
<Member Id="P:Xamarin.Essentials.Location.Speed" />
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
</Type>
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />
Expand Down
1 change: 1 addition & 0 deletions docs/en/FrameworksIndex/xamarin-essentials-tvos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
<Member Id="P:Xamarin.Essentials.Location.Speed" />
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
</Type>
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />
Expand Down
1 change: 1 addition & 0 deletions docs/en/FrameworksIndex/xamarin-essentials-uwp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
<Member Id="P:Xamarin.Essentials.Location.Speed" />
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
</Type>
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />
Expand Down
1 change: 1 addition & 0 deletions docs/en/FrameworksIndex/xamarin-essentials-watchos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
<Member Id="P:Xamarin.Essentials.Location.Speed" />
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
</Type>
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />
Expand Down
1 change: 1 addition & 0 deletions docs/en/FrameworksIndex/xamarin-essentials.xml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
<Member Id="P:Xamarin.Essentials.Location.Speed" />
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
</Type>
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />
Expand Down
24 changes: 22 additions & 2 deletions docs/en/Xamarin.Essentials/Location.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
<ReturnType>System.Nullable&lt;System.Double&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the accuracy (in meters) of the location.</summary>
<value>The location accuracy.</value>
<summary>Gets or sets the horizontal accuracy (in meters) of the location.</summary>
<value>The horizontal accuracy of the location.</value>
<remarks>
<para />
</remarks>
Expand Down Expand Up @@ -397,5 +397,25 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="VerticalAccuracy">
<MemberSignature Language="C#" Value="public Nullable&lt;double&gt; VerticalAccuracy { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Nullable`1&lt;float64&gt; VerticalAccuracy" />
<MemberSignature Language="DocId" Value="P:Xamarin.Essentials.Location.VerticalAccuracy" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AssemblyName>Xamarin.Essentials</AssemblyName>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Nullable&lt;System.Double&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the vertical accuracy (in meters) of the location.</summary>
<value>The vertical accuracy of the location.</value>
<remarks>
<para />
</remarks>
</Docs>
</Member>
</Members>
</Type>

0 comments on commit 634e74f

Please sign in to comment.