Merge pull request #459 from xamarin/feature/issue-348

GH-348: Add Barometer Sensor API
This commit is contained in:
Matthew Leibowitz 2018-08-15 17:08:25 +02:00 коммит произвёл GitHub
Родитель 9d81a761cd d39b08cc23
Коммит fee59d67fd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
30 изменённых файлов: 1007 добавлений и 55 удалений

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

@ -0,0 +1,84 @@
using System.Threading.Tasks;
using Xamarin.Essentials;
using Xunit;
namespace DeviceTests
{
public class Barometer_Tests
{
[Fact]
public void IsSupported()
=> Assert.Equal(HardwareSupport.HasBarometer, Barometer.IsSupported);
[Fact]
[Trait(Traits.Hardware.Barometer, Traits.FeatureSupport.Supported)]
public async Task Monitor()
{
// TODO: the test runner app (UI version) should do this, until then...
if (!HardwareSupport.HasBarometer)
return;
var tcs = new TaskCompletionSource<BarometerData>();
Barometer.ReadingChanged += Barometer_ReadingChanged;
void Barometer_ReadingChanged(object sender, BarometerChangedEventArgs e)
{
tcs.TrySetResult(e.Reading);
}
Barometer.Start(SensorSpeed.UI);
var d = await tcs.Task;
Assert.True(d.Pressure >= 0);
Barometer.Stop();
Barometer.ReadingChanged -= Barometer_ReadingChanged;
}
[Fact]
[Trait(Traits.Hardware.Barometer, Traits.FeatureSupport.Supported)]
public async Task IsMonitoring()
{
// TODO: the test runner app (UI version) should do this, until then...
if (!HardwareSupport.HasBarometer)
return;
var tcs = new TaskCompletionSource<BarometerData>();
Barometer.ReadingChanged += Barometer_ReadingChanged;
void Barometer_ReadingChanged(object sender, BarometerChangedEventArgs e)
{
tcs.TrySetResult(e.Reading);
}
Barometer.Start(SensorSpeed.UI);
var d = await tcs.Task;
Assert.True(Barometer.IsMonitoring);
Barometer.Stop();
Barometer.ReadingChanged -= Barometer_ReadingChanged;
}
[Fact]
[Trait(Traits.Hardware.Barometer, Traits.FeatureSupport.Supported)]
public async Task Stop_Monitor()
{
// TODO: the test runner app (UI version) should do this, until then...
if (!HardwareSupport.HasBarometer)
return;
var tcs = new TaskCompletionSource<BarometerData>();
Barometer.ReadingChanged += Barometer_ReadingChanged;
void Barometer_ReadingChanged(object sender, BarometerChangedEventArgs e)
{
tcs.TrySetResult(e.Reading);
}
Barometer.Start(SensorSpeed.UI);
var d = await tcs.Task;
Barometer.Stop();
Barometer.ReadingChanged -= Barometer_ReadingChanged;
Assert.False(Barometer.IsMonitoring);
}
}
}

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

@ -74,5 +74,16 @@
// TODO: most UWP devices don't have a camera lamp (mobile devices do, we we don't care about those)
false;
#endif
public static bool HasBarometer =>
#if __ANDROID__
true;
#elif __IOS__
// iphone 6 and never have a barometer. looking in how to test this.
Xamarin.Essentials.DeviceInfo.DeviceType == Xamarin.Essentials.DeviceType.Physical;
#elif WINDOWS_UWP
// TODO: most UWP devices don't have a barometer (mobile devices do, we we don't care about those)
false;
#endif
}
}

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

@ -14,6 +14,7 @@ namespace DeviceTests
internal static class Hardware
{
public const string Accelerometer = "HardwareAccelerometer";
public const string Barometer = "HardwareBarometer";
public const string Compass = "HardwareCompass";
public const string Gyroscope = "HardwareGyroscope";
public const string Magnetometer = "HardwareMagnetometer";

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

@ -176,6 +176,29 @@
<Button Grid.Row="5" Grid.Column="1" Text="Stop" Command="{Binding StopCommand}"
IsEnabled="{Binding IsActive}" />
</Grid>
<Label Text="Monitor barometer for changes." FontAttributes="Bold" Margin="12" />
<Grid x:Name="GridBarometer">
<Grid.BindingContext>
<viewmodels:BarometerViewModel />
</Grid.BindingContext>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.ColumnSpan="2"
Text="{Binding BaromterValue, StringFormat='Barometer pressure (hPA): {0:N}'}" />
<Button Grid.Row="1" Grid.Column="0" Text="Start" Command="{Binding StartBarometerComand}"
IsEnabled="{Binding BarometerIsActive, Converter={StaticResource NegativeConverter}}" />
<Button Grid.Row="1" Grid.Column="1" Text="Stop" Command="{Binding StopBarometerCommand}"
IsEnabled="{Binding BarometerIsActive}" />
</Grid>
</StackLayout>
</ScrollView>
</StackLayout>

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

@ -20,6 +20,7 @@ namespace Samples.View
SetupBinding(GridGyro.BindingContext);
SetupBinding(GridMagnetometer.BindingContext);
SetupBinding(GridOrientation.BindingContext);
SetupBinding(GridBarometer.BindingContext);
}
protected override void OnDisappearing()
@ -29,7 +30,7 @@ namespace Samples.View
TearDownBinding(GridGyro.BindingContext);
TearDownBinding(GridMagnetometer.BindingContext);
TearDownBinding(GridOrientation.BindingContext);
TearDownBinding(GridBarometer.BindingContext);
base.OnDisappearing();
}
}

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

