summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2015-04-17 19:11:01 (GMT)
committerWinson Chung <winsonc@google.com>2015-04-17 19:51:27 (GMT)
commit466663edeec8d889aca37612aab2ab2d67da4ad8 (patch)
tree52211b77ce7d643cf53c4ef4e20dee227bbe641b
parent9cbea78b19badc86299b0ac4254799d8a3bf9684 (diff)
downloadandroid_packages_apps_Trebuchet-466663edeec8d889aca37612aab2ab2d67da4ad8.zip
android_packages_apps_Trebuchet-466663edeec8d889aca37612aab2ab2d67da4ad8.tar.gz
android_packages_apps_Trebuchet-466663edeec8d889aca37612aab2ab2d67da4ad8.tar.bz2
Accounting for recent changes in padding when detecting backgound taps to close AllApps.
- Also ensuring that we keep the search bar visible in all apps only if it is being overridden. Change-Id: Iba980ecec255da80aff8ff57b42ad99d70a2122a
-rw-r--r--src/com/android/launcher3/AppsContainerRecyclerView.java15
-rw-r--r--src/com/android/launcher3/AppsContainerView.java65
-rw-r--r--src/com/android/launcher3/Workspace.java4
3 files changed, 65 insertions, 19 deletions
diff --git a/src/com/android/launcher3/AppsContainerRecyclerView.java b/src/com/android/launcher3/AppsContainerRecyclerView.java
index bb2aeb0..16244ee 100644
--- a/src/com/android/launcher3/AppsContainerRecyclerView.java
+++ b/src/com/android/launcher3/AppsContainerRecyclerView.java
@@ -196,21 +196,6 @@ public class AppsContainerRecyclerView extends RecyclerView
}
break;
case MotionEvent.ACTION_UP:
- ViewConfiguration viewConfig = ViewConfiguration.get(getContext());
- float dx = ev.getX() - mDownX;
- float dy = ev.getY() - mDownY;
- float distance = (float) Math.sqrt(dx * dx + dy * dy);
- if (distance < viewConfig.getScaledTouchSlop()) {
- Rect backgroundPadding = new Rect();
- getBackground().getPadding(backgroundPadding);
- boolean isOutsideBounds = ev.getX() < backgroundPadding.left ||
- ev.getX() > (getWidth() - backgroundPadding.right);
- if (isOutsideBounds) {
- Launcher launcher = (Launcher) getContext();
- launcher.showWorkspace(true);
- }
- }
- // Fall through
case MotionEvent.ACTION_CANCEL:
mDraggingFastScroller = false;
animateFastScrollerVisibility(false);
diff --git a/src/com/android/launcher3/AppsContainerView.java b/src/com/android/launcher3/AppsContainerView.java
index 52bc6b6..376f888 100644
--- a/src/com/android/launcher3/AppsContainerView.java
+++ b/src/com/android/launcher3/AppsContainerView.java
@@ -63,7 +63,8 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett
private EditText mSearchBarView;
private int mNumAppsPerRow;
- private Point mLastTouchDownPos = new Point();
+ private Point mLastTouchDownPos = new Point(-1, -1);
+ private Point mLastTouchPos = new Point();
private Rect mInsets = new Rect();
private Rect mFixedBounds = new Rect();
private int mContentMarginStart;
@@ -235,11 +236,21 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett
}
@Override
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ return handleTouchEvent(ev);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ return handleTouchEvent(ev);
+ }
+
+ @Override
public boolean onTouch(View v, MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
- mLastTouchDownPos.set((int) ev.getX(), (int) ev.getY());
+ mLastTouchPos.set((int) ev.getX(), (int) ev.getY());
break;
}
return false;
@@ -256,7 +267,7 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett
if (!mLauncher.isDraggingEnabled()) return false;
// Start the drag
- mLauncher.getWorkspace().beginDragShared(v, mLastTouchDownPos, this, false);
+ mLauncher.getWorkspace().beginDragShared(v, mLastTouchPos, this, false);
// We delay entering spring-loaded mode slightly to make sure the UI
// thready is free of any work.
@@ -429,6 +440,54 @@ public class AppsContainerView extends FrameLayout implements DragSource, Insett
}
/**
+ * Handles the touch events to dismiss all apps when clicking outside the bounds of the
+ * recycler view.
+ */
+ private boolean handleTouchEvent(MotionEvent ev) {
+ LauncherAppState app = LauncherAppState.getInstance();
+ DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
+
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ if (!mFixedBounds.isEmpty()) {
+ // Outset the fixed bounds and check if the touch is outside all apps
+ Rect tmpRect = new Rect(mFixedBounds);
+ tmpRect.inset(-grid.allAppsIconSizePx / 2, 0);
+ if (ev.getX() < tmpRect.left || ev.getX() > tmpRect.right) {
+ mLastTouchDownPos.set((int) ev.getX(), (int) ev.getY());
+ return true;
+ }
+ } else {
+ // Check if the touch is outside all apps
+ if (ev.getX() < getPaddingLeft() ||
+ ev.getX() > (getWidth() - getPaddingRight())) {
+ mLastTouchDownPos.set((int) ev.getX(), (int) ev.getY());
+ return true;
+ }
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ if (mLastTouchDownPos.x > -1) {
+ ViewConfiguration viewConfig = ViewConfiguration.get(getContext());
+ float dx = ev.getX() - mLastTouchDownPos.x;
+ float dy = ev.getY() - mLastTouchDownPos.y;
+ float distance = (float) Math.hypot(dx, dy);
+ if (distance < viewConfig.getScaledTouchSlop()) {
+ // The background was clicked, so just go home
+ Launcher launcher = (Launcher) getContext();
+ launcher.showWorkspace(true);
+ return true;
+ }
+ }
+ // Fall through
+ case MotionEvent.ACTION_CANCEL:
+ mLastTouchDownPos.set(-1, -1);
+ break;
+ }
+ return false;
+ }
+
+ /**
* Update the padding of the Apps view and children. To ensure that the RecyclerView has the
* full width to handle touches right to the edge of the screen, we only apply the top and
* bottom padding to the AppsContainerView and then the left/right padding on the RecyclerView
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 043ecb0..671dcaa 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2264,7 +2264,9 @@ public class Workspace extends SmoothPagedView
float finalHotseatAndPageIndicatorAlpha = (stateIsNormal || stateIsSpringLoaded) ? 1f : 0f;
float finalOverviewPanelAlpha = stateIsOverview ? 1f : 0f;
// We keep the search bar visible on the workspace and in AllApps now
- float finalSearchBarAlpha = (stateIsNormal || stateIsNormalHidden) ? 1f : 0f;
+ boolean showSearchBar = stateIsNormal ||
+ (mLauncher.isAllAppsSearchOverridden() && stateIsNormalHidden);
+ float finalSearchBarAlpha = showSearchBar ? 1f : 0f;
float finalWorkspaceTranslationY = stateIsOverview || stateIsOverviewHidden ?
getOverviewModeTranslationY() : 0;