diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..0650135 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,11 @@ +version: 2 +jobs: + build: + docker: + - image: circleci/android:api-28-alpha # gcloud is baked into this image + steps: + - checkout + - run: + name: Build debug APK and release APK + command: | + ./gradlew build diff --git a/README.md b/README.md index 0ed40eb..cea639f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Android Gesture Detectors Framework =================================== +[![CircleCI](https://circleci.com/gh/mariopce/android-gesture-detectors/tree/master.svg?style=svg)](https://circleci.com/gh/mariopce/android-gesture-detectors/tree/master) + Introduction ------------ diff --git a/build.gradle b/build.gradle index b01c392..4505dd2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,18 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { + google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.3' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.android.tools.build:gradle:3.3.0' } } allprojects { repositories { + google() + jcenter() mavenCentral() } } diff --git a/gradle.properties b/gradle.properties index fb959d0..f7344a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ VERSION_NAME=1.0 -VERSION_CODE=2 +VERSION_CODE=3 GROUP=com.almeros.android-gesture-detectors POM_DESCRIPTION=Gesture detector framework for multitouch handling on Android, based on Android's ScaleGestureDetector @@ -15,7 +15,7 @@ POM_DEVELOPER_NAME=Almeros Thies ANDROID_MIN_SDK=8 ANDROID_TARGET_SDK=21 -ANDROID_COMPILE_SDK=21 -ANDROID_BUILD_TOOLS_VERSION=25.0.0 +ANDROID_COMPILE_SDK=28 +ANDROID_BUILD_TOOLS_VERSION=28.0.3 org.gradle.jvmargs=-Xmx1536M diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 123157e..9dc40d5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml index 8bef032..1ddd256 100644 --- a/library/src/main/AndroidManifest.xml +++ b/library/src/main/AndroidManifest.xml @@ -2,16 +2,6 @@ - - - - - - diff --git a/library/src/main/java/com/almeros/android/multitouch/RotateGestureDetector.java b/library/src/main/java/com/almeros/android/multitouch/RotateGestureDetector.java index ba27af1..fd98561 100644 --- a/library/src/main/java/com/almeros/android/multitouch/RotateGestureDetector.java +++ b/library/src/main/java/com/almeros/android/multitouch/RotateGestureDetector.java @@ -139,6 +139,7 @@ protected void handleInProgressEvent(int actionCode, MotionEvent event){ // a certain limit. This can help filter shaky data as a // finger is lifted. if (mCurrPressure / mPrevPressure > PRESSURE_THRESHOLD) { + determineFocusPoint(event); final boolean updatePrevious = mListener.onRotate(this); if (updatePrevious) { mPrevEvent.recycle(); @@ -155,7 +156,6 @@ protected void resetState() { mSloppyGesture = false; } - /** * Return the rotation difference from the previous rotate event to the current * event. diff --git a/library/src/main/java/com/almeros/android/multitouch/ShoveGestureDetector.java b/library/src/main/java/com/almeros/android/multitouch/ShoveGestureDetector.java index cb8f818..515b7d7 100644 --- a/library/src/main/java/com/almeros/android/multitouch/ShoveGestureDetector.java +++ b/library/src/main/java/com/almeros/android/multitouch/ShoveGestureDetector.java @@ -143,6 +143,7 @@ protected void handleInProgressEvent(int actionCode, MotionEvent event){ // finger is lifted. Also check that shove is meaningful. if (mCurrPressure / mPrevPressure > PRESSURE_THRESHOLD && Math.abs(getShovePixelsDelta()) > 0.5f) { + determineFocusPoint(event); final boolean updatePrevious = mListener.onShove(this); if (updatePrevious) { mPrevEvent.recycle(); diff --git a/library/src/main/java/com/almeros/android/multitouch/TwoFingerGestureDetector.java b/library/src/main/java/com/almeros/android/multitouch/TwoFingerGestureDetector.java index 4b031c7..0abffbb 100644 --- a/library/src/main/java/com/almeros/android/multitouch/TwoFingerGestureDetector.java +++ b/library/src/main/java/com/almeros/android/multitouch/TwoFingerGestureDetector.java @@ -2,7 +2,6 @@ import android.content.Context; import android.util.DisplayMetrics; -import android.util.FloatMath; import android.view.MotionEvent; import android.view.ViewConfiguration; @@ -36,10 +35,12 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector { protected float mPrevFingerDiffY; protected float mCurrFingerDiffX; protected float mCurrFingerDiffY; - + protected float mFocusX; + protected float mFocusY; + private float mCurrLen; private float mPrevLen; - + public TwoFingerGestureDetector(Context context) { super(context); @@ -92,7 +93,7 @@ public float getCurrentSpan() { if (mCurrLen == -1) { final float cvx = mCurrFingerDiffX; final float cvy = mCurrFingerDiffY; - mCurrLen = FloatMath.sqrt(cvx*cvx + cvy*cvy); + mCurrLen = (float) Math.sqrt(cvx*cvx + cvy*cvy); } return mCurrLen; } @@ -107,11 +108,37 @@ public float getPreviousSpan() { if (mPrevLen == -1) { final float pvx = mPrevFingerDiffX; final float pvy = mPrevFingerDiffY; - mPrevLen = FloatMath.sqrt(pvx*pvx + pvy*pvy); + mPrevLen = (float) Math.sqrt(pvx*pvx + pvy*pvy); } return mPrevLen; } - + + /** + * Get gesture focus X point. + * @return focus X point of gesture. + */ + public float getFocusX() { + return mFocusX; + } + + + /** + * Get gesture focus Y point. + * @return focus Y point of gesture. + */ + public float getFocusY() { + return mFocusY; + } + + /** + * Calculate focus point for gesture. + * @param curr current motion event used to calculate focus point. + */ + protected void determineFocusPoint(MotionEvent curr) { + mFocusX = (curr.getX(0) + curr.getX(1)) * 0.5f; + mFocusY = (curr.getY(0) + curr.getY(1)) * 0.5f; + } + /** * MotionEvent has no getRawX(int) method; simulate it pending future API approval. * @param event