@ -0,0 +1,48 @@
<views:BasePage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Samples.View"
xmlns:viewmodels="clr-namespace:Samples.ViewModel"
x:Class="Samples.View.BarometerPage"
Title="Barometer">
<views:BasePage.BindingContext>
<viewmodels:BarometerViewModel />
</views:BasePage.BindingContext>
<StackLayout>
<Label Text="Monitor barometer for changes." FontAttributes="Bold" Margin="12" />
<ScrollView>
<Grid Padding="12,0,12,12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.ColumnSpan="2"
Text="{Binding Pressure, StringFormat='Barometer pressure (hPA): {0:N}'}" />
<Label Grid.Row="1" Grid.ColumnSpan="2" Text="Speed:" />
<Picker Grid.Row="2" Grid.ColumnSpan="2" HorizontalOptions="FillAndExpand"
ItemsSource="{Binding Speeds}"
SelectedIndex="{Binding Speed, Mode=TwoWay}"
IsEnabled="{Binding IsActive, Converter={StaticResource NegativeConverter}}"
Margin="0,0,0,10"/>
<Button Grid.Row="3" Grid.Column="0" Text="Start" Command="{Binding StartCommand}"
IsEnabled="{Binding IsActive, Converter={StaticResource NegativeConverter}}" />
<Button Grid.Row="3" Grid.Column="1" Text="Stop" Command="{Binding StopCommand}"
IsEnabled="{Binding IsActive}" />
</Grid>
</ScrollView>
</StackLayout>
</views:BasePage>

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

@ -0,0 +1,13 @@
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Samples.View
{
public partial class BarometerPage : BasePage
{
public BarometerPage()
{
InitializeComponent();
}
}
}

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

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Windows.Input;
using Xamarin.Essentials;
using Xamarin.Forms;
namespace Samples.ViewModel
{
public class BarometerViewModel : BaseViewModel
{
bool isActive;
double pressure;
int speed = 2;
public BarometerViewModel()
{
StartCommand = new Command(OnStartBarometer);
StopCommand = new Command(OnStop);
}
public ICommand StartCommand { get; }
public ICommand StopCommand { get; }
public bool IsActive
{
get => isActive;
set => SetProperty(ref isActive, value);
}
public double Pressure
{
get => pressure;
set => SetProperty(ref pressure, value);
}
public List<string> Speeds { get; } =
new List<string>
{
"Fastest",
"Game",
"Normal",
"User Interface"
};
public int Speed
{
get => speed;
set => SetProperty(ref speed, value);
}
public override void OnAppearing()
{
Barometer.ReadingChanged += OnBarometerReadingChanged;
base.OnAppearing();
}
public override void OnDisappearing()
{
OnStop();
Barometer.ReadingChanged -= OnBarometerReadingChanged;
base.OnDisappearing();
}
async void OnStartBarometer()
{
try
{
Barometer.Start((SensorSpeed)Speed);
IsActive = true;
}
catch (Exception ex)
{
await DisplayAlertAsync($"Unable to start barometer: {ex.Message}");
}
}
void OnBarometerReadingChanged(object sender, BarometerChangedEventArgs e)
{
Pressure = e.Reading.Pressure;
}
void OnStop()
{
IsActive = false;
Barometer.Stop();
Barometer.ReadingChanged -= OnBarometerReadingChanged;
}
}
}

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

@ -102,9 +102,8 @@ namespace Samples.ViewModel
if (Compass.IsMonitoring)
OnStopCompass2();
Compass.ReadingChanged += OnCompass1ReadingChanged;
Compass.Start((SensorSpeed)Speed1);
Compass.ReadingChanged += OnCompass1ReadingChanged;
Compass1IsActive = true;
}
catch (Exception ex)
@ -141,8 +140,8 @@ namespace Samples.ViewModel
if (Compass.IsMonitoring)
OnStopCompass1();
Compass.ReadingChanged += OnCompass2ReadingChanged;
Compass.Start((SensorSpeed)Speed2);
Compass.ReadingChanged += OnCompass2ReadingChanged;
Compass2IsActive = true;
}
catch (Exception ex)

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

