-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from AathifMahir/AutoStop
New Auto Stop Property Implementation and Overall Enhancements
- Loading branch information
Showing
13 changed files
with
168 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/MauiShakeDetector.UnitTest/MauiShakeDetector.UnitTest.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.11.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\MauiShakeDetector\MauiShakeDetector.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace MauiShakeDetector.UnitTest; | ||
public class ShakeDetectorDefaultTest | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using FluentAssertions; | ||
|
||
namespace MauiShakeDetector.UnitTest; | ||
public class ShakeEventArgsTest | ||
{ | ||
[Theory] | ||
[InlineData(1)] | ||
[InlineData(2)] | ||
public void NoOfShakesShouldBeEqualInShakeDetectedEventArgs(int noOfShakes) | ||
{ | ||
var eventArgs = new ShakeDetectedEventArgs(noOfShakes); | ||
eventArgs.NoOfShakes.Should().Be(noOfShakes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,85 @@ | ||
namespace MauiShakeDetector; | ||
public interface IShakeDetector | ||
{ | ||
|
||
/// <summary> | ||
/// Gets a Value Indicating Whether ShakeDetector is Supported on this Device | ||
/// Gets a value indicating whether ShakeDetector is supported on this device | ||
/// </summary> | ||
bool IsSupported { get; } | ||
/// <summary> | ||
/// Gets a Value Indicating Whether ShakeDetector is Already Monitoring | ||
/// Gets a value indicating whether ShakeDetector is already monitoring | ||
/// </summary> | ||
bool IsMonitoring { get; } | ||
|
||
/// <summary> | ||
/// Get or Set the Value of Shake Detection Threshold | ||
/// In Summary The Gforce Value for Shake To Be Detected | ||
/// Gets or sets the value of shake detection threshold | ||
/// In summary, the Gforce value for shake to be detected | ||
/// </summary> | ||
double ShakeThresholdGravity { get; set; } | ||
double ShakeThresholdGravity { get; set; } | ||
|
||
/// <summary> | ||
/// Get or Set the value of Minimum Delay betweem Shakes | ||
/// Gets or sets the value of minimum delay between shakes | ||
/// </summary> | ||
TimeSpan ShakeIntervalInMilliseconds { get; set; } | ||
TimeSpan ShakeIntervalInMilliseconds { get; set; } | ||
|
||
/// <summary> | ||
/// Get or Set the Value of Shake Reset Interval in Milliseconds | ||
/// Gets or sets the value of shake reset interval in milliseconds | ||
/// </summary> | ||
TimeSpan ShakeResetIntervalInMilliseconds { get; set; } | ||
TimeSpan ShakeResetIntervalInMilliseconds { get; set; } | ||
|
||
/// <summary> | ||
/// Get or Set the Value for Number of Shakes Required Before Shake is Triggered | ||
/// Gets or sets the value for number of shakes required before shake is triggered | ||
/// </summary> | ||
int MinimumShakeCount { get; set; } | ||
int MinimumShakeCount { get; set; } | ||
/// <summary> | ||
/// Gets a Value Indicating Whether Haptics is Enabled or not | ||
/// Gets a value indicating whether haptics is enabled or not | ||
/// </summary> | ||
/// <remarks> | ||
/// Default is true, you can disable it if you want by setting it to false | ||
/// </remarks> | ||
/// <remarks> | ||
/// Will throw Microsoft.Maui.ApplicationModel.FeatureNotSupportedException If MauiShakeDetector.IShakeDetector.IsHapticsSupported is false, | ||
/// Therefore Please Check Whether MauiShakeDetector.IShakeDetector.IsHapticsSupported is true before enabling haptics on the device | ||
/// </remarks> | ||
bool IsHapticsEnabled { get; set; } | ||
/// <summary> | ||
/// Gets a Value Indicating Whether Haptics Supported in this Device | ||
/// Gets a value indicating whether haptics is supported on this device | ||
/// </summary> | ||
bool IsHapticsSupported { get;} | ||
/// <remarks> | ||
/// Will throw Microsoft.Maui.ApplicationModel.FeatureNotSupportedException If MauiShakeDetector.IShakeDetector.IsHapticsSupported is false | ||
/// </remarks> | ||
bool IsHapticsSupported { get; } | ||
/// <summary> | ||
/// Gets or sets the value of haptics duration | ||
/// </summary> | ||
TimeSpan HapticsDurationInMilliseconds { get; set; } | ||
/// <summary> | ||
/// Get or Set the Value Of Haptics Duration | ||
/// Gets or sets the value of auto stop listening to shake event after number of shakes triggered | ||
/// </summary> | ||
TimeSpan HapticsDurationInMilliseconds { get; set; } | ||
/// <remarks> | ||
/// Default is 0 and it means feature is disabled by default. You can set the count to some other value to enable this feature | ||
/// </remarks> | ||
int AutoStopAfterNoShakes { get; set; } | ||
/// <summary> | ||
/// Shake Detected Event for Detecting Whether User Shaked the Device | ||
/// Shake detected event for detecting whether user shook the device | ||
/// </summary> | ||
#nullable enable | ||
event EventHandler<ShakeDetectedEventArgs>? ShakeDetected; | ||
#nullable disable | ||
|
||
/// <summary> | ||
/// Start listening for Shake Event | ||
/// Start listening for shake event | ||
/// </summary> | ||
/// <param name="sensorSpeed"> | ||
/// Speed to monitor the Shake Events. | ||
/// Speed to monitor the shake events. | ||
/// </param> | ||
/// <remarks> | ||
/// Will throw Microsoft.Maui.ApplicationModel.FeatureNotSupportedException if MauiShakeDetector.IShakeDetector.IsSupported | ||
/// is false. Will throw System.InvalidOperationException if MauiShakeDetector.IShakeDetector.IsMonitoring | ||
/// is true. | ||
/// Will throw Microsoft.Maui.ApplicationModel.FeatureNotSupportedException if MauiShakeDetector.IShakeDetector.IsSupported is false. | ||
/// Will throw System.InvalidOperationException if MauiShakeDetector.IShakeDetector.IsMonitoring is true. | ||
/// </remarks> | ||
void StartListening(SensorSpeed sensorSpeed = SensorSpeed.Default); | ||
/// <summary> | ||
/// Stop Already Monitoring Shake Event | ||
/// Stop already monitoring shake event | ||
/// </summary> | ||
void StopListening(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters