Skip to content

Commit 24c6d63

Browse files
authored
Missing API IsSupported in Vibration and HapticFeedback (#30471)
* feat(Vibration): Add IsSupported property Introduces a static IsSupported property to check if vibration is supported on the device across different platforms. Updates public API definitions accordingly. Aligning Vibration API with other Device capabilities API. Vibration was different from Vibration.Default. * feat(HapticFeedback): Add support check for haptic feedback Aligns static API with other platform services
1 parent bfbab9e commit 24c6d63

File tree

9 files changed

+28
-0
lines changed

9 files changed

+28
-0
lines changed

src/Essentials/src/HapticFeedback/HapticFeedback.shared.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public static void Perform(HapticFeedbackType type = HapticFeedbackType.Click) =
3333

3434
static IHapticFeedback? defaultImplementation;
3535

36+
/// <summary>
37+
/// Gets a value indicating whether haptic feedback is supported on this device.
38+
/// </summary>
39+
public static bool IsSupported
40+
=> Current.IsSupported;
41+
42+
static IHapticFeedback Current => Devices.HapticFeedback.Default;
43+
3644
/// <summary>
3745
/// Provides the default implementation for static usage of this API.
3846
/// </summary>

src/Essentials/src/PublicAPI/net-android/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ static Microsoft.Maui.Media.MediaPicker.PickPhotosAsync(Microsoft.Maui.Media.Med
2323
static Microsoft.Maui.Media.MediaPicker.PickVideosAsync(Microsoft.Maui.Media.MediaPickerOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.List<Microsoft.Maui.Storage.FileResult!>!>!
2424
*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!>!>!
2525
static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult?>!>!
26+
static Microsoft.Maui.Devices.HapticFeedback.IsSupported.get -> bool
27+
static Microsoft.Maui.Devices.Vibration.IsSupported.get -> bool

src/Essentials/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ static Microsoft.Maui.Media.MediaPicker.PickPhotosAsync(Microsoft.Maui.Media.Med
2323
static Microsoft.Maui.Media.MediaPicker.PickVideosAsync(Microsoft.Maui.Media.MediaPickerOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.List<Microsoft.Maui.Storage.FileResult!>!>!
2424
*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!>!>!
2525
static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult?>!>!
26+
static Microsoft.Maui.Devices.HapticFeedback.IsSupported.get -> bool
27+
static Microsoft.Maui.Devices.Vibration.IsSupported.get -> bool

src/Essentials/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ static Microsoft.Maui.Media.MediaPicker.PickPhotosAsync(Microsoft.Maui.Media.Med
2323
static Microsoft.Maui.Media.MediaPicker.PickVideosAsync(Microsoft.Maui.Media.MediaPickerOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.List<Microsoft.Maui.Storage.FileResult!>!>!
2424
*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!>!>!
2525
static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult?>!>!
26+
static Microsoft.Maui.Devices.HapticFeedback.IsSupported.get -> bool
27+
static Microsoft.Maui.Devices.Vibration.IsSupported.get -> bool

src/Essentials/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ static Microsoft.Maui.Authentication.WebAuthenticatorExtensions.AuthenticateAsyn
1111
static Microsoft.Maui.Devices.Sensors.Geolocation.IsEnabled.get -> bool
1212
*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!>!>!
1313
static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult?>!>!
14+
static Microsoft.Maui.Devices.HapticFeedback.IsSupported.get -> bool
15+
static Microsoft.Maui.Devices.Vibration.IsSupported.get -> bool

src/Essentials/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ static Microsoft.Maui.Media.MediaPicker.PickPhotosAsync(Microsoft.Maui.Media.Med
2323
static Microsoft.Maui.Media.MediaPicker.PickVideosAsync(Microsoft.Maui.Media.MediaPickerOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.List<Microsoft.Maui.Storage.FileResult!>!>!
2424
*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!>!>!
2525
static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult?>!>!
26+
static Microsoft.Maui.Devices.HapticFeedback.IsSupported.get -> bool
27+
static Microsoft.Maui.Devices.Vibration.IsSupported.get -> bool

src/Essentials/src/PublicAPI/net/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ static Microsoft.Maui.Media.MediaPicker.PickPhotosAsync(Microsoft.Maui.Media.Med
2323
static Microsoft.Maui.Media.MediaPicker.PickVideosAsync(Microsoft.Maui.Media.MediaPickerOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.List<Microsoft.Maui.Storage.FileResult!>!>!
2424
*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!>!>!
2525
static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult?>!>!
26+
static Microsoft.Maui.Devices.HapticFeedback.IsSupported.get -> bool
27+
static Microsoft.Maui.Devices.Vibration.IsSupported.get -> bool

src/Essentials/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ static Microsoft.Maui.Media.MediaPicker.PickPhotosAsync(Microsoft.Maui.Media.Med
2323
static Microsoft.Maui.Media.MediaPicker.PickVideosAsync(Microsoft.Maui.Media.MediaPickerOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.List<Microsoft.Maui.Storage.FileResult!>!>!
2424
*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!>!>!
2525
static Microsoft.Maui.Storage.FilePicker.PickMultipleAsync(Microsoft.Maui.Storage.PickOptions? options = null) -> System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Microsoft.Maui.Storage.FileResult?>!>!
26+
static Microsoft.Maui.Devices.HapticFeedback.IsSupported.get -> bool
27+
static Microsoft.Maui.Devices.Vibration.IsSupported.get -> bool

src/Essentials/src/Vibration/Vibration.shared.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public static void Vibrate(TimeSpan duration) =>
6666
public static void Cancel() =>
6767
Current.Cancel();
6868

69+
/// <summary>
70+
/// Gets a value indicating whether vibration is supported on this device.
71+
/// </summary>
72+
public static bool IsSupported
73+
=> Current.IsSupported;
74+
6975
static IVibration Current => Devices.Vibration.Default;
7076

7177
static IVibration? defaultImplementation;

0 commit comments

Comments
 (0)