@ -28,14 +28,20 @@ namespace Samples.ViewModel
"📏",
"All Sensors",
typeof(AllSensorsPage),
"Have a look at the accelerometer, compass, gyroscope, magnetometer, and orientation sensors.",
new[] { "accelerometer", "compass", "gyroscope", "magnetometer", "orientation", "sensors", "hardware", "device" }),
"Have a look at the accelerometer, barometer, compass, gyroscope, magnetometer, and orientation sensors.",
new[] { "accelerometer", "barometer", "compass", "gyroscope", "magnetometer", "orientation", "sensors", "hardware", "device" }),
new SampleItem(
"📦",
"App Info",
typeof(AppInfoPage),
"Find out about the app with ease.",
new[] { "app", "info" }),
new SampleItem(
"📏",
"Barometer",
typeof(BarometerPage),
"Easily detect pressure level, via the device barometer.",
new[] { "barometer", "hardware", "device", "sensor" }),
new SampleItem(
"🔋",
"Battery",

51
Tests/Barometer_Tests.cs Normal file
Просмотреть файл

@ -0,0 +1,51 @@
using System;
using Xamarin.Essentials;
using Xunit;
namespace Tests
{
public class Barometer_Tests
{
[Fact]
public void IsSupported_On_NetStandard() =>
Assert.Throws<NotImplementedInReferenceAssemblyException>(() => Barometer.IsSupported);
[Fact]
public void Monitor_On_NetStandard() =>
Assert.Throws<NotImplementedInReferenceAssemblyException>(() => Barometer.Start(SensorSpeed.UI));
[Fact]
public void Monitor_Off_NetStandard() =>
Assert.Throws<NotImplementedInReferenceAssemblyException>(() => Barometer.Stop());
[Fact]
public void IsMonitoring_Default_On_NetStandard() =>
Assert.False(Barometer.IsMonitoring);
[Fact]
public void BarometerData_Comparison_Equal()
{
var device1 = new BarometerData(0);
var device2 = new BarometerData(0);
Assert.True(device1.Equals(device2));
Assert.True(device1 == device2);
Assert.False(device1 != device2);
Assert.Equal(device1, device2);
Assert.Equal(device1.GetHashCode(), device2.GetHashCode());
}
[Fact]
public void BarometerData_Comparison_NotEqual()
{
var device1 = new BarometerData(0);
var device2 = new BarometerData(1);
Assert.False(device1.Equals(device2));
Assert.False(device1 == device2);
Assert.True(device1 != device2);
Assert.NotEqual(device1, device2);
Assert.NotEqual(device1.GetHashCode(), device2.GetHashCode());
}
}
}

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

@ -54,19 +54,15 @@ namespace Xamarin.Essentials
}
}
internal static void OnChanged(AccelerometerData reading)
=> OnChanged(new AccelerometerChangedEventArgs(reading));
internal static void OnChanged(AccelerometerData reading) =>
OnChanged(new AccelerometerChangedEventArgs(reading));
internal static void OnChanged(AccelerometerChangedEventArgs e)
{
var handler = ReadingChanged;
if (handler == null)
return;
if (useSyncContext)
MainThread.BeginInvokeOnMainThread(() => handler?.Invoke(null, e));
MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(null, e));
else
handler?.Invoke(null, e);
ReadingChanged?.Invoke(null, e);
}
}

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

@ -0,0 +1,45 @@
using System;
using Android.Hardware;
using Android.Runtime;
namespace Xamarin.Essentials
{
public static partial class Barometer
{
internal static bool IsSupported =>
DefaultBarometer != null;
static Sensor DefaultBarometer => Platform.SensorManager?.GetDefaultSensor(SensorType.Pressure);
static Sensor barometer;
static BarometerListener listener;
static void PlatformStart(SensorSpeed sensorSpeed)
{
listener = new BarometerListener();
barometer = DefaultBarometer;
Platform.SensorManager.RegisterListener(listener, barometer, sensorSpeed.ToPlatform());
}
static void PlatformStop()
{
if (listener == null)
return;
Platform.SensorManager.UnregisterListener(listener, barometer);
listener.Dispose();
listener = null;
}
}
class BarometerListener : Java.Lang.Object, ISensorEventListener, IDisposable
{
void ISensorEventListener.OnAccuracyChanged(Sensor sensor, [GeneratedEnum] SensorStatus accuracy)
{
}
void ISensorEventListener.OnSensorChanged(SensorEvent e)
=> Barometer.OnChanged(new BarometerData(e.Values[0]));
}
}

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

@ -0,0 +1,32 @@
using CoreMotion;
using Foundation;
namespace Xamarin.Essentials
{
public static partial class Barometer
{
internal static bool IsSupported =>
CMAltimeter.IsRelativeAltitudeAvailable;
static CMAltimeter altitudeManager;
static void PlatformStart(SensorSpeed sensorSpeed)
{
altitudeManager = new CMAltimeter();
altitudeManager.StartRelativeAltitudeUpdates(Platform.GetCurrentQueue(), LocationManagerUpdatedHeading);
// Heading updates Convert to HectoPascal from KiloPascal
void LocationManagerUpdatedHeading(CMAltitudeData e, NSError error) =>
OnChanged(new BarometerData(e.Pressure.DoubleValue / 10d));
}
static void PlatformStop()
{
if (altitudeManager == null)
return;
altitudeManager.StopRelativeAltitudeUpdates();
altitudeManager.Dispose();
altitudeManager = null;
}
}
}

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

