summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI
diff options
context:
space:
mode:
authorJames Cook <jamescook@google.com>2015-03-17 21:16:28 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-03-17 21:16:29 +0000
commit4d87285c317d7ee6febbe5cc2b8eb0ca83eb9681 (patch)
tree4ea205d5f206b1fa1e07ca9a3a6dd2aac89ee811 /packages/SystemUI
parent1938a389e7b5c5c11b5d6bc12a49e3ad78c2437e (diff)
parent4bd79b7556177a3d52d43916f8dd52c44017048a (diff)
downloadframeworks_base-4d87285c317d7ee6febbe5cc2b8eb0ca83eb9681.zip
frameworks_base-4d87285c317d7ee6febbe5cc2b8eb0ca83eb9681.tar.gz
frameworks_base-4d87285c317d7ee6febbe5cc2b8eb0ca83eb9681.tar.bz2
Merge "Recents: Tapping on background returns to launcher"
Diffstat (limited to 'packages/SystemUI')
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
index 6cdddc5..509560eb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewTouchHandler.java
@@ -24,6 +24,7 @@ import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewParent;
import com.android.systemui.recents.Constants;
+import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsConfiguration;
import java.util.List;
@@ -53,6 +54,8 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
int mScrollTouchSlop;
// The page touch slop is used to calculate when we start swiping
float mPagingTouchSlop;
+ // Used to calculate when a tap is outside a task view rectangle.
+ final int mWindowTouchSlop;
SwipeHelper mSwipeHelper;
boolean mInterceptedBySwipeHelper;
@@ -64,6 +67,7 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mScrollTouchSlop = configuration.getScaledTouchSlop();
mPagingTouchSlop = configuration.getScaledPagingTouchSlop();
+ mWindowTouchSlop = configuration.getScaledWindowTouchSlop();
mSv = sv;
mScroller = scroller;
mConfig = config;
@@ -314,6 +318,9 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
} else if (mScroller.isScrollOutOfBounds()) {
// Animate the scroll back into bounds
mScroller.animateBoundScroll();
+ } else if (mActiveTaskView == null) {
+ // This tap didn't start on a task.
+ maybeHideRecentsFromBackgroundTap((int) ev.getX(), (int) ev.getY());
}
mActivePointerId = INACTIVE_POINTER_ID;
@@ -351,6 +358,34 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
return true;
}
+ /** Hides recents if the up event at (x, y) is a tap on the background area. */
+ void maybeHideRecentsFromBackgroundTap(int x, int y) {
+ // Ignore the up event if it's too far from its start position. The user might have been
+ // trying to scroll or swipe.
+ int dx = Math.abs(mInitialMotionX - x);
+ int dy = Math.abs(mInitialMotionY - y);
+ if (dx > mScrollTouchSlop || dy > mScrollTouchSlop) {
+ return;
+ }
+
+ // Shift the tap position toward the center of the task stack and check to see if it would
+ // have hit a view. The user might have tried to tap on a task and missed slightly.
+ int shiftedX = x;
+ if (x > mSv.getTouchableRegion().centerX()) {
+ shiftedX -= mWindowTouchSlop;
+ } else {
+ shiftedX += mWindowTouchSlop;
+ }
+ if (findViewAtPoint(shiftedX, y) != null) {
+ return;
+ }
+
+ // The user intentionally tapped on the background, which is like a tap on the "desktop".
+ // Hide recents and transition to the launcher.
+ Recents recents = Recents.getInstanceAndStartIfNeeded(mSv.getContext());
+ recents.hideRecents(false /* altTab */, true /* homeKey */);
+ }
+
/** Handles generic motion events */
public boolean onGenericMotionEvent(MotionEvent ev) {
if ((ev.getSource() & InputDevice.SOURCE_CLASS_POINTER) ==