Skip to content

Commit

Permalink
Merge pull request #15 from AathifMahir/v1
Browse files Browse the repository at this point in the history
1st Milestone Build
  • Loading branch information
AathifMahir authored Sep 13, 2023
2 parents 614a57d + ccaf650 commit 19e152c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/MauiShakeDetector/IShakeDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public interface IShakeDetector
event EventHandler<ShakeDetectedEventArgs>? ShakeDetected;
#nullable disable

/// <summary>
/// Shake stopped event for detecting whether shake detector is stopped when Auto Stop is more than 0
/// </summary>
#nullable enable
event EventHandler? ShakeStopped;
#nullable disable
/// <summary>
/// Shake Detected Command for detecting whether user shook the device
/// </summary>
Expand All @@ -77,6 +83,11 @@ public interface IShakeDetector
/// </remarks>
ICommand ShakeDetectedCommand { get; set; }

/// <summary>
/// Shake stopped command for detecting whether shake detector is stopped when Auto Stop is more than 0
/// </summary>
ICommand ShakeStoppedCommand { get; set; }

/// <summary>
/// Start listening for shake event
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions src/MauiShakeDetector/MauiShakeDetector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
<Description>Maui Shake Detector Shake Event Detector Library with Lots of Customization like GForce Tuning, Shake Intervals and Haptics for Shake Events</Description>
<PackageIcon>icon.png</PackageIcon>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<AssemblyVersion>0.4.0.0</AssemblyVersion>
<AssemblyFileVersion>0.4.0.0</AssemblyFileVersion>
<Version>0.4.0</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AssemblyFileVersion>1.0.0.0</AssemblyFileVersion>
<Version>1.0.0</Version>
<PackageVersion>$(Version)$(VersionSuffix)</PackageVersion>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>Maui,Shake,ShakeDetector,MauiShake,</PackageTags>
<PackageTags>Maui,Shake,ShakeDetector,MauiShake,Accelerometer,Vibration</PackageTags>
<Configurations>Debug;Release</Configurations>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/ReleaseNotes.txt"))</PackageReleaseNotes>
Expand Down
5 changes: 4 additions & 1 deletion src/MauiShakeDetector/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
v0.4.0
v1.0.0
• Added Shake Stopped Event and Command for Auto Stop Enabled Scenerios

v0.4.0
• Added Command Support

v0.3.0
Expand Down
7 changes: 7 additions & 0 deletions src/MauiShakeDetector/ShakeDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ public static event EventHandler<ShakeDetectedEventArgs> ShakeDetected
add => Default.ShakeDetected += value;
remove => Default.ShakeDetected -= value;
}

public static event EventHandler ShakeStopped
{
add => Default.ShakeStopped += value;
remove => Default.ShakeStopped -= value;
}
public static ICommand ShakeDetectedCommand => Default.ShakeDetectedCommand;
public static ICommand ShakeStoppedCommand => Default.ShakeStoppedCommand;

public static void StartListening(SensorSpeed sensorSpeed) => Default.StartListening(sensorSpeed);

Expand Down
9 changes: 9 additions & 0 deletions src/MauiShakeDetector/ShakeDetectorDefault.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ internal sealed class ShakeDetectorDefault : IShakeDetector
// Event & Commands

public event EventHandler<ShakeDetectedEventArgs> ShakeDetected;
public event EventHandler ShakeStopped;

public ICommand ShakeDetectedCommand { get; set; }
public ICommand ShakeStoppedCommand { get; set; }

public void StartListening(SensorSpeed sensorSpeed = SensorSpeed.Default)
{
Expand Down Expand Up @@ -93,7 +96,13 @@ void AutoStopAfterNoShakeEvents()
if(AutoStopAfterNoShakes is not defaultShakeCount && currentTriggeredShakesCount >= AutoStopAfterNoShakes)
{
currentTriggeredShakesCount = defaultShakeCount;

StopListening();

ShakeStopped?.Invoke(this, new EventArgs());
if (ShakeStoppedCommand is not null && ShakeStoppedCommand.CanExecute(null))
ShakeStoppedCommand.Execute(null);

}
}

Expand Down
4 changes: 3 additions & 1 deletion src/MauiShakeDetector/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ using MauiShakeDetector;
| **ShakeIntervalInMilliseconds** | `TimeSpan` | Get or Set the value of Minimum Delay betweem Shakes |
| **ShakeResetIntervalInMilliseconds** | `TimeSpan` | Get or Set the Value of Shake Reset Interval in Milliseconds |
| **MinimumShakeCount** | `int` | Get or Set the Value for Number of Shakes Required Before Shake is Triggered |
| **AutoStopAfterNoShakes** | `int` | Gets or sets the value of Auto Stop listening to shake event after number of shakes triggered |
| **AutoStopAfterNoShakes** | `int` | Gets or sets the value of Auto Stop listening to shake event after number of shakes triggered, Minimum is 1 |
| **HapticsDurationInMilliseconds** | `TimeSpan` | Get or Set the Value Of Haptics Duration |
| **ShakeDetectedCommand** | `ICommand` | Shake Detected Command for Detecting Whether User Shooked the Device |
| **ShakeDetected** | `event` | Shake Detected Event for Detecting Whether User Shooked the Device |
| **ShakeStoppedCommand** | `ICommand` | Shake Stopped Command for Detecting Whether Shake Detector is Stopped When Auto Stop is more than 0 |
| **ShakeStopped** | `event` | Shake Stopped Event for Detecting Whether Shake Detector is Stopped When Auto Stop is more than 0 |
| **StartListening()** | `method` | Start listening for Shake Event |
| **SensorSpeed** | `enum` | Set the value for Shake Detection Speed When Using Start Listning Method |
| **StopListening()** | `method` | Stop Already Monitoring Shake Event |
Expand Down

0 comments on commit 19e152c

Please sign in to comment.