diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java index a63e3062b0..f9dcee05b3 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java @@ -15,6 +15,7 @@ */ package com.android.quickstep; +import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS; import static com.android.launcher3.LauncherState.FAST_OVERVIEW; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS; @@ -24,10 +25,15 @@ import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_ import android.animation.AnimatorSet; import android.animation.ObjectAnimator; +import android.annotation.TargetApi; +import android.app.ActivityManager.RunningTaskInfo; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.graphics.Rect; +import android.os.Build; import android.os.Handler; +import android.os.Looper; import android.support.annotation.Nullable; import android.support.annotation.UiThread; import android.view.View; @@ -52,21 +58,23 @@ import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.RecentsViewContainer; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import java.util.Objects; import java.util.function.BiPredicate; import java.util.function.Consumer; /** * Utility class which abstracts out the logical differences between Launcher and RecentsActivity. */ +@TargetApi(Build.VERSION_CODES.P) public interface ActivityControlHelper { LayoutListener createLayoutListener(T activity); /** * Updates the UI to indicate quick interaction. - * @return true if there any any UI change as a result of this */ - boolean onQuickInteractionStart(T activity, boolean activityVisible); + void onQuickInteractionStart(T activity, @Nullable RunningTaskInfo taskInfo, + boolean activityVisible); float getTranslationYForQuickScrub(T activity); @@ -120,10 +128,14 @@ public interface ActivityControlHelper { } @Override - public boolean onQuickInteractionStart(Launcher activity, boolean activityVisible) { + public void onQuickInteractionStart(Launcher activity, RunningTaskInfo taskInfo, + boolean activityVisible) { LauncherState fromState = activity.getStateManager().getState(); activity.getStateManager().goToState(FAST_OVERVIEW, activityVisible); - return !fromState.overviewUi; + + QuickScrubController controller = activity.getOverviewPanel() + .getQuickScrubController(); + controller.onQuickScrubStart(activityVisible && !fromState.overviewUi, this); } @Override @@ -311,10 +323,27 @@ public interface ActivityControlHelper { class FallbackActivityControllerHelper implements ActivityControlHelper { + private final ComponentName mHomeComponent; + private final Handler mUiHandler = new Handler(Looper.getMainLooper()); + + public FallbackActivityControllerHelper(ComponentName homeComponent) { + mHomeComponent = homeComponent; + } + @Override - public boolean onQuickInteractionStart(RecentsActivity activity, boolean activityVisible) { - // Activity does not need any UI change for quickscrub. - return false; + public void onQuickInteractionStart(RecentsActivity activity, RunningTaskInfo taskInfo, + boolean activityVisible) { + QuickScrubController controller = activity.getOverviewPanel() + .getQuickScrubController(); + + // TODO: match user is as well + boolean startingFromHome = !activityVisible && + (taskInfo == null || Objects.equals(taskInfo.topActivity, mHomeComponent)); + controller.onQuickScrubStart(startingFromHome, this); + if (activityVisible) { + mUiHandler.postDelayed(controller::onFinishedTransitionToQuickScrub, + OVERVIEW_TRANSITION_MS); + } } @Override @@ -465,6 +494,7 @@ public interface ActivityControlHelper { public AlphaProperty getAlphaProperty(RecentsActivity activity) { return activity.getDragLayer().getAlphaProperty(0); } + } interface LayoutListener { diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 3ec2d23bbe..bde36255ef 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -138,7 +138,7 @@ public class OverviewCommandHelper { } else { // The default home app is a different launcher. Use the fallback Overview instead. overviewComponent = new ComponentName(mContext, RecentsActivity.class); - mActivityControlHelper = new FallbackActivityControllerHelper(); + mActivityControlHelper = new FallbackActivityControllerHelper(defaultHome); overviewIntentCategory = Intent.CATEGORY_DEFAULT; // User's default home app can change as a result of package updates of this app (such diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 3babd1ffd6..7496b47827 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -350,8 +350,7 @@ public class TouchInteractionService extends Service { mStartPending = true; Runnable action = () -> { - mQuickScrubController.onQuickScrubStart(mActivityHelper.onQuickInteractionStart( - mActivity, true), mActivityHelper); + mActivityHelper.onQuickInteractionStart(mActivity, null, true); mQuickScrubController.onQuickScrubProgress(mLastProgress); mStartPending = false; diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index a88b8cd969..645e749c51 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -171,6 +171,7 @@ public class WindowTransformSwipeHandler { private final ActivityInitListener mActivityInitListener; private final int mRunningTaskId; + private final RunningTaskInfo mRunningTaskInfo; private ThumbnailData mTaskSnapshot; private MultiStateCallback mStateCallback; @@ -207,6 +208,7 @@ public class WindowTransformSwipeHandler { WindowTransformSwipeHandler(RunningTaskInfo runningTaskInfo, Context context, long touchTimeMs, ActivityControlHelper controller) { mContext = context; + mRunningTaskInfo = runningTaskInfo; mRunningTaskId = runningTaskInfo.id; mTouchTimeMs = touchTimeMs; mActivityControlHelper = controller; @@ -772,8 +774,7 @@ public class WindowTransformSwipeHandler { mLauncherTransitionController = null; } - mActivityControlHelper.onQuickInteractionStart(mActivity, false); - mQuickScrubController.onQuickScrubStart(false, mActivityControlHelper); + mActivityControlHelper.onQuickInteractionStart(mActivity, mRunningTaskInfo, false); // Inform the last progress in case we skipped before. mQuickScrubController.onQuickScrubProgress(mCurrentQuickScrubProgress); diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index fb4aa02652..9e2de33954 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -35,6 +35,7 @@ public class FallbackRecentsView extends RecentsView { public FallbackRecentsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setOverviewStateEnabled(true); + getQuickScrubController().onFinishedTransitionToQuickScrub(); } @Override