diff --git a/quickstep/res/layout/overview_panel.xml b/quickstep/res/layout/overview_panel.xml index 9f4f8a153f..54190ec66f 100644 --- a/quickstep/res/layout/overview_panel.xml +++ b/quickstep/res/layout/overview_panel.xml @@ -24,8 +24,4 @@ android:alpha="0.0" android:visibility="invisible" > - - \ No newline at end of file diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java index b97669bf3e..27b7f52b6f 100644 --- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java @@ -295,7 +295,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag boolean launchingCenterTask = launchedTaskIndex == centerTaskIndex; boolean isRtl = recentsView.isRtl(); if (launchingCenterTask) { - if (launchedTaskIndex - 1 >= recentsView.getFirstTaskIndex()) { + if (launchedTaskIndex - 1 >= 0) { TaskView adjacentPage1 = (TaskView) recentsView.getPageAt(launchedTaskIndex - 1); ObjectAnimator adjacentTask1ScaleAndTranslate = LauncherAnimUtils.ofPropertyValuesHolder(adjacentPage1, @@ -317,7 +317,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag .build()); launcherAnimator.play(adjacentTask2ScaleAndTranslate); } - } else if (centerTaskIndex >= recentsView.getFirstTaskIndex()) { + } else { // We are launching an adjacent task, so parallax the center and other adjacent task. TaskView centerTask = (TaskView) recentsView.getPageAt(centerTaskIndex); float translationX = Math.abs(v.getTranslationX()); @@ -329,7 +329,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag .build()); launcherAnimator.play(centerTaskParallaxToRight); int otherAdjacentTaskIndex = centerTaskIndex + (centerTaskIndex - launchedTaskIndex); - if (otherAdjacentTaskIndex >= recentsView.getFirstTaskIndex() + if (otherAdjacentTaskIndex >= 0 && otherAdjacentTaskIndex < recentsView.getPageCount()) { TaskView otherAdjacentTask = (TaskView) recentsView.getPageAt( otherAdjacentTaskIndex); diff --git a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java index acd4fc169d..c86c5afa8a 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java @@ -23,7 +23,7 @@ import com.android.launcher3.Launcher; public class FastOverviewState extends OverviewState { private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_DISABLE_RESTORE - | FLAG_PAGE_BACKGROUNDS | FLAG_DISABLE_INTERACTION | FLAG_OVERVIEW_UI; + | FLAG_DISABLE_INTERACTION | FLAG_OVERVIEW_UI; private static final boolean DEBUG_DIFFERENT_UI = false; diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java index 4d9dbd0842..4dfbf8d62a 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java @@ -16,7 +16,7 @@ package com.android.launcher3.uioverrides; import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS; -import static com.android.launcher3.anim.Interpolators.ACCEL_2; +import static com.android.launcher3.anim.Interpolators.DEACCEL_2; import static com.android.launcher3.states.RotationHelper.REQUEST_ROTATE; import android.graphics.Rect; @@ -34,7 +34,7 @@ import com.android.quickstep.RecentsView; public class OverviewState extends LauncherState { private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED - | FLAG_DISABLE_RESTORE | FLAG_PAGE_BACKGROUNDS | FLAG_OVERVIEW_UI; + | FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI; public OverviewState(int id) { this(id, STATE_FLAGS); @@ -79,11 +79,10 @@ public class OverviewState extends LauncherState { } public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) { - final int centerPage = launcher.getWorkspace().getNextPage(); - return new PageAlphaProvider(ACCEL_2) { + return new PageAlphaProvider(DEACCEL_2) { @Override public float getPageAlpha(int pageIndex) { - return pageIndex != centerPage ? 0 : 1f; + return 0; } }; } diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeController.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeController.java index 468a5617cb..958091bc48 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeController.java @@ -15,6 +15,13 @@ */ package com.android.launcher3.uioverrides; +import static com.android.launcher3.LauncherState.ALL_APPS; +import static com.android.launcher3.LauncherState.NORMAL; +import static com.android.launcher3.LauncherState.OVERVIEW; +import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5; +import static com.android.launcher3.anim.Interpolators.LINEAR; +import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity; + import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; @@ -32,20 +39,13 @@ import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.touch.SwipeDetector; import com.android.launcher3.userevent.nano.LauncherLogProto; -import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; +import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.TouchController; import com.android.quickstep.RecentsView; import com.android.quickstep.TaskView; -import static com.android.launcher3.LauncherState.ALL_APPS; -import static com.android.launcher3.LauncherState.NORMAL; -import static com.android.launcher3.LauncherState.OVERVIEW; -import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5; -import static com.android.launcher3.anim.Interpolators.LINEAR; -import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity; - /** * Touch controller for swipe interaction in Overview state */ @@ -132,28 +132,22 @@ public class OverviewSwipeController extends AnimatorListenerAdapter mTaskBeingDragged = null; mSwipeDownEnabled = true; - int currentPage = mRecentsView.getCurrentPage(); - if (currentPage == 0) { - // User is on home tile + View view = mRecentsView.getChildAt(mRecentsView.getCurrentPage()); + if (mLauncher.getDragLayer().isEventOverView(view, ev) && + view instanceof TaskView) { + // The tile can be dragged down to open the task. + mTaskBeingDragged = (TaskView) view; directionsToDetectScroll = SwipeDetector.DIRECTION_BOTH; + mStartingTarget = LauncherLogProto.ItemType.TASK; + } else if (isEventOverHotseat(ev)) { + // The hotseat is being dragged + directionsToDetectScroll = SwipeDetector.DIRECTION_POSITIVE; + mSwipeDownEnabled = false; + mStartingTarget = ContainerType.HOTSEAT; } else { - View view = mRecentsView.getChildAt(currentPage); - if (mLauncher.getDragLayer().isEventOverView(view, ev) && - view instanceof TaskView) { - // The tile can be dragged down to open the task. - mTaskBeingDragged = (TaskView) view; - directionsToDetectScroll = SwipeDetector.DIRECTION_BOTH; - mStartingTarget = LauncherLogProto.ItemType.TASK; - } else if (isEventOverHotseat(ev)) { - // The hotseat is being dragged - directionsToDetectScroll = SwipeDetector.DIRECTION_POSITIVE; - mSwipeDownEnabled = false; - mStartingTarget = ContainerType.HOTSEAT; - } else { - mNoIntercept = true; - mStartingTarget = ContainerType.WORKSPACE; - return false; - } + mNoIntercept = true; + mStartingTarget = ContainerType.WORKSPACE; + return false; } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java index 1f0fa11628..2a2e9c576a 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java @@ -16,7 +16,7 @@ package com.android.launcher3.uioverrides; import static com.android.launcher3.LauncherState.NORMAL; -import static com.android.launcher3.LauncherState.OVERVIEW; +import static com.android.launcher3.anim.Interpolators.ACCEL; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -28,7 +28,6 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.LauncherStateManager.AnimationConfig; import com.android.launcher3.LauncherStateManager.StateHandler; import com.android.launcher3.PagedView; -import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.Interpolators; @@ -40,22 +39,18 @@ public class RecentsViewStateController implements StateHandler { private final Launcher mLauncher; private final RecentsView mRecentsView; - private final WorkspaceCard mWorkspaceCard; private final AnimatedFloat mTransitionProgress = new AnimatedFloat(this::onTransitionProgress); // The fraction representing the visibility of the RecentsView. This allows delaying the // overall transition while the RecentsView is being shown or hidden. private final AnimatedFloat mVisibilityMultiplier = new AnimatedFloat(this::onVisibilityProgress); - private boolean mIsRecentsScrollingToFirstTask; + private boolean mIsRecentsSlidingInOrOut; public RecentsViewStateController(Launcher launcher) { mLauncher = launcher; mRecentsView = launcher.getOverviewPanel(); mRecentsView.setStateController(this); - - mWorkspaceCard = (WorkspaceCard) mRecentsView.getChildAt(0); - mWorkspaceCard.setup(launcher); } @Override @@ -63,7 +58,7 @@ public class RecentsViewStateController implements StateHandler { setVisibility(state.overviewUi); setTransitionProgress(state.overviewUi ? 1 : 0); if (state.overviewUi) { - for (int i = mRecentsView.getFirstTaskIndex(); i < mRecentsView.getPageCount(); i++) { + for (int i = 0; i < mRecentsView.getPageCount(); i++) { ((TaskView) mRecentsView.getPageAt(i)).resetVisualProperties(); } mRecentsView.updateCurveProperties(); @@ -73,20 +68,19 @@ public class RecentsViewStateController implements StateHandler { @Override public void setStateWithAnimation(final LauncherState toState, AnimatorSetBuilder builder, AnimationConfig config) { - boolean settingEnabled = Utilities.getPrefs(mLauncher) - .getBoolean("pref_scroll_to_first_task_default_true", true); - mIsRecentsScrollingToFirstTask = mLauncher.isInState(NORMAL) && toState == OVERVIEW - && settingEnabled; + LauncherState fromState = mLauncher.getStateManager().getState(); + mIsRecentsSlidingInOrOut = fromState == NORMAL && toState.overviewUi + || fromState.overviewUi && toState == NORMAL; // Scroll to the workspace card before changing to the NORMAL state. int currPage = mRecentsView.getCurrentPage(); - LauncherState fromState = mLauncher.getStateManager().getState(); if (fromState.overviewUi && toState == NORMAL && currPage != 0 && !config.userControlled) { int maxSnapDuration = PagedView.SLOW_PAGE_SNAP_ANIMATION_DURATION; int durationPerPage = maxSnapDuration / 10; int snapDuration = Math.min(maxSnapDuration, durationPerPage * currPage); mRecentsView.snapToPage(0, snapDuration); - builder.setStartDelay(snapDuration); + // Let the snapping animation play for a bit before we translate off screen. + builder.setStartDelay(snapDuration / 4); } ObjectAnimator progressAnim = @@ -141,11 +135,14 @@ public class RecentsViewStateController implements StateHandler { private void onTransitionProgress() { applyProgress(); - if (mIsRecentsScrollingToFirstTask) { - int scrollForFirstTask = mRecentsView.getScrollForPage(mRecentsView.getFirstTaskIndex()); - int scrollForPage0 = mRecentsView.getScrollForPage(0); - mRecentsView.setScrollX((int) (mTransitionProgress.value * scrollForFirstTask - + (1 - mTransitionProgress.value) * scrollForPage0)); + if (mIsRecentsSlidingInOrOut) { + float interpolatedProgress = ACCEL.getInterpolation(mTransitionProgress.value); + // Slide in from the side as we swipe. + int translation = mRecentsView.getWidth(); + if (mRecentsView.isRtl()) { + translation = -translation; + } + mRecentsView.setTranslationX(translation * (1 - interpolatedProgress)); } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/WorkspaceCard.java b/quickstep/src/com/android/launcher3/uioverrides/WorkspaceCard.java deleted file mode 100644 index b50c4e75e4..0000000000 --- a/quickstep/src/com/android/launcher3/uioverrides/WorkspaceCard.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2017 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.LauncherState.NORMAL; - -import android.content.Context; -import android.graphics.Canvas; -import android.util.AttributeSet; -import android.view.View; -import android.view.View.OnClickListener; - -import com.android.launcher3.Launcher; -import com.android.quickstep.RecentsView.PageCallbacks; - -public class WorkspaceCard extends View implements PageCallbacks, OnClickListener { - - private Launcher mLauncher; - - public WorkspaceCard(Context context) { - this(context, null); - } - - public WorkspaceCard(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public WorkspaceCard(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - setOnClickListener(this); - } - - /** - * Draw nothing. - */ - @Override - public void draw(Canvas canvas) { } - - @Override - public void onClick(View view) { - mLauncher.getStateManager().goToState(NORMAL); - } - - public void setup(Launcher launcher) { - mLauncher = launcher; - } -} diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java index f28d51c8ea..dc1c0d2ac3 100644 --- a/quickstep/src/com/android/quickstep/QuickScrubController.java +++ b/quickstep/src/com/android/quickstep/QuickScrubController.java @@ -22,10 +22,9 @@ import com.android.launcher3.Alarm; import com.android.launcher3.Launcher; import com.android.launcher3.OnAlarmListener; import com.android.launcher3.Utilities; -import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; -import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; +import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType; /** * Responds to quick scrub callbacks to page through and launch recent tasks. @@ -52,6 +51,7 @@ public class QuickScrubController implements OnAlarmListener { private boolean mInQuickScrub; private int mQuickScrubSection; private int mStartPage; + private boolean mStartedFromHome; private boolean mHasAlarmRun; public QuickScrubController(Launcher launcher, RecentsView recentsView) { @@ -65,7 +65,8 @@ public class QuickScrubController implements OnAlarmListener { public void onQuickScrubStart(boolean startingFromHome) { mInQuickScrub = true; - mStartPage = startingFromHome ? 0 : mRecentsView.getFirstTaskIndex(); + mStartPage = 0; + mStartedFromHome = startingFromHome; mQuickScrubSection = 0; mHasAlarmRun = false; mLauncher.getUserEventDispatcher().resetActionDurationMillis(); @@ -78,11 +79,7 @@ public class QuickScrubController implements OnAlarmListener { } int page = mRecentsView.getNextPage(); Runnable launchTaskRunnable = () -> { - if (page < mRecentsView.getFirstTaskIndex()) { - mRecentsView.getPageAt(page).performClick(); - } else { - ((TaskView) mRecentsView.getPageAt(page)).launchTask(true); - } + ((TaskView) mRecentsView.getPageAt(page)).launchTask(true); }; int snapDuration = Math.abs(page - mRecentsView.getPageNearestToCenterOfScreen()) * QUICKSCRUB_END_SNAP_DURATION_PER_PAGE; @@ -94,7 +91,7 @@ public class QuickScrubController implements OnAlarmListener { launchTaskRunnable.run(); } mLauncher.getUserEventDispatcher().logActionOnControl(Touch.DRAGDROP, - ControlType.QUICK_SCRUB_BUTTON, null, mStartPage == 0 ? + ControlType.QUICK_SCRUB_BUTTON, null, mStartedFromHome ? ContainerType.WORKSPACE : ContainerType.APP); } @@ -116,7 +113,7 @@ public class QuickScrubController implements OnAlarmListener { } public void onQuickSwitch() { - for (int i = mRecentsView.getFirstTaskIndex(); i < mRecentsView.getPageCount(); i++) { + for (int i = 0; i < mRecentsView.getPageCount(); i++) { TaskView taskView = (TaskView) mRecentsView.getPageAt(i); if (taskView.getTask().key.id != mRecentsView.getRunningTaskId()) { Runnable launchTaskRunnable = () -> taskView.launchTask(true); @@ -131,13 +128,13 @@ public class QuickScrubController implements OnAlarmListener { } } mLauncher.getUserEventDispatcher().logActionOnControl(Touch.FLING, - ControlType.QUICK_SCRUB_BUTTON, null, mStartPage == 0 ? + ControlType.QUICK_SCRUB_BUTTON, null, mStartedFromHome ? ContainerType.WORKSPACE : ContainerType.APP); } public void snapToPageForCurrentQuickScrubSection() { if (mInQuickScrub) { - goToPageWithHaptic(mRecentsView.getFirstTaskIndex() + mQuickScrubSection); + goToPageWithHaptic(mQuickScrubSection); } } diff --git a/quickstep/src/com/android/quickstep/RecentsView.java b/quickstep/src/com/android/quickstep/RecentsView.java index 406c962116..fdfca84abb 100644 --- a/quickstep/src/com/android/quickstep/RecentsView.java +++ b/quickstep/src/com/android/quickstep/RecentsView.java @@ -265,7 +265,7 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer } public TaskView getTaskView(int taskId) { - for (int i = getFirstTaskIndex(); i < getChildCount(); i++) { + for (int i = 0; i < getChildCount(); i++) { TaskView tv = (TaskView) getChildAt(i); if (tv.getTask().key.id == taskId) { return tv; diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index ede0ad2136..bab8ef17a3 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -588,9 +588,8 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler { mLauncherTransitionController.setPlayFraction(shift); // Make sure the window follows the first task if it moves, e.g. during quick scrub. - int firstTaskIndex = mRecentsView.getFirstTaskIndex(); - View firstTask = mRecentsView.getPageAt(firstTaskIndex); - int scrollForFirstTask = mRecentsView.getScrollForPage(firstTaskIndex); + View firstTask = mRecentsView.getPageAt(0); + int scrollForFirstTask = mRecentsView.getScrollForPage(0); int offsetFromFirstTask = (scrollForFirstTask - mRecentsView.getScrollX()); if (offsetFromFirstTask != 0) { synchronized (mTargetRect) {