summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI
diff options
context:
space:
mode:
authorJames Cook <jamescook@google.com>2015-03-17 07:33:28 -0700
committerJames Cook <jamescook@google.com>2015-03-17 10:59:44 -0700
commit4bd79b7556177a3d52d43916f8dd52c44017048a (patch)
treec68a0902f3d2cd84f76fd5d919fb8a2439bb5c81 /packages/SystemUI
parent11b07c05ac5d2c3e9c4a4f5c83047091ed8e50bc (diff)
downloadframeworks_base-4bd79b7556177a3d52d43916f8dd52c44017048a.zip
frameworks_base-4bd79b7556177a3d52d43916f8dd52c44017048a.tar.gz
frameworks_base-4bd79b7556177a3d52d43916f8dd52c44017048a.tar.bz2
Recents: Tapping on background returns to launcher
Conceptually the area outside the recents task stack looks like a "desktop". Make a non-scroll tap outside the task stack close recents and return to the launcher. Bug: 19271451 Change-Id: I9e639d6b5c6127bc37e1003152ef7a6fcbc2c2f3
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) ==