From b66675a36d5daec4aea4470cb5c804c54edb06cd Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 15 May 2020 16:16:17 -0700 Subject: [PATCH] Delegate horizontal scrolls from the Hotseat to the Workspace => Before this change, scrolling horizontally on the the hotseat area was a no-op => This is a mild usability issue (or arguably WAI) for the default grid, but for larger grids it feels really broken as you have to reach very high just to scroll to another page. issue 156507399 Test: manual. Also verified that swipe up still works and goes through the same code path. Change-Id: I760aca473dd36bc8cfb906cb58e897e2ab7fd1d9 --- src/com/android/launcher3/Hotseat.java | 29 +++++++++++++++++++++++++ src/com/android/launcher3/Launcher.java | 1 + 2 files changed, 30 insertions(+) diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index be941f2e56..1c157c26d2 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -38,6 +38,8 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta @ViewDebug.ExportedProperty(category = "launcher") private boolean mHasVerticalHotseat; + private Workspace mWorkspace; + private boolean mSendTouchToWorkspace; public Hotseat(Context context) { this(context, null); @@ -112,8 +114,35 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta InsettableFrameLayout.dispatchInsets(this, insets); } + public void setWorkspace(Workspace w) { + mWorkspace = w; + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + // We allow horizontal workspace scrolling from within the Hotseat. We do this by delegating + // touch intercept the Workspace, and if it intercepts, delegating touch to the Workspace + // for the remainder of the this input stream. + int yThreshold = getMeasuredHeight() - getPaddingBottom(); + if (mWorkspace != null && ev.getY() <= yThreshold) { + mSendTouchToWorkspace = mWorkspace.onInterceptTouchEvent(ev); + return mSendTouchToWorkspace; + } + return false; + } + @Override public boolean onTouchEvent(MotionEvent event) { + // See comment in #onInterceptTouchEvent + if (mSendTouchToWorkspace) { + final int action = event.getAction(); + switch (action & MotionEvent.ACTION_MASK) { + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: + mSendTouchToWorkspace = false; + } + return mWorkspace.onTouchEvent(event); + } return event.getY() > getCellHeight(); } } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 59476dd5a1..1f84c42f22 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1116,6 +1116,7 @@ public class Launcher extends StatefulActivity implements Launche mWorkspace.initParentViews(mDragLayer); mOverviewPanel = findViewById(R.id.overview_panel); mHotseat = findViewById(R.id.hotseat); + mHotseat.setWorkspace(mWorkspace); mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION