summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2016-06-13 19:49:07 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-06-13 19:49:07 +0000
commit556571ebb3781abdfc837dd4468e63a77de3cc04 (patch)
tree1df545cd560e04783b6c82c4acb3896897676e4d
parentbff2c15f2fcf706249e2eb22f846c221ab422dba (diff)
parent6041eb248a4a8fe06769c8e5977255b54153bdcd (diff)
downloadandroid_packages_apps_Trebuchet-556571ebb3781abdfc837dd4468e63a77de3cc04.tar.gz
android_packages_apps_Trebuchet-556571ebb3781abdfc837dd4468e63a77de3cc04.tar.bz2
android_packages_apps_Trebuchet-556571ebb3781abdfc837dd4468e63a77de3cc04.zip
Merge \"All apps container should not intercept touch during animation.\" into ub-launcher3-calgary
am: 6041eb248a Change-Id: I29292ad955af83792d42bf6a89072e7c688e22af
-rw-r--r--src/com/android/launcher3/allapps/AllAppsTransitionController.java24
-rw-r--r--src/com/android/launcher3/allapps/VerticalPullDetector.java65
2 files changed, 66 insertions, 23 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index d70ee477a..7f047d5cc 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -54,6 +54,8 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private float mProgressTransY; // numerator
private float mTranslation = -1; // denominator
+ private static final float RECATCH_REJECTION_FRACTION = .0875f;
+
private long mAnimationDuration;
private float mCurY;
@@ -73,19 +75,19 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
mNoIntercept = false;
if (mLauncher.getWorkspace().isInOverviewMode() || mLauncher.isWidgetsViewVisible()) {
mNoIntercept = true;
- }
- if (mLauncher.isAllAppsVisible() &&
+ } else if (mLauncher.isAllAppsVisible() &&
!mAppsView.shouldContainerScroll(ev.getX(), ev.getY())) {
mNoIntercept = true;
+ } else {
+ mDetector.setDetectableScrollConditions(mLauncher.isAllAppsVisible() /* down */,
+ isInDisallowRecatchTopZone(), isInDisallowRecatchBottomZone());
}
}
if (mNoIntercept) {
return false;
- } else {
- mDetector.setScrollDirectionDown(mLauncher.isAllAppsVisible());
}
mDetector.onTouchEvent(ev);
- return mDetector.mScrolling;
+ return mDetector.shouldIntercept();
}
@Override
@@ -93,6 +95,14 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
return mDetector.onTouchEvent(ev);
}
+ private boolean isInDisallowRecatchTopZone() {
+ return mProgressTransY / mTranslation < RECATCH_REJECTION_FRACTION;
+ }
+
+ private boolean isInDisallowRecatchBottomZone() {
+ return mProgressTransY / mTranslation > 1 - RECATCH_REJECTION_FRACTION;
+ }
+
private void init() {
if (mAppsView != null) {
return;
@@ -267,7 +277,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
return;
}
- if (!mDetector.mScrolling) {
+ if (mDetector.isRestingState()) {
preparePull(true);
mAnimationDuration = duration;
}
@@ -311,7 +321,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
if ((mAppsView = mLauncher.getAppsView()) == null || animationOut == null){
return;
}
- if(!mDetector.mScrolling) {
+ if(mDetector.isRestingState()) {
preparePull(true);
mAnimationDuration = duration;
}
diff --git a/src/com/android/launcher3/allapps/VerticalPullDetector.java b/src/com/android/launcher3/allapps/VerticalPullDetector.java
index 0c3698de2..7df63e040 100644
--- a/src/com/android/launcher3/allapps/VerticalPullDetector.java
+++ b/src/com/android/launcher3/allapps/VerticalPullDetector.java
@@ -15,6 +15,8 @@ public class VerticalPullDetector {
private float mTouchSlop;
private boolean mScrollDown; // if false, only scroll up will be reported.
+ private boolean mDisallowRecatchFromTop;
+ private boolean mDisallowRecatchFromBottom;
/**
* The minimum release velocity in pixels per millisecond that triggers fling..
@@ -28,7 +30,23 @@ public class VerticalPullDetector {
public static final float SCROLL_VELOCITY_DAMPENING_RC = 1000f / (2f * (float) Math.PI * 10);
/* Scroll state, this is set to true during dragging and animation. */
- boolean mScrolling;
+ private State mState = State.NONE;
+ enum State {NONE, DRAG, SCROLLING};
+
+ private void setState(State newState) {
+ if (DBG) {
+ Log.d(TAG, mState + "->" + newState);
+ }
+ mState = newState;
+ }
+
+ public boolean shouldIntercept() {
+ return mState == State.DRAG;
+ }
+
+ public boolean isRestingState() {
+ return mState == State.NONE;
+ }
private float mDownX;
private float mDownY;
@@ -53,9 +71,6 @@ public class VerticalPullDetector {
}
interface Listener{
- /**
- * @param start when should
- */
void onScrollStart(boolean start);
boolean onScroll(float displacement, float velocity);
void onScrollEnd(float velocity, boolean fling);
@@ -65,8 +80,11 @@ public class VerticalPullDetector {
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
}
- public void setScrollDirectionDown(boolean scrollDown) {
+ public void setDetectableScrollConditions(boolean scrollDown, boolean disallowRecatchFromTop,
+ boolean disallowRecatchFromBottom) {
mScrollDown = scrollDown;
+ mDisallowRecatchFromTop = disallowRecatchFromTop;
+ mDisallowRecatchFromBottom = disallowRecatchFromBottom;
}
private boolean shouldScrollStart() {
@@ -85,6 +103,21 @@ public class VerticalPullDetector {
return false;
}
+ private boolean shouldRecatchScrollStart() {
+ if (!mDisallowRecatchFromBottom && !mDisallowRecatchFromTop) {
+ return true;
+ }
+ if (mDisallowRecatchFromTop && mDisplacementY > mTouchSlop) {
+ mDisallowRecatchFromTop = false;
+ return true;
+ }
+ if (mDisallowRecatchFromBottom && mDisplacementY < -mTouchSlop) {
+ mDisallowRecatchFromBottom = false;
+ return true;
+ }
+ return false;
+ }
+
public boolean onTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
@@ -93,8 +126,7 @@ public class VerticalPullDetector {
mDownY = ev.getY();
mLastDisplacement = 0;
mVelocity = 0;
-
- if (mScrolling) {
+ if (mState == State.SCROLLING && shouldRecatchScrollStart()){
reportScrollStart(true /* recatch */);
}
break;
@@ -103,18 +135,22 @@ public class VerticalPullDetector {
mDisplacementY = ev.getY() - mDownY;
mVelocity = computeVelocity(ev, mVelocity);
- if (!mScrolling && shouldScrollStart()) {
- mScrolling = true;
+ if (mState == State.SCROLLING && shouldRecatchScrollStart()){
+ setState(State.DRAG);
+ reportScrollStart(true /* recatch */);
+ }
+ if (mState == State.NONE && shouldScrollStart()) {
+ setState(State.DRAG);
reportScrollStart(false /* recatch */);
}
- if (mScrolling && mListener != null) {
+ if (mState == State.DRAG && mListener != null) {
reportScroll();
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
// These are synthetic events and there is no need to update internal values.
- if (mScrolling && mListener != null) {
+ if (mState == State.DRAG && mListener != null) {
reportScrollEnd();
}
break;
@@ -132,7 +168,7 @@ public class VerticalPullDetector {
}
public void finishedScrolling() {
- mScrolling = false;
+ setState(State.NONE);
}
private boolean reportScrollStart(boolean recatch) {
@@ -170,6 +206,7 @@ public class VerticalPullDetector {
mDisplacementY, mVelocity));
}
mListener.onScrollEnd(mVelocity, Math.abs(mVelocity) > RELEASE_VELOCITY_PX_MS);
+ setState(State.SCROLLING);
}
/**
* Computes the damped velocity using the two motion events and the previous velocity.
@@ -187,10 +224,6 @@ public class VerticalPullDetector {
return interpolate(previousVelocity, velocity, alpha);
}
- private float computeDisplacement(MotionEvent to) {
- return to.getY() - mDownY;
- }
-
private float computeDelta(MotionEvent to) {
return to.getY() - mLastY;
}