summaryrefslogtreecommitdiffstats
path: root/quickstep/recents_ui_overrides/src/com/android/launcher3
diff options
context:
space:
mode:
authorKevin <kevhan@google.com>2019-01-16 10:57:04 -0800
committerKevin <kevhan@google.com>2019-01-17 10:19:43 -0800
commit69d05656c64b1b6b2f29fb23e6dd186c8caf03cb (patch)
tree34d3cd8207ddd750466c2644d467879cb37f00ef /quickstep/recents_ui_overrides/src/com/android/launcher3
parentc049c80e411b59d5e20cb6d9f82b98ee04f14a8c (diff)
downloadandroid_packages_apps_Trebuchet-69d05656c64b1b6b2f29fb23e6dd186c8caf03cb.tar.gz
android_packages_apps_Trebuchet-69d05656c64b1b6b2f29fb23e6dd186c8caf03cb.tar.bz2
android_packages_apps_Trebuchet-69d05656c64b1b6b2f29fb23e6dd186c8caf03cb.zip
Split PortraitOverviewStateTouchHelper for Go
Split out the logic in PortraitOverviewStateTouchHelper that is dependent on the recents view implementation. This is done through a separate helper class that we override on Go to stub out most of the behavior. This results in the Go version not supporting swipe transitions from the recents state which is desired since we would otherwise risk confusion over whether the swipe should go to the view or to the transition (note that we will also take out the hotseat in this state). Bug: 114136250 Test: Manual test NexusLauncher and l3goWithQuickstep Test: Build l3goWithQuickstepIconRecents Change-Id: I9b0e9c05171d279d03bbcb7f05344fa425f34b3e
Diffstat (limited to 'quickstep/recents_ui_overrides/src/com/android/launcher3')
-rw-r--r--quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java
new file mode 100644
index 000000000..eead4c8ba
--- /dev/null
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.uioverrides;
+
+import static com.android.launcher3.uioverrides.PortraitStatesTouchController.isTouchOverHotseat;
+
+import android.view.MotionEvent;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.util.PendingAnimation;
+import com.android.quickstep.views.RecentsView;
+import com.android.quickstep.views.TaskView;
+
+/**
+ * Helper class for {@link PortraitStatesTouchController} that determines swipeable regions and
+ * animations on the overview state that depend on the recents implementation.
+ */
+public final class PortraitOverviewStateTouchHelper {
+
+ RecentsView mRecentsView;
+ Launcher mLauncher;
+
+ public PortraitOverviewStateTouchHelper(Launcher launcher) {
+ mLauncher = launcher;
+ mRecentsView = launcher.getOverviewPanel();
+ }
+
+ /**
+ * Whether or not {@link PortraitStatesTouchController} should intercept the touch when on the
+ * overview state.
+ *
+ * @param ev the motion event
+ * @return true if we should intercept the motion event
+ */
+ boolean canInterceptTouch(MotionEvent ev) {
+ if (mRecentsView.getChildCount() > 0) {
+ // Allow swiping up in the gap between the hotseat and overview.
+ return ev.getY() >= mRecentsView.getChildAt(0).getBottom();
+ } else {
+ // If there are no tasks, we only intercept if we're below the hotseat height.
+ return isTouchOverHotseat(mLauncher, ev);
+ }
+ }
+
+ /**
+ * Whether or not swiping down to leave overview state should return to the currently running
+ * task app.
+ *
+ * @return true if going back should take the user to the currently running task
+ */
+ boolean shouldSwipeDownReturnToApp() {
+ TaskView taskView = mRecentsView.getTaskViewAt(mRecentsView.getNextPage());
+ return taskView != null && mRecentsView.shouldSwipeDownLaunchApp();
+ }
+
+ /**
+ * Create the animation for going from overview to the task app via swiping. Should only be
+ * called when {@link #shouldSwipeDownReturnToApp()} returns true.
+ *
+ * @param duration how long the animation should be
+ * @return the animation
+ */
+ PendingAnimation createSwipeDownToTaskAppAnimation(long duration) {
+ TaskView taskView = mRecentsView.getTaskViewAt(mRecentsView.getNextPage());
+ if (taskView == null) {
+ throw new IllegalStateException("There is no task view to animate to.");
+ }
+ return mRecentsView.createTaskLauncherAnimation(taskView, duration);
+ }
+}