diff --git a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java index 6b50088221..04753d2527 100644 --- a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java +++ b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java @@ -46,13 +46,13 @@ final class AppToOverviewAnimationProvider imple RemoteAnimationProvider { private static final String TAG = "AppToOverviewAnimationProvider"; - private final BaseActivityInterface mHelper; + private final BaseActivityInterface mActivityInterface; private final int mTargetTaskId; private IconRecentsView mRecentsView; private AppToOverviewAnimationListener mAnimationReadyListener; - AppToOverviewAnimationProvider(BaseActivityInterface helper, int targetTaskId) { - mHelper = helper; + AppToOverviewAnimationProvider(BaseActivityInterface activityInterface, int targetTaskId) { + mActivityInterface = activityInterface; mTargetTaskId = targetTaskId; } @@ -68,15 +68,15 @@ final class AppToOverviewAnimationProvider imple /** * Callback for when the activity is ready/initialized. * - * @param activity the activity that is ready * @param wasVisible true if it was visible before */ - boolean onActivityReady(T activity, Boolean wasVisible) { + boolean onActivityReady(Boolean wasVisible) { + T activity = mActivityInterface.getCreatedActivity(); if (mAnimationReadyListener != null) { mAnimationReadyListener.onActivityReady(activity); } BaseActivityInterface.AnimationFactory factory = - mHelper.prepareRecentsUI(activity, wasVisible, + mActivityInterface.prepareRecentsUI(wasVisible, false /* animate activity */, (controller) -> { controller.dispatchOnStart(); ValueAnimator anim = controller.getAnimationPlayer() diff --git a/go/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/go/quickstep/src/com/android/quickstep/FallbackActivityInterface.java index 2af8441853..ecb9472c72 100644 --- a/go/quickstep/src/com/android/quickstep/FallbackActivityInterface.java +++ b/go/quickstep/src/com/android/quickstep/FallbackActivityInterface.java @@ -29,8 +29,8 @@ import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.quickstep.util.ActivityInitListener; import com.android.quickstep.views.IconRecentsView; -import java.util.function.BiPredicate; import java.util.function.Consumer; +import java.util.function.Predicate; /** * {@link BaseActivityInterface} for recents when the default launcher is different than the @@ -43,12 +43,13 @@ public final class FallbackActivityInterface extends public FallbackActivityInterface() { } @Override - public AnimationFactory prepareRecentsUI(RecentsActivity activity, boolean activityVisible, + public AnimationFactory prepareRecentsUI(boolean activityVisible, boolean animateActivity, Consumer callback) { if (activityVisible) { return (transitionLength) -> { }; } + RecentsActivity activity = getCreatedActivity(); IconRecentsView rv = activity.getOverviewPanel(); rv.setUsingRemoteAnimation(true); rv.setAlpha(0); @@ -84,8 +85,9 @@ public final class FallbackActivityInterface extends @Override public ActivityInitListener createActivityInitListener( - BiPredicate onInitListener) { - return new ActivityInitListener(onInitListener, RecentsActivity.ACTIVITY_TRACKER); + Predicate onInitListener) { + return new ActivityInitListener<>((activity, alreadyOnHome) -> + onInitListener.test(alreadyOnHome), RecentsActivity.ACTIVITY_TRACKER); } @Nullable @@ -115,5 +117,5 @@ public final class FallbackActivityInterface extends } @Override - public void onLaunchTaskSuccess(RecentsActivity activity) { } + public void onLaunchTaskSuccess() { } } diff --git a/go/quickstep/src/com/android/quickstep/GoActivityInterface.java b/go/quickstep/src/com/android/quickstep/GoActivityInterface.java index 5ce0f4cdf5..b62d17ce2f 100644 --- a/go/quickstep/src/com/android/quickstep/GoActivityInterface.java +++ b/go/quickstep/src/com/android/quickstep/GoActivityInterface.java @@ -17,7 +17,7 @@ public abstract class GoActivityInterface implem BaseActivityInterface { @Override - public void onTransitionCancelled(T activity, boolean activityVisible) { + public void onTransitionCancelled(boolean activityVisible) { // Go transitions to overview are all atomic. } @@ -29,7 +29,7 @@ public abstract class GoActivityInterface implem } @Override - public void onSwipeUpToRecentsComplete(T activity) { + public void onSwipeUpToRecentsComplete() { // Go does not support swipe up gesture. } @@ -39,7 +39,7 @@ public abstract class GoActivityInterface implem } @Override - public HomeAnimationFactory prepareHomeUI(T activity) { + public HomeAnimationFactory prepareHomeUI() { // Go does not support gestures from app to home. return null; } @@ -63,7 +63,7 @@ public abstract class GoActivityInterface implem } @Override - public void onLaunchTaskFailed(T activity) { + public void onLaunchTaskFailed() { // Go does not support gestures from one task to another. } } diff --git a/go/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/go/quickstep/src/com/android/quickstep/LauncherActivityInterface.java index 5bff8e8060..3e93480a95 100644 --- a/go/quickstep/src/com/android/quickstep/LauncherActivityInterface.java +++ b/go/quickstep/src/com/android/quickstep/LauncherActivityInterface.java @@ -26,8 +26,8 @@ import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.quickstep.views.IconRecentsView; -import java.util.function.BiPredicate; import java.util.function.Consumer; +import java.util.function.Predicate; /** * {@link BaseActivityInterface} for the in-launcher recents. @@ -36,15 +36,15 @@ import java.util.function.Consumer; public final class LauncherActivityInterface extends GoActivityInterface { @Override - public AnimationFactory prepareRecentsUI(Launcher activity, - boolean activityVisible, boolean animateActivity, + public AnimationFactory prepareRecentsUI(boolean activityVisible, boolean animateActivity, Consumer callback) { - LauncherState fromState = activity.getStateManager().getState(); - activity.getOverviewPanel().setUsingRemoteAnimation(true); + Launcher launcher = getCreatedActivity(); + LauncherState fromState = launcher.getStateManager().getState(); + launcher.getOverviewPanel().setUsingRemoteAnimation(true); //TODO: Implement this based off where the recents view needs to be for app => recents anim. return new AnimationFactory() { public void createActivityInterface(long transitionLength) { - callback.accept(activity.getStateManager().createAnimationToNewWorkspace( + callback.accept(launcher.getStateManager().createAnimationToNewWorkspace( fromState, OVERVIEW, transitionLength)); } @@ -54,9 +54,9 @@ public final class LauncherActivityInterface extends GoActivityInterface onInitListener) { - return new LauncherInitListener(onInitListener); + public LauncherInitListener createActivityInitListener(Predicate onInitListener) { + return new LauncherInitListener((activity, alreadyOnHome) -> + onInitListener.test(alreadyOnHome)); } @Override @@ -105,7 +105,8 @@ public final class LauncherActivityInterface extends GoActivityInterface imple activity.getOverviewPanel().showCurrentTask(mTargetTaskId); AbstractFloatingView.closeAllOpenViews(activity, wasVisible); BaseActivityInterface.AnimationFactory factory = - mHelper.prepareRecentsUI(activity, wasVisible, + mHelper.prepareRecentsUI(wasVisible, false /* animate activity */, (controller) -> { controller.dispatchOnStart(); ValueAnimator anim = controller.getAnimationPlayer() @@ -102,7 +102,7 @@ final class AppToOverviewAnimationProvider imple anim.addListener(new AnimationSuccessListener() { @Override public void onAnimationSuccess(Animator animator) { - mHelper.onSwipeUpToRecentsComplete(mActivity); + mHelper.onSwipeUpToRecentsComplete(); if (mRecentsView != null) { mRecentsView.animateUpRunningTaskIconScale(); } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java index a16c365af1..939656eb3e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -239,10 +239,10 @@ public abstract class BaseSwipeUpHandler { resultCallback.accept(success); if (!success) { - mActivityInterface.onLaunchTaskFailed(mActivity); + mActivityInterface.onLaunchTaskFailed(); nextTask.notifyTaskLaunchFailed(TAG); } else { - mActivityInterface.onLaunchTaskSuccess(mActivity); + mActivityInterface.onLaunchTaskSuccess(); } }, MAIN_EXECUTOR.getHandler()); } @@ -359,7 +359,7 @@ public abstract class BaseSwipeUpHandler callback) { + RecentsActivity activity = getCreatedActivity(); if (activityVisible) { return (transitionLength) -> { }; } @@ -176,8 +180,9 @@ public final class FallbackActivityInterface implements @Override public ActivityInitListener createActivityInitListener( - BiPredicate onInitListener) { - return new ActivityInitListener(onInitListener, RecentsActivity.ACTIVITY_TRACKER); + Predicate onInitListener) { + return new ActivityInitListener<>((activity, alreadyOnHome) -> + onInitListener.test(alreadyOnHome), RecentsActivity.ACTIVITY_TRACKER); } @Nullable @@ -228,13 +233,15 @@ public final class FallbackActivityInterface implements } @Override - public void onLaunchTaskFailed(RecentsActivity activity) { + public void onLaunchTaskFailed() { // TODO: probably go back to overview instead. + RecentsActivity activity = getCreatedActivity(); activity.getOverviewPanel().startHome(); } @Override - public void onLaunchTaskSuccess(RecentsActivity activity) { + public void onLaunchTaskSuccess() { + RecentsActivity activity = getCreatedActivity(); activity.onTaskLaunched(); } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java index c5289355b8..87db83db53 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java @@ -69,8 +69,8 @@ import com.android.systemui.plugins.shared.LauncherOverlayManager; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; -import java.util.function.BiPredicate; import java.util.function.Consumer; +import java.util.function.Predicate; /** * {@link BaseActivityInterface} for the in-launcher recents. @@ -92,23 +92,26 @@ public final class LauncherActivityInterface implements BaseActivityInterface callback) { - final LauncherState startState = activity.getStateManager().getState(); + Launcher launcher = getCreatedActivity(); + final LauncherState startState = launcher.getStateManager().getState(); LauncherState resetState = startState; if (startState.disableRestore) { - resetState = activity.getStateManager().getRestState(); + resetState = launcher.getStateManager().getRestState(); } - activity.getStateManager().setRestState(resetState); + launcher.getStateManager().setRestState(resetState); final LauncherState fromState = animateActivity ? BACKGROUND_APP : OVERVIEW; - activity.getStateManager().goToState(fromState, false); + launcher.getStateManager().goToState(fromState, false); // Since all apps is not visible, we can safely reset the scroll position. // This ensures then the next swipe up to all-apps starts from scroll 0. - activity.getAppsView().reset(false /* animate */); + launcher.getAppsView().reset(false /* animate */); return new AnimationFactory() { private ShelfAnimState mShelfState; @@ -215,11 +220,11 @@ public final class LauncherActivityInterface implements BaseActivityInterface