@ -0,0 +1,14 @@
namespace Xamarin.Essentials
{
public static partial class Barometer
{
internal static bool IsSupported =>
throw new NotImplementedInReferenceAssemblyException();
internal static void PlatformStart(SensorSpeed sensorSpeed) =>
throw new NotImplementedInReferenceAssemblyException();
internal static void PlatformStop() =>
throw new NotImplementedInReferenceAssemblyException();
}
}

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

@ -0,0 +1,106 @@
using System;
namespace Xamarin.Essentials
{
public static partial class Barometer
{
static bool useSyncContext;
public static event EventHandler<BarometerChangedEventArgs> ReadingChanged;
public static bool IsMonitoring { get; private set; }
public static void Start(SensorSpeed sensorSpeed)
{
if (!IsSupported)
throw new FeatureNotSupportedException();
if (IsMonitoring)
return;
IsMonitoring = true;
useSyncContext = sensorSpeed == SensorSpeed.Normal || sensorSpeed == SensorSpeed.UI;
try
{
PlatformStart(sensorSpeed);
}
catch
{
IsMonitoring = false;
throw;
}
}
public static void Stop()
{
if (!IsSupported)
throw new FeatureNotSupportedException();
if (!IsMonitoring)
return;
IsMonitoring = false;
try
{
PlatformStop();
}
catch
{
IsMonitoring = true;
throw;
}
}
internal static void OnChanged(BarometerData reading) =>
OnChanged(new BarometerChangedEventArgs(reading));
static void OnChanged(BarometerChangedEventArgs e)
{
if (useSyncContext)
MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(null, e));
else
ReadingChanged?.Invoke(null, e);
}
}
public class BarometerChangedEventArgs : EventArgs
{
internal BarometerChangedEventArgs(BarometerData reading) =>
Reading = reading;
public BarometerData Reading { get; }
}
public readonly struct BarometerData : IEquatable<BarometerData>
{
internal BarometerData(double pressure) =>
Pressure = pressure;
public double Pressure { get; }
public static bool operator ==(BarometerData left, BarometerData right) =>
Equals(left, right);
public static bool operator !=(BarometerData left, BarometerData right) =>
!Equals(left, right);
public override bool Equals(object obj)
{
if (obj == null)
return false;
if (!(obj is BarometerData barometerData))
return false;
return Equals(barometerData);
}
public bool Equals(BarometerData other) =>
Pressure.Equals(other.Pressure);
public override int GetHashCode() =>
Pressure.GetHashCode();
}
}

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

@ -0,0 +1,36 @@
using System;
using Windows.Devices.Sensors;
using WinBarometer = Windows.Devices.Sensors.Barometer;
namespace Xamarin.Essentials
{
public static partial class Barometer
{
static WinBarometer sensor;
static WinBarometer DefaultBarometer => WinBarometer.GetDefault();
internal static bool IsSupported =>
DefaultBarometer != null;
static void PlatformStart(SensorSpeed sensorSpeed)
{
sensor = DefaultBarometer;
var interval = sensorSpeed.ToPlatform();
sensor.ReportInterval = sensor.MinimumReportInterval >= interval ? sensor.MinimumReportInterval : interval;
sensor.ReadingChanged += BarometerReportedInterval;
}
static void BarometerReportedInterval(object sender, BarometerReadingChangedEventArgs e)
=> OnChanged(new BarometerData(e.Reading.StationPressureInHectopascals));
static void PlatformStop()
{
sensor.ReadingChanged -= BarometerReportedInterval;
sensor.ReportInterval = 0;
sensor = null;
}
}
}

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

@ -55,25 +55,22 @@ namespace Xamarin.Essentials
}
}
internal static void OnChanged(CompassData reading)
=> OnChanged(new CompassChangedEventArgs(reading));
internal static void OnChanged(CompassData reading) =>
OnChanged(new CompassChangedEventArgs(reading));
internal static void OnChanged(CompassChangedEventArgs e)
{
var handler = ReadingChanged;
if (handler == null)
return;
if (useSyncContext)
MainThread.BeginInvokeOnMainThread(() => handler?.Invoke(null, e));
MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(null, e));
else
handler?.Invoke(null, e);
ReadingChanged?.Invoke(null, e);
}
}
public class CompassChangedEventArgs : EventArgs
{
internal CompassChangedEventArgs(CompassData reading) => Reading = reading;
internal CompassChangedEventArgs(CompassData reading) =>
Reading = reading;
public CompassData Reading { get; }
}

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

@ -54,25 +54,22 @@ namespace Xamarin.Essentials
}
}
internal static void OnChanged(GyroscopeData reading)
=> OnChanged(new GyroscopeChangedEventArgs(reading));
internal static void OnChanged(GyroscopeData reading) =>
OnChanged(new GyroscopeChangedEventArgs(reading));
internal static void OnChanged(GyroscopeChangedEventArgs e)
{
var handler = ReadingChanged;
if (handler == null)
return;
if (useSyncContext)
MainThread.BeginInvokeOnMainThread(() => handler?.Invoke(null, e));
MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(null, e));
else
handler?.Invoke(null, e);
ReadingChanged?.Invoke(null, e);
}
}
public class GyroscopeChangedEventArgs : EventArgs
{
internal GyroscopeChangedEventArgs(GyroscopeData reading) => Reading = reading;
internal GyroscopeChangedEventArgs(GyroscopeData reading) =>
Reading = reading;
public GyroscopeData Reading { get; }
}

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

