Skip to content
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

Updated sample for the issue Add sample for SimpleHapticsController #473 #13994

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AryanParashar24
Copy link

@AryanParashar24 AryanParashar24 commented Oct 17, 2023

GitHub Issue (If applicable): closes #

PR Type

What kind of change does this PR introduce?

What is the current behavior?

What is the new behavior?

Copilot Summary

🤖 Generated by Copilot at a942ba2

This pull request improves the cross-platform support for haptic feedback in the Uno Platform. It fixes and enhances the SimpleHapticsController class for Android and macOS devices, using the native APIs to provide more feedback options. It also refactors the iOS implementation, moving the haptic logic to a separate HapticFeedbackManager class.

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Internal Issue (If applicable):

New functions of single and double clicks have been added in the code for better expreince
added the press, single click and double click features in the macOS file of the SimpleHapticsController
features been included for the android version as well iun the base code for the PR to egt merged
@github-actions github-actions bot added platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform labels Oct 17, 2023
Copy link
Member

@jeromelaban jeromelaban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I added a few comments, but it's looking good!

Make sure to use conventional commits for your commit message.

#nullable enable
#pragma warning disable CS0618 // obsolete members
#nullable enable
#program warning disable CS0618 // obsolete members
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#program warning disable CS0618 // obsolete members
#pragma warning disable CS0618 // obsolete members

}
else
{
throw new NotSupportedException("Device does not support vibration");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably best if we skip vibrating altogether. It may be common for simulators to not have this feature. We can probably log a debug message instead.

}
else
{
throw new NotSupportedException("Device does not support vibration");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, let's log instead.

{
long[] pattern = { 0, (long)feedback.Duration.TotalMilliseconds, 50, (long)feedback.Duration.TotalMilliseconds };
vibrator.Vibrate(VibrationEffect.CreateWaveform(pattern, -1));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be keeping this try/catch, in case there's an unexpected error. Failing haptics should not fail the app.

else if (feedback.Duration.TotalMilliseconds <= 200)
{
// Potential Double Click - Check time interval with last click
if (lastClickTime.HasValue && (DateTime.Now - lastClickTime.Value).TotalMilliseconds < 200)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dr1rrb how do we determine that something is a double tap in gestures? We may want to align this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using this https://github.com/unoplatform/uno/blob/master/src/Uno.UWP/UI/Input/GestureRecognizer.cs#L27

But anyway, I'm not sure to understand the condition and why try to make distinction between simple click and double click. Here we end by doing impact.ImpactOccurred(); anyway. Is it expected ?

@jeromelaban jeromelaban marked this pull request as draft November 2, 2023 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform platform/macos 🍏 Categorizes an issue or PR as relevant to the macOS platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants