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

Commit 634e74f

Browse files
Redthjanuswjamesmontemagno
authored
1.5.0 Changes (#1124)
* 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]>
1 parent 5e0b655 commit 634e74f

15 files changed

+50
-6
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# default for csharp files.
1111
# Note: This is only used by command line
1212
###############################################################################
13-
#*.cs diff=csharp
13+
*.cs diff=csharp
1414

1515
###############################################################################
1616
# Set the merge driver for project and solution files

Samples/Samples/ViewModel/GeolocationViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ string FormatLocation(Location location, Exception ex = null)
9898
return
9999
$"Latitude: {location.Latitude}\n" +
100100
$"Longitude: {location.Longitude}\n" +
101-
$"Accuracy: {location.Accuracy}\n" +
101+
$"HorizontalAccuracy: {location.Accuracy}\n" +
102102
$"Altitude: {(location.Altitude.HasValue ? location.Altitude.Value.ToString() : notAvailable)}\n" +
103+
$"VerticalAccuracy: {(location.VerticalAccuracy.HasValue ? location.VerticalAccuracy.Value.ToString() : notAvailable)}\n" +
103104
$"Heading: {(location.Course.HasValue ? location.Course.Value.ToString() : notAvailable)}\n" +
104105
$"Speed: {(location.Speed.HasValue ? location.Speed.Value.ToString() : notAvailable)}\n" +
105106
$"Date (UTC): {location.Timestamp:d}\n" +

Xamarin.Essentials/Browser/Browser.ios.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static async Task<bool> PlatformOpenAsync(Uri uri, BrowserLaunchOptions options)
3131
await vc.PresentViewControllerAsync(sfViewController, true);
3232
break;
3333
case BrowserLaunchMode.External:
34-
if (Platform.HasOSVersion(12, 0))
34+
if (Platform.HasOSVersion(10, 0))
3535
{
3636
return await UIApplication.SharedApplication.OpenUrlAsync(nativeUrl, new UIApplicationOpenUrlOptions());
3737
}

Xamarin.Essentials/Launcher/Launcher.ios.tvos.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ static Task<bool> PlatformTryOpenAsync(Uri uri)
2020
var canOpen = UIApplication.SharedApplication.CanOpenUrl(nativeUrl);
2121

2222
if (canOpen)
23-
return UIApplication.SharedApplication.OpenUrlAsync(nativeUrl, new UIApplicationOpenUrlOptions());
23+
{
24+
if (Platform.HasOSVersion(10, 0))
25+
return UIApplication.SharedApplication.OpenUrlAsync(nativeUrl, new UIApplicationOpenUrlOptions());
26+
27+
UIApplication.SharedApplication.OpenUrl(nativeUrl);
28+
}
2429

2530
return Task.FromResult(canOpen);
2631
}

Xamarin.Essentials/Types/Location.shared.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public Location(Location point)
5252

5353
public double? Accuracy { get; set; }
5454

55+
public double? VerticalAccuracy { get; set; }
56+
5557
public double? Speed { get; set; }
5658

5759
public double? Course { get; set; }
@@ -88,6 +90,7 @@ public static double CalculateDistance(
8890
public override string ToString() =>
8991
$"{nameof(Latitude)}: {Latitude}, {nameof(Longitude)}: {Longitude}, " +
9092
$"{nameof(Altitude)}: {Altitude ?? 0}, {nameof(Accuracy)}: {Accuracy ?? 0}, " +
93+
$"{nameof(VerticalAccuracy)}: {VerticalAccuracy ?? 0}, " +
9194
$"{nameof(Speed)}: {Speed ?? 0}, {nameof(Course)}: {Course ?? 0}, " +
9295
$"{nameof(Timestamp)}: {Timestamp}";
9396
}

Xamarin.Essentials/Types/LocationExtensions.android.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ internal static Location ToLocation(this AndroidLocation location) =>
2828
Altitude = location.HasAltitude ? location.Altitude : default(double?),
2929
Timestamp = location.GetTimestamp().ToUniversalTime(),
3030
Accuracy = location.HasAccuracy ? location.Accuracy : default(float?),
31+
VerticalAccuracy =
32+
#if __ANDROID_26__
33+
Platform.HasApiLevelO && location.HasVerticalAccuracy ? location.VerticalAccuracyMeters : default(float?),
34+
#else
35+
default(float?),
36+
#endif
3137
Course = location.HasBearing ? location.Bearing : default(double?),
3238
Speed = location.HasSpeed ? location.Speed : default(double?),
3339
IsFromMockProvider = Platform.HasApiLevel(global::Android.OS.BuildVersionCodes.JellyBeanMr2) ? location.IsFromMockProvider : false

Xamarin.Essentials/Types/LocationExtensions.ios.tvos.watchos.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ internal static Location ToLocation(this CLLocation location) =>
2727
Longitude = location.Coordinate.Longitude,
2828
Altitude = location.VerticalAccuracy < 0 ? default(double?) : location.Altitude,
2929
Accuracy = location.HorizontalAccuracy,
30+
VerticalAccuracy = location.VerticalAccuracy,
3031
Timestamp = location.Timestamp.ToDateTime(),
3132
#if __iOS__ || __WATCHOS__
3233
Course = location.Course < 0 ? default(double?) : location.Course,