@ -54,25 +54,22 @@ namespace Xamarin.Essentials
}
}
internal static void OnChanged(MagnetometerData reading)
=> OnChanged(new MagnetometerChangedEventArgs(reading));
internal static void OnChanged(MagnetometerData reading) =>
OnChanged(new MagnetometerChangedEventArgs(reading));
internal static void OnChanged(MagnetometerChangedEventArgs e)
{
var handler = ReadingChanged;
if (handler == null)
return;
if (useSyncContext)
MainThread.BeginInvokeOnMainThread(() => handler?.Invoke(null, e));
MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(null, e));
else
handler?.Invoke(null, e);
ReadingChanged?.Invoke(null, e);
}
}
public class MagnetometerChangedEventArgs : EventArgs
{
internal MagnetometerChangedEventArgs(MagnetometerData reading) => Reading = reading;
internal MagnetometerChangedEventArgs(MagnetometerData reading) =>
Reading = reading;
public MagnetometerData Reading { get; }
}

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

@ -54,25 +54,22 @@ namespace Xamarin.Essentials
}
}
internal static void OnChanged(OrientationSensorData reading)
=> OnChanged(new OrientationSensorChangedEventArgs(reading));
internal static void OnChanged(OrientationSensorData reading) =>
OnChanged(new OrientationSensorChangedEventArgs(reading));
internal static void OnChanged(OrientationSensorChangedEventArgs e)
{
var handler = ReadingChanged;
if (handler == null)
return;
if (useSyncContext)
MainThread.BeginInvokeOnMainThread(() => handler?.Invoke(null, e));
MainThread.BeginInvokeOnMainThread(() => ReadingChanged?.Invoke(null, e));
else
handler?.Invoke(null, e);
ReadingChanged?.Invoke(null, e);
}
}
public class OrientationSensorChangedEventArgs : EventArgs
{
internal OrientationSensorChangedEventArgs(OrientationSensorData reading) => Reading = reading;
internal OrientationSensorChangedEventArgs(OrientationSensorData reading) =>
Reading = reading;
public OrientationSensorData Reading { get; }
}
@ -84,10 +81,8 @@ namespace Xamarin.Essentials
{
}
internal OrientationSensorData(float x, float y, float z, float w)
{
internal OrientationSensorData(float x, float y, float z, float w) =>
Orientation = new Quaternion(x, y, z, w);
}
public Quaternion Orientation { get; }
}

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

@ -20,6 +20,23 @@
<Member Id="P:Xamarin.Essentials.AppInfo.Version" />
<Member Id="P:Xamarin.Essentials.AppInfo.VersionString" />
</Type>
<Type Name="Xamarin.Essentials.Barometer" Id="T:Xamarin.Essentials.Barometer">
<Member Id="E:Xamarin.Essentials.Barometer.ReadingChanged" />
<Member Id="M:Xamarin.Essentials.Barometer.Start(Xamarin.Essentials.SensorSpeed)" />
<Member Id="M:Xamarin.Essentials.Barometer.Stop" />
<Member Id="P:Xamarin.Essentials.Barometer.IsMonitoring" />
</Type>
<Type Name="Xamarin.Essentials.BarometerChangedEventArgs" Id="T:Xamarin.Essentials.BarometerChangedEventArgs">
<Member Id="P:Xamarin.Essentials.BarometerChangedEventArgs.Reading" />
</Type>
<Type Name="Xamarin.Essentials.BarometerData" Id="T:Xamarin.Essentials.BarometerData">
<Member Id="M:Xamarin.Essentials.BarometerData.Equals(System.Object)" />
<Member Id="M:Xamarin.Essentials.BarometerData.Equals(Xamarin.Essentials.BarometerData)" />
<Member Id="M:Xamarin.Essentials.BarometerData.GetHashCode" />
<Member Id="M:Xamarin.Essentials.BarometerData.op_Equality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<Member Id="M:Xamarin.Essentials.BarometerData.op_Inequality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<Member Id="P:Xamarin.Essentials.BarometerData.Pressure" />
</Type>
<Type Name="Xamarin.Essentials.Battery" Id="T:Xamarin.Essentials.Battery">
<Member Id="E:Xamarin.Essentials.Battery.BatteryChanged" />
<Member Id="P:Xamarin.Essentials.Battery.ChargeLevel" />

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

