* 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 <janus@gcc.gnu.org>
Co-authored-by: James Montemagno <james.montemagno@gmail.com>
This commit is contained in:
Jonathan Dick 2020-02-26 14:45:08 -05:00 коммит произвёл GitHub
Родитель 5e0b655d3a
Коммит 634e74fefa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 50 добавлений и 6 удалений

2
.gitattributes поставляемый
Просмотреть файл

@ -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

Просмотреть файл

@ -98,8 +98,9 @@ namespace Samples.ViewModel
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" +

Просмотреть файл

@ -31,7 +31,7 @@ namespace Xamarin.Essentials
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());
}

Просмотреть файл

@ -20,7 +20,12 @@ namespace Xamarin.Essentials
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);
}

Просмотреть файл

@ -52,6 +52,8 @@ namespace Xamarin.Essentials
public double? Accuracy { get; set; }
public double? VerticalAccuracy { get; set; }
public double? Speed { get; set; }
public double? Course { get; set; }
@ -88,6 +90,7 @@ namespace Xamarin.Essentials
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}";
}

Просмотреть файл

@ -28,6 +28,12 @@ namespace Xamarin.Essentials
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

Просмотреть файл

@ -27,6 +27,7 @@ namespace Xamarin.Essentials
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,

Просмотреть файл

@ -31,6 +31,7 @@ namespace Xamarin.Essentials
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
@ -44,6 +45,7 @@ namespace Xamarin.Essentials
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
};

Просмотреть файл

@ -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)" />

Просмотреть файл

@ -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)" />

Просмотреть файл

@ -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)" />

Просмотреть файл

@ -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)" />

Просмотреть файл

@ -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)" />

Просмотреть файл

@ -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)" />

Просмотреть файл

@ -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>
@ -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>