# sensey **Repository Path**: chinasoft_ohos/sensey ## Basic Information - **Project Name**: sensey - **Description**: ohos传感器封装 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 1 - **Created**: 2021-04-15 - **Last Updated**: 2022-09-06 ## Categories & Tags **Categories**: harmonyos-drivers **Tags**: None ## README
# sensey #### 项目介绍 - 项目名称:sensey - 所属系列:openharmony 第三方组件适配移植 - 功能:传感器封装 - 项目移植状态:主功能完成 - 调用差异:无 (TouchType中的onTwoFingerSingleTap、onThreeFingerSingleTap、onScroll、onSwipe功能尚未实现) - 开发版本:sdk6,DevEco Studio2.2 beta1 - 基线版本:Release v1.9.0 #### 效果演示 ![sc3](img/sensey.gif) #### 安装教程 1.在moudle级别下的build.gradle文件中添加依赖 ``` // 添加maven仓库 repositories { maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } ``` 2.在entry模块的build.gradle文件中, ``` // 添加依赖库 dependencies { implementation 'com.gitee.chinasoft_ohos:sensey:1.0.1' } ``` 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 #### 使用说明 Ohos library which makes playing with sensor events & detecting gestures a breeze.

The library is built for simplicity and ease of use. It eliminates most boilerplate code for dealing with setting up sensor based event and gesture detection on Ohos.

Supported gestures/events | Gesture | Methods | Usage | | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | | Flip | onFaceUp
onFaceDown | [Link](https://github.com/nisrulz/sensey/wiki/Usage#flip) | | Light | onDark
onLight | [Link](https://github.com/nisrulz/sensey/wiki/Usage#light) | | Orientation | onTopSideUp
onBottomSideUp
onLeftSideUp
onRightSideUp | [Link](https://github.com/nisrulz/sensey/wiki/Usage#orientation) | | PinchScale | onScale
onScaleStart
onScaleEnd | [Link](https://github.com/nisrulz/sensey/wiki/Usage#pinchscale) | | Proximity | onNear
onFar | [Link](https://github.com/nisrulz/sensey/wiki/Usage#proximity) | | Shake | onShakeDetected
onShakeStopped | [Link](https://github.com/nisrulz/sensey/wiki/Usage#shake) | | Wave | onWave | [Link](https://github.com/nisrulz/sensey/wiki/Usage#wave) | | Chop | onChop | [Link](https://github.com/nisrulz/sensey/wiki/Usage#chop) | | WristTwist | onWristTwist | [Link](https://github.com/nisrulz/sensey/wiki/Usage#wristtwist) | | Movement | onMovement
onStationary | [Link](https://github.com/nisrulz/sensey/wiki/Usage#movement) | | SoundLevel | onSoundDetected | [Link](https://github.com/nisrulz/sensey/wiki/Usage#soundlevel) | | RotationAngle | onRotation | [Link](https://github.com/nisrulz/sensey/wiki/Usage#rotationangle) | | TiltDirection | onTiltInAxisX
onTiltInAxisY
onTiltInAxisZ | [Link](https://github.com/nisrulz/sensey/wiki/Usage#tiltdirection) | | Scoop | onScooped | [Link](https://github.com/nisrulz/sensey/wiki/Usage#scoop) | | PickupDevice | onDevicePickedUp
onDevicePutDown | [Link](https://github.com/nisrulz/sensey/wiki/Usage#pickupdevice) | | Steps | stepInformation | [Link](https://github.com/nisrulz/sensey/wiki/Usage#steps) | | TouchType | onDoubleTap
onScroll(direction)
onSingleTap
onSwipeLeft
onSwipeRight
onLongPress
onTwoFingerSingleTap
onThreeFingerSingleTap | [Link](https://github.com/nisrulz/sensey/wiki/Usage#touchtype) | * Java 调用示例 ** - To initialize Sensey under your `onActive()` in the ability/abilitySlice, call ```java Sensey.getInstance().init(context); ``` - To stop Sensey, under your `onInactive()` in the ability/abilitySlice, call ```java // *** IMPORTANT *** // Stop Sensey and release the context held by it Sensey.getInstance().stop(); ``` - Next to enable shake detection - Create an instance of ShakeListener ```java ShakeDetector.ShakeListener shakeListener=new ShakeDetector.ShakeListener() { @Override public void onShakeDetected() { // Shake detected, do something } @Override public void onShakeStopped() { // Shake stopped, do something } }; ``` - Now to start listening for Shake gesture, pass the instance `shakeListener` to `startShakeDetection()` function ```java Sensey.getInstance().startShakeDetection(shakeListener); ``` If you want to modify the `threshold` and `time` before declaring that shake gesture is stopped, use ```java Sensey.getInstance().startShakeDetection(threshold,timeBeforeDeclaringShakeStopped,shakeListener); ``` - To stop listening for Shake gesture, pass the instance `shakeListener` to `stopShakeDetection()` function ```java Sensey.getInstance().stopShakeDetection(shakeListener); ``` #### 测试信息 CodeCheck代码测试无异常 CloudTest代码测试无异常 安全病毒安全检测通过 当前版本demo功能与原组件基本无差异 #### 版本迭代 - 1.0.1 #### 版权和许可信息 Licensed under the Apache License, Version 2.0, [click here for the full license](/LICENSE.txt).