Xamarin.Essentials/Types/LocationExtensions.uwp.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ internal static Location ToLocation(this Geoposition location) =>
3131
Timestamp = location.Coordinate.Timestamp,
3232
Altitude = location.Coordinate.Point.Position.Altitude,
3333
Accuracy = location.Coordinate.Accuracy,
34+
VerticalAccuracy = location.Coordinate.AltitudeAccuracy,
3435
Speed = (!location.Coordinate.Speed.HasValue || double.IsNaN(location.Coordinate.Speed.Value)) ? default : location.Coordinate.Speed,
3536
Course = (!location.Coordinate.Heading.HasValue || double.IsNaN(location.Coordinate.Heading.Value)) ? default : location.Coordinate.Heading,
3637
IsFromMockProvider = false
@@ -44,6 +45,7 @@ internal static Location ToLocation(this Geocoordinate coordinate) =>
4445
Timestamp = coordinate.Timestamp,
4546
Altitude = coordinate.Point.Position.Altitude,
4647
Accuracy = coordinate.Accuracy,
48+
VerticalAccuracy = coordinate.AltitudeAccuracy,
4749
Speed = (!coordinate.Speed.HasValue || double.IsNaN(coordinate.Speed.Value)) ? default : coordinate.Speed,
4850
Course = (!coordinate.Heading.HasValue || double.IsNaN(coordinate.Heading.Value)) ? default : coordinate.Heading
4951
};

docs/en/FrameworksIndex/xamarin-essentials-android.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@
437437
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
438438
<Member Id="P:Xamarin.Essentials.Location.Speed" />
439439
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
440+
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
440441
</Type>
441442
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
442443
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />

docs/en/FrameworksIndex/xamarin-essentials-ios.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@
416416
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
417417
<Member Id="P:Xamarin.Essentials.Location.Speed" />
418418
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
419+
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
419420
</Type>
420421
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
421422
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />

docs/en/FrameworksIndex/xamarin-essentials-tvos.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@
415415
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
416416
<Member Id="P:Xamarin.Essentials.Location.Speed" />
417417
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
418+
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
418419
</Type>
419420
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
420421
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />

docs/en/FrameworksIndex/xamarin-essentials-uwp.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@
415415
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
416416
<Member Id="P:Xamarin.Essentials.Location.Speed" />
417417
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
418+
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
418419
</Type>
419420
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
420421
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />

docs/en/FrameworksIndex/xamarin-essentials-watchos.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@
415415
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
416416
<Member Id="P:Xamarin.Essentials.Location.Speed" />
417417
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
418+
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
418419
</Type>
419420
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
420421
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />

docs/en/FrameworksIndex/xamarin-essentials.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@
414414
<Member Id="P:Xamarin.Essentials.Location.Longitude" />
415415
<Member Id="P:Xamarin.Essentials.Location.Speed" />
416416
<Member Id="P:Xamarin.Essentials.Location.Timestamp" />
417+
<Member Id="P:Xamarin.Essentials.Location.VerticalAccuracy" />
417418
</Type>
418419
<Type Name="Xamarin.Essentials.LocationExtensions" Id="T:Xamarin.Essentials.LocationExtensions">
419420
<Member Id="M:Xamarin.Essentials.LocationExtensions.CalculateDistance(Xamarin.Essentials.Location,System.Double,System.Double,Xamarin.Essentials.DistanceUnits)" />

docs/en/Xamarin.Essentials/Location.xml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@
113113
<ReturnType>System.Nullable&lt;System.Double&gt;</ReturnType>
114114
</ReturnValue>
115115
<Docs>
116-
<summary>Gets or sets the accuracy (in meters) of the location.</summary>
117-
<value>The location accuracy.</value>
116+
<summary>Gets or sets the horizontal accuracy (in meters) of the location.</summary>
117+
<value>The horizontal accuracy of the location.</value>
118118
<remarks>
119119
<para />
120120
</remarks>
@@ -397,5 +397,25 @@
397397
<remarks>To be added.</remarks>
398398
</Docs>
399399
</Member>
400+
<Member MemberName="VerticalAccuracy">
401+
<MemberSignature Language="C#" Value="public Nullable&lt;double&gt; VerticalAccuracy { get; set; }" />
402+
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Nullable`1&lt;float64&gt; VerticalAccuracy" />
403+
<MemberSignature Language="DocId" Value="P:Xamarin.Essentials.Location.VerticalAccuracy" />
404+
<MemberType>Property</MemberType>
405+
<AssemblyInfo>
406+
<AssemblyVersion>1.0.0.0</AssemblyVersion>
407+
<AssemblyName>Xamarin.Essentials</AssemblyName>
408+
</AssemblyInfo>
409+
<ReturnValue>
410+
<ReturnType>System.Nullable&lt;System.Double&gt;</ReturnType>
411+
</ReturnValue>
412+
<Docs>
413+
<summary>Gets or sets the vertical accuracy (in meters) of the location.</summary>
414+
<value>The vertical accuracy of the location.</value>
415+
<remarks>
416+
<para />
417+
</remarks>
418+
</Docs>
419+
</Member>
400420
</Members>
401421
</Type>

0 commit comments

Comments
 (0)