Skip to content

Integrate common ISensor interface (net10.0) #30135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: net10.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions src/Essentials/src/Accelerometer/Accelerometer.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.Maui.Devices.Sensors
/// <summary>
/// Accelerometer data of the acceleration of the device in three-dimensional space.
/// </summary>
public interface IAccelerometer
public interface IAccelerometer : ISensor
{
/// <summary>
/// Occurs when the sensor reading changes.
Expand All @@ -19,30 +19,6 @@ public interface IAccelerometer
/// Occurs when the accelerometer detects that the device has been shaken.
/// </summary>
event EventHandler? ShakeDetected;

/// <summary>
/// Gets a value indicating whether reading the accelerometer is supported on this device.
/// </summary>
bool IsSupported { get; }

/// <summary>
/// Gets a value indicating whether the accelerometer is being monitored.
/// </summary>
bool IsMonitoring { get; }

/// <summary>
/// Start monitoring for changes to accelerometer.
/// </summary>
/// <remarks>
/// Will throw <see cref="FeatureNotSupportedException"/> if <see cref="IsSupported"/> is <see langword="false"/>.
/// Will throw <see cref="InvalidOperationException"/> if <see cref="IsMonitoring"/> is <see langword="true"/>.</remarks>
/// <param name="sensorSpeed">Speed to monitor the sensor.</param>
void Start(SensorSpeed sensorSpeed);

/// <summary>
/// Stop monitoring for changes to accelerometer.
/// </summary>
void Stop();
}

