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

Commit

Permalink
Added bool IsFromMockProvider in Location class
Browse files Browse the repository at this point in the history
  • Loading branch information
pictos committed Jan 7, 2019
1 parent 2c2e6d6 commit e56d940
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 23 deletions.
26 changes: 6 additions & 20 deletions Samples/Samples.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.xamarin.essentials" android:installLocation="auto">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature android:name="android.hardware.location" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature android:name="android.hardware.location.network" android:required="false" />
<application android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/MainTheme"
android:fullBackupContent="@xml/my_backup_rules">

</application>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.xamarin.essentials" android:installLocation="auto" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />
<uses-feature android:name="android.hardware.location" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature android:name="android.hardware.location.network" android:required="false" />
<application android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:fullBackupContent="@xml/my_backup_rules" android:icon="@mipmap/ic_launcher" android:theme="@style/MainTheme"></application>
</manifest>
2 changes: 2 additions & 0 deletions Xamarin.Essentials/Types/Location.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public Location(Location point)

public double? Course { get; set; }

public bool IsFromMockProvider { get; set; }

public static double CalculateDistance(double latitudeStart, double longitudeStart, Location locationEnd, DistanceUnits units) =>
CalculateDistance(latitudeStart, longitudeStart, locationEnd.Latitude, locationEnd.Longitude, units);

Expand Down
3 changes: 2 additions & 1 deletion Xamarin.Essentials/Types/LocationExtensions.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ internal static Location ToLocation(this AndroidLocation location) =>
Timestamp = location.GetTimestamp().ToUniversalTime(),
Accuracy = location.HasAccuracy ? location.Accuracy : default(float?),
Course = location.HasBearing ? location.Bearing : default(double?),
Speed = location.HasSpeed ? location.Speed : default(double?)
Speed = location.HasSpeed ? location.Speed : default(double?),
IsFromMockProvider = !location.IsFromMockProvider
};

static readonly DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
Expand Down
3 changes: 2 additions & 1 deletion Xamarin.Essentials/Types/LocationExtensions.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ internal static Location ToLocation(this CLLocation location) =>
Accuracy = location.HorizontalAccuracy,
Timestamp = location.Timestamp.ToDateTime(),
Course = location.Course < 0 ? default(double?) : location.Course,
Speed = location.Speed < 0 ? default(double?) : location.Speed
Speed = location.Speed < 0 ? default(double?) : location.Speed,
IsFromMockProvider = DeviceInfo.DeviceType == DeviceType.Virtual
};

internal static DateTimeOffset ToDateTime(this NSDate timestamp)
Expand Down
3 changes: 2 additions & 1 deletion Xamarin.Essentials/Types/LocationExtensions.uwp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ internal static Location ToLocation(this Geoposition location) =>
Altitude = location.Coordinate.Point.Position.Altitude,
Accuracy = location.Coordinate.Accuracy,
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
Course = (!location.Coordinate.Heading.HasValue || double.IsNaN(location.Coordinate.Heading.Value)) ? default : location.Coordinate.Heading,
IsFromMockProvider = false
};

internal static Location ToLocation(this Geocoordinate coordinate) =>
Expand Down

0 comments on commit e56d940

Please sign in to comment.