@ -20,6 +20,23 @@
<Member Id="P:Xamarin.Essentials.AppInfo.Version" />
<Member Id="P:Xamarin.Essentials.AppInfo.VersionString" />
</Type>
<Type Name="Xamarin.Essentials.Barometer" Id="T:Xamarin.Essentials.Barometer">
<Member Id="E:Xamarin.Essentials.Barometer.ReadingChanged" />
<Member Id="M:Xamarin.Essentials.Barometer.Start(Xamarin.Essentials.SensorSpeed)" />
<Member Id="M:Xamarin.Essentials.Barometer.Stop" />
<Member Id="P:Xamarin.Essentials.Barometer.IsMonitoring" />
</Type>
<Type Name="Xamarin.Essentials.BarometerChangedEventArgs" Id="T:Xamarin.Essentials.BarometerChangedEventArgs">
<Member Id="P:Xamarin.Essentials.BarometerChangedEventArgs.Reading" />
</Type>
<Type Name="Xamarin.Essentials.BarometerData" Id="T:Xamarin.Essentials.BarometerData">
<Member Id="M:Xamarin.Essentials.BarometerData.Equals(System.Object)" />
<Member Id="M:Xamarin.Essentials.BarometerData.Equals(Xamarin.Essentials.BarometerData)" />
<Member Id="M:Xamarin.Essentials.BarometerData.GetHashCode" />
<Member Id="M:Xamarin.Essentials.BarometerData.op_Equality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<Member Id="M:Xamarin.Essentials.BarometerData.op_Inequality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<Member Id="P:Xamarin.Essentials.BarometerData.Pressure" />
</Type>
<Type Name="Xamarin.Essentials.Battery" Id="T:Xamarin.Essentials.Battery">
<Member Id="E:Xamarin.Essentials.Battery.BatteryChanged" />
<Member Id="P:Xamarin.Essentials.Battery.ChargeLevel" />

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

@ -20,6 +20,23 @@
<Member Id="P:Xamarin.Essentials.AppInfo.Version" />
<Member Id="P:Xamarin.Essentials.AppInfo.VersionString" />
</Type>
<Type Name="Xamarin.Essentials.Barometer" Id="T:Xamarin.Essentials.Barometer">
<Member Id="E:Xamarin.Essentials.Barometer.ReadingChanged" />
<Member Id="M:Xamarin.Essentials.Barometer.Start(Xamarin.Essentials.SensorSpeed)" />
<Member Id="M:Xamarin.Essentials.Barometer.Stop" />
<Member Id="P:Xamarin.Essentials.Barometer.IsMonitoring" />
</Type>
<Type Name="Xamarin.Essentials.BarometerChangedEventArgs" Id="T:Xamarin.Essentials.BarometerChangedEventArgs">
<Member Id="P:Xamarin.Essentials.BarometerChangedEventArgs.Reading" />
</Type>
<Type Name="Xamarin.Essentials.BarometerData" Id="T:Xamarin.Essentials.BarometerData">
<Member Id="M:Xamarin.Essentials.BarometerData.Equals(System.Object)" />
<Member Id="M:Xamarin.Essentials.BarometerData.Equals(Xamarin.Essentials.BarometerData)" />
<Member Id="M:Xamarin.Essentials.BarometerData.GetHashCode" />
<Member Id="M:Xamarin.Essentials.BarometerData.op_Equality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<Member Id="M:Xamarin.Essentials.BarometerData.op_Inequality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<Member Id="P:Xamarin.Essentials.BarometerData.Pressure" />
</Type>
<Type Name="Xamarin.Essentials.Battery" Id="T:Xamarin.Essentials.Battery">
<Member Id="E:Xamarin.Essentials.Battery.BatteryChanged" />
<Member Id="P:Xamarin.Essentials.Battery.ChargeLevel" />

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

@ -20,6 +20,23 @@
<Member Id="P:Xamarin.Essentials.AppInfo.Version" />
<Member Id="P:Xamarin.Essentials.AppInfo.VersionString" />
</Type>
<Type Name="Xamarin.Essentials.Barometer" Id="T:Xamarin.Essentials.Barometer">
<Member Id="E:Xamarin.Essentials.Barometer.ReadingChanged" />
<Member Id="M:Xamarin.Essentials.Barometer.Start(Xamarin.Essentials.SensorSpeed)" />
<Member Id="M:Xamarin.Essentials.Barometer.Stop" />
<Member Id="P:Xamarin.Essentials.Barometer.IsMonitoring" />
</Type>
<Type Name="Xamarin.Essentials.BarometerChangedEventArgs" Id="T:Xamarin.Essentials.BarometerChangedEventArgs">
<Member Id="P:Xamarin.Essentials.BarometerChangedEventArgs.Reading" />
</Type>
<Type Name="Xamarin.Essentials.BarometerData" Id="T:Xamarin.Essentials.BarometerData">
<Member Id="M:Xamarin.Essentials.BarometerData.Equals(System.Object)" />
<Member Id="M:Xamarin.Essentials.BarometerData.Equals(Xamarin.Essentials.BarometerData)" />
<Member Id="M:Xamarin.Essentials.BarometerData.GetHashCode" />
<Member Id="M:Xamarin.Essentials.BarometerData.op_Equality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<Member Id="M:Xamarin.Essentials.BarometerData.op_Inequality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<Member Id="P:Xamarin.Essentials.BarometerData.Pressure" />
</Type>
<Type Name="Xamarin.Essentials.Battery" Id="T:Xamarin.Essentials.Battery">
<Member Id="E:Xamarin.Essentials.Battery.BatteryChanged" />
<Member Id="P:Xamarin.Essentials.Battery.ChargeLevel" />

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

