diff --git a/.travis.yml b/.travis.yml index 32af2e8b..c84fc407 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,8 @@ android: - platform-tools - extra-android-m2repository - extra-google-m2repository - - build-tools-23.0.3 - - android-23 + - build-tools-26.0.0 + - android-26 # Enable travis container based infrastructure sudo: false diff --git a/README.md b/README.md index 15029b4d..52da9c4d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.sothree.slidinguppanel/library/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.sothree.slidinguppanel/library) [![Badge](http://www.libtastic.com/static/osbadges/30.png)](http://www.libtastic.com/technology/30/) +**Note:** we are **not** actively responding to issues right now. If you find a bug, please submit a PR. + Android Sliding Up Panel ========================= @@ -27,7 +29,7 @@ dependencies { repositories { mavenCentral() } - compile 'com.sothree.slidinguppanel:library:3.3.1' + compile 'com.sothree.slidinguppanel:library:3.4.0' } ``` @@ -139,6 +141,9 @@ If you have an awesome pull request, send it over! ### Changelog +* 3.4.0 + * Use the latest support library 26 and update the min version to 14. + * Bug fixes * 3.3.1 * Lots of bug fixes from various pull requests. * Removed the nineoldandroids dependency. Use ViewCompat instead. diff --git a/build.gradle b/build.gradle index d49db880..53d5638f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { - mavenCentral() + jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' + classpath 'com.android.tools.build:gradle:2.3.2' } } @@ -18,11 +18,14 @@ allprojects { group = GROUP repositories { - mavenCentral() + jcenter() + maven { + url "https://maven.google.com" + } } } task wrapper(type: Wrapper) { - gradleVersion = '2.13' + gradleVersion = '3.3' distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip" } diff --git a/demo/build.gradle b/demo/build.gradle index 86f0df2e..02b6f063 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -1,21 +1,21 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" + compileSdkVersion 26 + buildToolsVersion "26.0.1" lintOptions { abortOnError false } defaultConfig { - minSdkVersion 11 - targetSdkVersion 23 + minSdkVersion 14 + targetSdkVersion 26 } } dependencies { - compile 'com.android.support:support-v4:23.4.0' - compile 'com.android.support:appcompat-v7:23.4.0' + compile 'com.android.support:support-v4:26.0.2' + compile 'com.android.support:appcompat-v7:26.0.2' compile project(':library') } diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index b818fef0..a37bd78c 100644 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -1,12 +1,15 @@ + xmlns:tools="http://schemas.android.com/tools" + android:versionCode="17" + android:versionName="3.4.0"> + android:minSdkVersion="14" + android:targetSdkVersion="17" + tools:overrideLibrary="android.support.v7.appcompat,android.support.graphics.drawavle" + /> + android:versionCode="17" + android:versionName="3.4.0"> + android:minSdkVersion="14" /> diff --git a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java index 5004bcdb..424a008c 100644 --- a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java +++ b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java @@ -13,6 +13,7 @@ import android.support.v4.view.MotionEventCompat; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; +import android.util.Log; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; @@ -207,6 +208,7 @@ public enum PanelState { */ private boolean mIsTouchEnabled; + private float mPrevMotionX; private float mPrevMotionY; private float mInitialMotionX; private float mInitialMotionY; @@ -961,15 +963,24 @@ public boolean dispatchTouchEvent(MotionEvent ev) { return super.dispatchTouchEvent(ev); } + final float x = ev.getX(); final float y = ev.getY(); if (action == MotionEvent.ACTION_DOWN) { mIsScrollableViewHandlingTouch = false; + mPrevMotionX = x; mPrevMotionY = y; } else if (action == MotionEvent.ACTION_MOVE) { + float dx = x - mPrevMotionX; float dy = y - mPrevMotionY; + mPrevMotionX = x; mPrevMotionY = y; + if (Math.abs(dx) > Math.abs(dy)) { + // Scrolling horizontally, so ignore + return super.dispatchTouchEvent(ev); + } + // If the scroll view isn't under the touch, pass the // event along to the dragView. if (!isViewUnder(mScrollableView, (int) mInitialMotionX, (int) mInitialMotionY)) { @@ -1086,6 +1097,13 @@ public PanelState getPanelState() { * @param state - new panel state */ public void setPanelState(PanelState state) { + + // Abort any running animation, to allow state change + if(mDragHelper.getViewDragState() == ViewDragHelper.STATE_SETTLING){ + Log.d(TAG, "View is settling. Aborting animation."); + mDragHelper.abort(); + } + if (state == null || state == PanelState.DRAGGING) { throw new IllegalArgumentException("Panel state cannot be null or DRAGGING."); } @@ -1216,6 +1234,7 @@ boolean smoothSlideTo(float slideOffset, int velocity) { } int panelTop = computePanelTopPosition(slideOffset); + if (mDragHelper.smoothSlideViewTo(mSlideableView, mSlideableView.getLeft(), panelTop)) { setAllChildrenVisible(); ViewCompat.postInvalidateOnAnimation(this);