AathifMahir.Maui.MauiShakeDetector 2.0.0

Prefix Reserved
dotnet add package AathifMahir.Maui.MauiShakeDetector --version 2.0.0                
NuGet\Install-Package AathifMahir.Maui.MauiShakeDetector -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AathifMahir.Maui.MauiShakeDetector" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AathifMahir.Maui.MauiShakeDetector --version 2.0.0                
#r "nuget: AathifMahir.Maui.MauiShakeDetector, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AathifMahir.Maui.MauiShakeDetector as a Cake Addin
#addin nuget:?package=AathifMahir.Maui.MauiShakeDetector&version=2.0.0

// Install AathifMahir.Maui.MauiShakeDetector as a Cake Tool
#tool nuget:?package=AathifMahir.Maui.MauiShakeDetector&version=2.0.0                

Maui Shake Detector

Maui Shake Detector is Shake Event Detector Library Which Detects Shake Event from Android, iOS and etc. with Options to Customize the Shake Gforce and Shake Intervals and Haptics and Haptics Duration and etc.

Permission

In order to use Maui Shake Detector, You need Specific permission for Android

Android

Add the assembly-based permission:

Open the Platforms/Android/MainApplication.cs file and add the following assembly attributes after using directives:

C#


[assembly: UsesPermission(Android.Manifest.Permission.Vibrate)]

  • or -

Update the Android Manifest:

Open the Platforms/Android/AndroidManifest.xml file and add the following in the manifest node:


<uses-permission android:name="android.permission.VIBRATE" />

Get Started

using MauiShakeDetector;

    // Start
    private void BtnStartListening_Clicked(object sender, EventArgs e)
    {
        if (ShakeDetector.Default.IsSupported && !ShakeDetector.Default.IsMonitoring)
        {
            ShakeDetector.Default.StartListening();
            ShakeDetector.Default.ShakeDetected += Detector_ShakeDetected;
            return;
        }
    }

    // Stop
    private void BtnStopListening_Clicked(object sender, EventArgs e)
    {
        if (ShakeDetector.Default.IsMonitoring)
        {
            ShakeDetector.Default.StopListening();
            ShakeDetector.Default.ShakeDetected -= Detector_ShakeDetected;
        }
    }

    private void Detector_ShakeDetected(object sender, ShakeDetectedEventArgs e)
    {
        Debug.Writeline($"No of Shakes : {e.NoOfShakes}");
    }

Parameters

Parameters Type Description
IsSupported bool Indicating Whether ShakeDetector is Supported on this Device
IsMonitoring bool Indicating Whether ShakeDetector is Already Monitoring
IsHapticsSupported bool Indicating Whether Haptics Supported in this Device
IsHapticsEnabled bool Get or Set the Value Indicating Whether Haptics is Enabled or Not
ShakeThresholdGravity double Get or Set the Value of Shake Detection Threshold
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, 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

License

Maui Shake Detector is Licensed Under MIT License.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-android33.0 is compatible.  net7.0-ios was computed.  net7.0-ios16.1 is compatible.  net7.0-maccatalyst was computed.  net7.0-maccatalyst16.1 is compatible.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows10.0.19041 is compatible.  net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-ios17.0 is compatible.  net8.0-maccatalyst was computed.  net8.0-maccatalyst17.0 is compatible.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows10.0.19041 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 334 11/19/2023
1.0.0 163 9/13/2023
0.4.0 186 6/3/2023
0.3.0 174 5/24/2023
0.2.0 157 5/19/2023
0.1.0 163 5/15/2023
0.1.0-preview1 125 5/13/2023

v2.0.0
• Dotnet 8 Support

Breaking Changes
- Removal of Dotnet 6 Support

v1.0.0
• Added Shake Stopped Event and Command for Auto Stop Enabled Scenerios

v0.4.0
• Added Command Support

v0.3.0
• Added .Net 6 Support

v0.2.0
• Added New Property to Auto Stop Listening to Shake Event "AutoStopAfterNoShakes"
• Enhancements for Comments

v0.1.0
• First Stable Build
• Enhancements for Comments

v0.1.0-preview1
• First Preview Build