@ -0,0 +1,101 @@
<Type Name="Barometer" FullName="Xamarin.Essentials.Barometer">
<TypeSignature Language="C#" Value="public static class Barometer" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit Barometer extends System.Object" />
<TypeSignature Language="DocId" Value="T:Xamarin.Essentials.Barometer" />
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Monitor changes to the atmospheric pressure.</summary>
<remarks>
<para></para>
</remarks>
</Docs>
<Members>
<Member MemberName="IsMonitoring">
<MemberSignature Language="C#" Value="public static bool IsMonitoring { get; }" />
<MemberSignature Language="ILAsm" Value=".property bool IsMonitoring" />
<MemberSignature Language="DocId" Value="P:Xamarin.Essentials.Barometer.IsMonitoring" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets if barometer is actively being monitored.</summary>
<value>If barometer is being monitored.</value>
<remarks>
<para></para>
</remarks>
</Docs>
</Member>
<Member MemberName="ReadingChanged">
<MemberSignature Language="C#" Value="public static event EventHandler&lt;Xamarin.Essentials.BarometerChangedEventArgs&gt; ReadingChanged;" />
<MemberSignature Language="ILAsm" Value=".event class System.EventHandler`1&lt;class Xamarin.Essentials.BarometerChangedEventArgs&gt; ReadingChanged" />
<MemberSignature Language="DocId" Value="E:Xamarin.Essentials.Barometer.ReadingChanged" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.EventHandler&lt;Xamarin.Essentials.BarometerChangedEventArgs&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>Event triggered when barometer reading changes.</summary>
<remarks>
<para></para>
</remarks>
</Docs>
</Member>
<Member MemberName="Start">
<MemberSignature Language="C#" Value="public static void Start (Xamarin.Essentials.SensorSpeed sensorSpeed);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void Start(valuetype Xamarin.Essentials.SensorSpeed sensorSpeed) cil managed" />
<MemberSignature Language="DocId" Value="M:Xamarin.Essentials.Barometer.Start(Xamarin.Essentials.SensorSpeed)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="sensorSpeed" Type="Xamarin.Essentials.SensorSpeed" />
</Parameters>
<Docs>
<param name="sensorSpeed">The speed to listen for changes.</param>
<summary>Start monitoring for changes to the barometer.</summary>
<remarks>Will throw FeatureNotSupportedException if not supported on device.</remarks>
</Docs>
</Member>
<Member MemberName="Stop">
<MemberSignature Language="C#" Value="public static void Stop ();" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void Stop() cil managed" />
<MemberSignature Language="DocId" Value="M:Xamarin.Essentials.Barometer.Stop" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Stop monitoring for changes to the barometer.</summary>
<remarks>
<para></para>
</remarks>
</Docs>
</Member>
</Members>
</Type>

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

@ -0,0 +1,61 @@
<Type Name="BarometerChangedEventArgs" FullName="Xamarin.Essentials.BarometerChangedEventArgs">
<TypeSignature Language="C#" Value="public class BarometerChangedEventArgs : EventArgs" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit BarometerChangedEventArgs extends System.EventArgs" />
<TypeSignature Language="DocId" Value="T:Xamarin.Essentials.BarometerChangedEventArgs" />
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.EventArgs</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>The current pressure information from the change event.</summary>
<remarks>
<para></para>
</remarks>
</Docs>
<Members>
<Member MemberName="BarometerData">
<MemberSignature Language="C#" Value="public Xamarin.Essentials.BarometerData Reading { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype Xamarin.Essentials.BarometerData Reading" />
<MemberSignature Language="DocId" Value="P:Xamarin.Essentials.BarometerChangedEventArgs.Reading" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>Xamarin.Essentials.BarometerData</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the current barometer pressure data</summary>
<value>Pressure in hPA</value>
<remarks>
<para></para>
</remarks>
</Docs>
</Member>
<Member MemberName="Reading">
<MemberSignature Language="C#" Value="public Xamarin.Essentials.BarometerData Reading { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype Xamarin.Essentials.BarometerData Reading" />
<MemberSignature Language="DocId" Value="P:Xamarin.Essentials.BarometerChangedEventArgs.Reading" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>Xamarin.Essentials.BarometerData</ReturnType>
</ReturnValue>
<Docs>
<summary>Get the current reading of the barometer</summary>
<value>The reading</value>
<remarks>
<para></para>
</remarks>
</Docs>
</Member>
</Members>
</Type>

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

