maui icon indicating copy to clipboard operation
maui copied to clipboard

Vibrate - Detect zero duration and return early

Open BioTurboNick opened this issue 3 years ago • 1 comments

Description of Change

CreateOneShot method doesn't accept a duration of zero as documented here:

https://learn.microsoft.com/en-us/dotnet/api/android.os.vibrationeffect.createoneshot?view=xamarin-android-sdk-12

However, zero is valid for the MAUI Vibrate method: https://learn.microsoft.com/en-us/dotnet/api/microsoft.maui.devices.vibration.vibrate?view=net-maui-7.0

So we need to detect this and return early to avoid this exception:

Java.Lang.IllegalArgumentException: 'at least one timing must be non-zero (segments=[Step{amplitude=-1.0, frequency=0.0, duration=0}])'

Issues Fixed

It was easier to fix this directly than to create a whole issue and take the time to make a reproduction project.

BioTurboNick avatar Nov 12 '22 17:11 BioTurboNick

Hey there @BioTurboNick! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

ghost avatar Nov 12 '22 17:11 ghost

/azp run

jfversluis avatar Nov 15 '22 09:11 jfversluis

Azure Pipelines successfully started running 2 pipeline(s).

azure-pipelines[bot] avatar Nov 15 '22 09:11 azure-pipelines[bot]

Should we add this in the API docs and/or conceptual docs or what would be a good place to mention this?

cc: @davidbritch

jfversluis avatar Nov 15 '22 09:11 jfversluis

/azp run

Redth avatar Nov 22 '22 16:11 Redth

Azure Pipelines successfully started running 2 pipeline(s).

azure-pipelines[bot] avatar Nov 22 '22 16:11 azure-pipelines[bot]

/backport to net7.0

mattleibow avatar Dec 15 '22 15:12 mattleibow

Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/3705758101

github-actions[bot] avatar Dec 15 '22 15:12 github-actions[bot]