/// <summary>
Expand Down
8 changes: 2 additions & 6 deletions src/Essentials/src/AppActions/AppActions.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Maui.Devices;
#if ANDROID
using Android.Content;
#endif
Expand All @@ -11,13 +12,8 @@ namespace Microsoft.Maui.ApplicationModel
/// <summary>
/// The AppActions API lets you create and respond to app shortcuts from the app icon.
/// </summary>
public interface IAppActions
public interface IAppActions : IDeviceCapabilities
{
/// <summary>
/// Gets if app actions are supported on this device.
/// </summary>
bool IsSupported { get; }

/// <summary>
/// Retrieves all the currently available <see cref="AppAction"/> instances.
/// </summary>
Expand Down
23 changes: 1 addition & 22 deletions src/Essentials/src/Barometer/Barometer.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,12 @@ namespace Microsoft.Maui.Devices.Sensors
/// <summary>
/// Monitor changes to the atmospheric pressure.
/// </summary>
public interface IBarometer
public interface IBarometer : ISensor
{
/// <summary>
/// Gets a value indicating whether reading the barometer is supported on this device.
/// </summary>
bool IsSupported { get; }

/// <summary>
/// Gets a value indicating whether the barometer is actively being monitored.
/// </summary>
bool IsMonitoring { get; }

/// <summary>
/// Start monitoring for changes to the barometer.
/// </summary>
/// <param name="sensorSpeed">The speed to listen for changes.</param>
void Start(SensorSpeed sensorSpeed);

/// <summary>
/// Occurs when the barometer reading changes.
/// </summary>
event EventHandler<BarometerChangedEventArgs>? ReadingChanged;

/// <summary>
/// Stop monitoring for changes to the barometer.
/// </summary>
void Stop();
}

/// <summary>
Expand Down
23 changes: 1 addition & 22 deletions src/Essentials/src/Compass/Compass.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,15 @@ namespace Microsoft.Maui.Devices.Sensors
/// <summary>
/// Monitor changes to the orientation of the user's device.
/// </summary>
public interface ICompass
public interface ICompass : ISensor
{
/// <summary>
/// Gets a value indicating whether reading the compass is supported on this device.
/// </summary>
bool IsSupported { get; }

/// <summary>
/// Gets if compass is actively being monitored.
/// </summary>
bool IsMonitoring { get; }

/// <summary>
/// Start monitoring for changes to the compass.
/// </summary>
/// <param name="sensorSpeed">The speed to monitor for changes.</param>
void Start(SensorSpeed sensorSpeed);

/// <summary>
/// Start monitoring for changes to the compass.
/// </summary>
/// <param name="sensorSpeed">The speed to monitor for changes.</param>
/// <param name="applyLowPassFilter">Whether or not to apply a moving average filter (only used on Android).</param>
void Start(SensorSpeed sensorSpeed, bool applyLowPassFilter);

/// <summary>
/// Stop monitoring for changes to the compass.
/// </summary>
void Stop();

/// <summary>
/// Occurs when compass reading changes.
/// </summary>
Expand Down
23 changes: 1 addition & 22 deletions src/Essentials/src/Gyroscope/Gyroscope.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,8 @@ namespace Microsoft.Maui.Devices.Sensors
/// <summary>
/// The Gyroscope API lets you monitor the device's gyroscope sensor which is the rotation around the device's three primary axes.
/// </summary>
public interface IGyroscope
public interface IGyroscope : ISensor
{
/// <summary>
/// Gets a value indicating whether reading the gyroscope is supported on this device.
/// </summary>
bool IsSupported { get; }

/// <summary>
/// Gets a value indicating whether the gyroscope is actively being monitored.
/// </summary>
bool IsMonitoring { get; }

/// <summary>
/// Start monitoring for changes to the gyroscope.
/// </summary>
/// <param name="sensorSpeed">The speed to listen for changes.</param>
void Start(SensorSpeed sensorSpeed);

/// <summary>
/// Stop monitoring for changes to the gyroscope.
/// </summary>
void Stop();

/// <summary>
/// Occurs when the gyroscope reading changes.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ namespace Microsoft.Maui.Devices
/// <summary>
/// The HapticFeedback API lets you control haptic feedback on the device.
/// </summary>
public interface IHapticFeedback
public interface IHapticFeedback : IDeviceCapabilities
{
/// <summary>
/// Gets a value indicating whether haptic feedback is supported on this device.
/// </summary>
bool IsSupported { get; }

/// <summary>
/// Perform a type of haptic feedback on the device.
/// </summary>
Expand Down
29 changes: 4 additions & 25 deletions src/Essentials/src/Magnetometer/Magnetometer.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,18 @@
namespace Microsoft.Maui.Devices.Sensors
{
/// <summary>
/// Detect device's orentation relative to Earth's magnetic field in microteslas (�).
/// Detect device's orentation relative to Earth's magnetic field in microteslas (�).
/// </summary>
public interface IMagnetometer
public interface IMagnetometer : ISensor
{
/// <summary>
/// Gets a value indicating whether reading the magnetometer is supported on this device.
/// </summary>
bool IsSupported { get; }

/// <summary>
/// Gets a value indicating whether the magnetometer is actively being monitored.
/// </summary>
bool IsMonitoring { get; }

/// <summary>
/// Start monitoring for changes to the magnetometer.
/// </summary>
/// <param name="sensorSpeed">The speed to listen for changes.</param>
void Start(SensorSpeed sensorSpeed);

/// <summary>
/// Stop monitoring for changes to the magnetometer.
/// </summary>
void Stop();

/// <summary>
/// Occurs when the magnetometer reading changes.
/// </summary>
event EventHandler<MagnetometerChangedEventArgs> ReadingChanged;
}

/// <summary>
/// Detect device's orentation relative to Earth's magnetic field in microteslas (�).
/// Detect device's orentation relative to Earth's magnetic field in microteslas (�).
/// </summary>
public static partial class Magnetometer
{
Expand Down Expand Up @@ -138,7 +117,7 @@ public MagnetometerData(float x, float y, float z) =>
MagneticField = new Vector3(x, y, z);

/// <summary>
/// Gets the magnetic field vector in microteslas (�).
/// Gets the magnetic field vector in microteslas (�).
/// </summary>
public Vector3 MagneticField { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,8 @@ namespace Microsoft.Maui.Devices.Sensors
/// <summary>
/// The OrientationSensor API lets you monitor the orientation of a device in three dimensional space.
/// </summary>
public interface IOrientationSensor
public interface IOrientationSensor : ISensor
{
/// <summary>
/// Gets a value indicating whether reading the orientation sensor is supported on this device.
/// </summary>
bool IsSupported { get; }

/// <summary>
/// Gets a value indicating whether the orientation sensor is actively being monitored.
/// </summary>
bool IsMonitoring { get; }

/// <summary>
/// Start monitoring for changes to the orientation.
/// </summary>
/// <param name="sensorSpeed">The speed to listen for changes.</param>
void Start(SensorSpeed sensorSpeed);

/// <summary>
/// Stop monitoring for changes to the orientation.
/// </summary>
void Stop();

/// <summary>
/// Occurs when the orientation reading changes.
/// </summary>
Expand Down
8 changes: 2 additions & 6 deletions src/Essentials/src/PhoneDialer/PhoneDialer.shared.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#nullable enable
using System;
using Microsoft.Maui.Devices;

namespace Microsoft.Maui.ApplicationModel.Communication
{
/// <summary>
/// The PhoneDialer API enables an application to open a phone number in the dialer.
/// </summary>
public interface IPhoneDialer
public interface IPhoneDialer : IDeviceCapabilities
{
/// <summary>
/// Gets a value indicating whether using the phone dialer is supported on this device.
/// </summary>
bool IsSupported { get; }

/// <summary>
/// Open the phone dialer to a specific phone number.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,37 @@ static Microsoft.Maui.Media.MediaPicker.PickPhotosAsync(Microsoft.Maui.Media.Med
static Microsoft.Maui.Media.MediaPicker.PickVideosAsync(Microsoft.Maui.Media.MediaPickerOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.List<Microsoft.Maui.Storage.FileResult!>!>!
*REMOVED*static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult!>!>!
static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult?>!>!
Microsoft.Maui.Devices.Sensors.ISensor
Microsoft.Maui.Devices.Sensors.ISensor.IsMonitoring.get -> bool
Microsoft.Maui.Devices.Sensors.ISensor.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
Microsoft.Maui.Devices.Sensors.ISensor.Stop() -> void
Microsoft.Maui.Devices.IDeviceCapabilities
Microsoft.Maui.Devices.IDeviceCapabilities.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.ApplicationModel.Communication.IPhoneDialer.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.ApplicationModel.IAppActions.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.IHapticFeedback.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.IVibration.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IAccelerometer.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IAccelerometer.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IAccelerometer.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IAccelerometer.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IBarometer.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IBarometer.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IBarometer.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IBarometer.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.ICompass.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.ICompass.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.ICompass.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.ICompass.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IGyroscope.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IGyroscope.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IGyroscope.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IGyroscope.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IMagnetometer.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IMagnetometer.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IMagnetometer.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IMagnetometer.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IOrientationSensor.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IOrientationSensor.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IOrientationSensor.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IOrientationSensor.Stop() -> void
34 changes: 34 additions & 0 deletions src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,37 @@ static Microsoft.Maui.Media.MediaPicker.PickPhotosAsync(Microsoft.Maui.Media.Med
static Microsoft.Maui.Media.MediaPicker.PickVideosAsync(Microsoft.Maui.Media.MediaPickerOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.List<Microsoft.Maui.Storage.FileResult!>!>!
*REMOVED*static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult!>!>!
static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult?>!>!
Microsoft.Maui.Devices.Sensors.ISensor
Microsoft.Maui.Devices.Sensors.ISensor.IsMonitoring.get -> bool
Microsoft.Maui.Devices.Sensors.ISensor.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
Microsoft.Maui.Devices.Sensors.ISensor.Stop() -> void
Microsoft.Maui.Devices.IDeviceCapabilities
Microsoft.Maui.Devices.IDeviceCapabilities.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.ApplicationModel.Communication.IPhoneDialer.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.ApplicationModel.IAppActions.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.IHapticFeedback.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.IVibration.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IAccelerometer.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IAccelerometer.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IAccelerometer.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IAccelerometer.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IBarometer.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IBarometer.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IBarometer.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IBarometer.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.ICompass.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.ICompass.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.ICompass.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.ICompass.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IGyroscope.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IGyroscope.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IGyroscope.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IGyroscope.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IMagnetometer.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IMagnetometer.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IMagnetometer.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IMagnetometer.Stop() -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IOrientationSensor.IsMonitoring.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IOrientationSensor.IsSupported.get -> bool
*REMOVED*Microsoft.Maui.Devices.Sensors.IOrientationSensor.Start(Microsoft.Maui.Devices.Sensors.SensorSpeed sensorSpeed) -> void
*REMOVED*Microsoft.Maui.Devices.Sensors.IOrientationSensor.Stop() -> void
Loading