Merge "launcher: enable swipe down to open focused app" into sc-v2-dev am: 2e15dde6b7

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15297765

Change-Id: Icd86b4b23ee6053be895589dd2287535ab60d67f
This commit is contained in:
Thales Lima
2021-07-16 13:35:28 +00:00
committed by Automerger Merge Worker
2 changed files with 25 additions and 21 deletions
@@ -34,7 +34,6 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.touch.BaseSwipeDetector;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.touch.SingleAxisSwipeDetector;
@@ -158,26 +157,21 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
mTaskBeingDragged = view;
int upDirection = mRecentsView.getPagedOrientationHandler()
.getUpDirection(mIsRtl);
if (!SysUINavigationMode.getMode(mActivity).hasGestures || (
mActivity.getDeviceProfile().isTablet
&& FeatureFlags.ENABLE_OVERVIEW_GRID.get())) {
// Don't allow swipe down to open if we don't support swipe up
// to enter overview, or when grid layout is enabled.
directionsToDetectScroll = upDirection;
mAllowGoingUp = true;
mAllowGoingDown = false;
} else {
// The task can be dragged up to dismiss it,
// and down to open if it's the current page.
mAllowGoingUp = true;
if (i == mRecentsView.getCurrentPage()) {
mAllowGoingDown = true;
directionsToDetectScroll = DIRECTION_BOTH;
} else {
mAllowGoingDown = false;
directionsToDetectScroll = upDirection;
}
}
// The task can be dragged up to dismiss it
mAllowGoingUp = true;
// The task can be dragged down to open it if:
// - It's the current page
// - We support gestures to enter overview
// - It's the focused task if in grid view
// - The task is snapped
mAllowGoingDown = i == mRecentsView.getCurrentPage()
&& SysUINavigationMode.getMode(mActivity).hasGestures
&& (!mRecentsView.showAsGrid() || mTaskBeingDragged.isFocusedTask())
&& mRecentsView.isTaskSnapped(i);
directionsToDetectScroll = mAllowGoingDown ? DIRECTION_BOTH : upDirection;
break;
}
}
@@ -949,6 +949,16 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
&& taskEnd <= end);
}
/**
* Returns true if the task is snapped.
*
* @param taskIndex the index of the task
*/
public boolean isTaskSnapped(int taskIndex) {
return getScrollForPage(taskIndex + mTaskViewStartIndex)
== getPagedOrientationHandler().getPrimaryScroll(this);
}
public TaskView getTaskView(int taskId) {
for (int i = 0; i < getTaskViewCount(); i++) {
TaskView taskView = getTaskViewAt(i);