@ -0,0 +1,176 @@
<Type Name="BarometerData" FullName="Xamarin.Essentials.BarometerData">
<TypeSignature Language="C#" Value="public struct BarometerData : IEquatable&lt;Xamarin.Essentials.BarometerData&gt;" />
<TypeSignature Language="ILAsm" Value=".class public sequential ansi sealed beforefieldinit BarometerData extends System.ValueType implements class System.IEquatable`1&lt;valuetype Xamarin.Essentials.BarometerData&gt;" />
<TypeSignature Language="DocId" Value="T:Xamarin.Essentials.BarometerData" />
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.ValueType</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.IEquatable&lt;Xamarin.Essentials.BarometerData&gt;</InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute FrameworkAlternate="xamarin-essentials-android;xamarin-essentials-ios;xamarin-essentials-uwp">
<AttributeName>System.Runtime.CompilerServices.IsReadOnly</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>
<para>Contains the pressure measured by the user's device.</para>
</summary>
<remarks>
<para></para>
</remarks>
</Docs>
<Members>
<Member MemberName="Equals">
<MemberSignature Language="C#" Value="public override bool Equals (object obj);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance bool Equals(object obj) cil managed" />
<MemberSignature Language="DocId" Value="M:Xamarin.Essentials.BarometerData.Equals(System.Object)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="obj" Type="System.Object" />
</Parameters>
<Docs>
<param name="obj">Object to compare</param>
<summary>If equal to another object</summary>
<returns>If equal</returns>
<remarks>
<para />
</remarks>
</Docs>
</Member>
<Member MemberName="Equals">
<MemberSignature Language="C#" Value="public bool Equals (Xamarin.Essentials.BarometerData other);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool Equals(valuetype Xamarin.Essentials.BarometerData other) cil managed" />
<MemberSignature Language="DocId" Value="M:Xamarin.Essentials.BarometerData.Equals(Xamarin.Essentials.BarometerData)" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.IEquatable`1.Equals(`0)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="other" Type="Xamarin.Essentials.BarometerData" />
</Parameters>
<Docs>
<param name="other">Other object to compare</param>
<summary>If equal to another object</summary>
<returns>If equal</returns>
<remarks>
<para></para>
</remarks>
</Docs>
</Member>
<Member MemberName="GetHashCode">
<MemberSignature Language="C#" Value="public override int GetHashCode ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetHashCode() cil managed" />
<MemberSignature Language="DocId" Value="M:Xamarin.Essentials.BarometerData.GetHashCode" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Get has code for object.</summary>
<returns>The hash code.</returns>
<remarks>
<para></para>
</remarks>
</Docs>
</Member>
<Member MemberName="op_Equality">
<MemberSignature Language="C#" Value="public static bool operator == (Xamarin.Essentials.BarometerData left, Xamarin.Essentials.BarometerData right);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig specialname bool op_Equality(valuetype Xamarin.Essentials.BarometerData left, valuetype Xamarin.Essentials.BarometerData right) cil managed" />
<MemberSignature Language="DocId" Value="M:Xamarin.Essentials.BarometerData.op_Equality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="left" Type="Xamarin.Essentials.BarometerData" />
<Parameter Name="right" Type="Xamarin.Essentials.BarometerData" />
</Parameters>
<Docs>
<param name="left">Left to compare</param>
<param name="right">Right to compare</param>
<summary>If equal to another object</summary>
<returns>If equal</returns>
<remarks>
<para />
</remarks>
</Docs>
</Member>
<Member MemberName="op_Inequality">
<MemberSignature Language="C#" Value="public static bool operator != (Xamarin.Essentials.BarometerData left, Xamarin.Essentials.BarometerData right);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig specialname bool op_Inequality(valuetype Xamarin.Essentials.BarometerData left, valuetype Xamarin.Essentials.BarometerData right) cil managed" />
<MemberSignature Language="DocId" Value="M:Xamarin.Essentials.BarometerData.op_Inequality(Xamarin.Essentials.BarometerData,Xamarin.Essentials.BarometerData)" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="left" Type="Xamarin.Essentials.BarometerData" />
<Parameter Name="right" Type="Xamarin.Essentials.BarometerData" />
</Parameters>
<Docs>
<param name="left">Left to comapre</param>
<param name="right">Right to comapre</param>
<summary>If not equal to another object</summary>
<returns>If not equal</returns>
<remarks>
<para></para>
</remarks>
</Docs>
</Member>
<Member MemberName="Pressure">
<MemberSignature Language="C#" Value="public double Pressure { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance float64 Pressure" />
<MemberSignature Language="DocId" Value="P:Xamarin.Essentials.BarometerData.Pressure" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Double</ReturnType>
</ReturnValue>
<Docs>
<summary>Pressure in hPA</summary>
<value>The pressure</value>
<remarks>
<para></para>
</remarks>
</Docs>
</Member>
</Members>
</Type>

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

@ -173,7 +173,7 @@
<summary>Gets the version of the operating system.</summary>
<value>The version of the operating system.</value>
<remarks>
<para />
<para></para>
</remarks>
</Docs>
</Member>

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

@ -64,6 +64,9 @@
<Type Name="AccelerometerChangedEventArgs" Kind="Class" />
<Type Name="AccelerometerData" Kind="Structure" />
<Type Name="AppInfo" Kind="Class" />
<Type Name="Barometer" Kind="Class" />
<Type Name="BarometerChangedEventArgs" Kind="Class" />
<Type Name="BarometerData" Kind="Structure" />
<Type Name="Battery" Kind="Class" />
<Type Name="BatteryChangedEventArgs" Kind="Class" />
<Type Name="BatteryPowerSource" Kind="Enumeration" />