summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorJorim Jaggi <jjaggi@google.com>2014-05-12 19:30:05 +0200
committerJorim Jaggi <jjaggi@google.com>2014-05-12 20:28:28 +0200
commitfc1a824ec1453a84d9c53837df4ab93eca591a5f (patch)
tree705aa3ded8a5189b491aaf21012dfc58e033c6b7 /packages
parentbc5f496e470e64917367abf6730e68ace6def88e (diff)
downloadframeworks_base-fc1a824ec1453a84d9c53837df4ab93eca591a5f.zip
frameworks_base-fc1a824ec1453a84d9c53837df4ab93eca591a5f.tar.gz
frameworks_base-fc1a824ec1453a84d9c53837df4ab93eca591a5f.tar.bz2
Directly start to collapse QS when overscrolling.
Change-Id: I33ec42fd0fe7344c269e31e9798e036e8a0532a0
Diffstat (limited to 'packages')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java53
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java19
2 files changed, 71 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 8387e36..6132ed2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -58,10 +58,18 @@ public class NotificationPanelView extends PanelView implements
private int mTrackingPointer;
private VelocityTracker mVelocityTracker;
private boolean mTracking;
+
+ /**
+ * Whether we are currently handling a motion gesture in #onInterceptTouchEvent, but haven't
+ * intercepted yet.
+ */
+ private boolean mIntercepting;
private boolean mQsExpanded;
private float mInitialHeightOnTouch;
private float mInitialTouchX;
private float mInitialTouchY;
+ private float mLastTouchX;
+ private float mLastTouchY;
private float mQsExpansionHeight;
private int mQsMinExpansionHeight;
private int mQsMaxExpansionHeight;
@@ -195,6 +203,7 @@ public class NotificationPanelView extends PanelView implements
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
+ mIntercepting = true;
mInitialTouchY = y;
mInitialTouchX = x;
initVelocityTracker();
@@ -217,6 +226,16 @@ public class NotificationPanelView extends PanelView implements
case MotionEvent.ACTION_MOVE:
final float h = y - mInitialTouchY;
trackMovement(event);
+ if (mTracking) {
+
+ // Already tracking because onOverscrolled was called. We need to update here
+ // so we don't stop for a frame until the next touch event gets handled in
+ // onTouchEvent.
+ setQsExpansion(h + mInitialHeightOnTouch);
+ trackMovement(event);
+ mIntercepting = false;
+ return true;
+ }
if (Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX)
&& shouldIntercept(mInitialTouchX, mInitialTouchY, h)) {
onQsExpansionStarted();
@@ -224,14 +243,29 @@ public class NotificationPanelView extends PanelView implements
mInitialTouchY = y;
mInitialTouchX = x;
mTracking = true;
+ mIntercepting = false;
return true;
}
break;
+
+ case MotionEvent.ACTION_CANCEL:
+ case MotionEvent.ACTION_UP:
+ mIntercepting = false;
+ break;
}
return !mQsExpanded && super.onInterceptTouchEvent(event);
}
@Override
+ public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
+
+ // Block request so we can still intercept the scrolling when QS is expanded.
+ if (!mQsExpanded) {
+ super.requestDisallowInterceptTouchEvent(disallowIntercept);
+ }
+ }
+
+ @Override
public boolean onTouchEvent(MotionEvent event) {
// TODO: Handle doublefinger swipe to notifications again. Look at history for a reference
// implementation.
@@ -299,11 +333,26 @@ public class NotificationPanelView extends PanelView implements
return mQsExpanded || super.onTouchEvent(event);
}
+ @Override
+ public void onOverscrolled(int amount) {
+ if (mIntercepting) {
+ onQsExpansionStarted(amount);
+ mInitialHeightOnTouch = mQsExpansionHeight;
+ mInitialTouchY = mLastTouchY;
+ mInitialTouchX = mLastTouchX;
+ mTracking = true;
+ }
+ }
+
private void onQsExpansionStarted() {
+ onQsExpansionStarted(0);
+ }
+
+ private void onQsExpansionStarted(int overscrollAmount) {
cancelAnimation();
// Reset scroll position and apply that position to the expanded height.
- float height = mQsExpansionHeight - mScrollView.getScrollY();
+ float height = mQsExpansionHeight - mScrollView.getScrollY() - overscrollAmount;
mScrollView.scrollTo(0, 0);
setQsExpansion(height);
}
@@ -361,6 +410,8 @@ public class NotificationPanelView extends PanelView implements
private void trackMovement(MotionEvent event) {
if (mVelocityTracker != null) mVelocityTracker.addMovement(event);
+ mLastTouchX = event.getX();
+ mLastTouchY = event.getY();
}
private void initVelocityTracker() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java
index 46484f3..ba0b66e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ObservableScrollView.java
@@ -27,6 +27,7 @@ import android.widget.ScrollView;
public class ObservableScrollView extends ScrollView {
private Listener mListener;
+ private int mLastOverscrollAmount;
public ObservableScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -58,7 +59,25 @@ public class ObservableScrollView extends ScrollView {
}
}
+ @Override
+ protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY,
+ int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY,
+ boolean isTouchEvent) {
+ mLastOverscrollAmount = Math.max(0, scrollY + deltaY - getMaxScrollY());
+ return super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY,
+ maxOverScrollX, maxOverScrollY, isTouchEvent);
+ }
+
+ @Override
+ protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
+ super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
+ if (mListener != null && mLastOverscrollAmount > 0) {
+ mListener.onOverscrolled(mLastOverscrollAmount);
+ }
+ }
+
public interface Listener {
void onScrollChanged();
+ void onOverscrolled(int amount);
}
}