12/ Clean up some ActivityInterface calls
- Require users of the activity interface to go through the interface to get the raw activity - Remove calls that pass in the activity since the interface already can get the reference to it internally (and the interface always has the reference before the caller) Bug: 141886704 Change-Id: I13e52caba593db918e8a7764c751044142fe7ece Signed-off-by: Winson Chung <winsonc@google.com>
This commit is contained in:
parent
981ef3a88a
commit
dd9d1ea1bf
|
@ -46,13 +46,13 @@ final class AppToOverviewAnimationProvider<T extends BaseDraggingActivity> imple
|
|||
RemoteAnimationProvider {
|
||||
private static final String TAG = "AppToOverviewAnimationProvider";
|
||||
|
||||
private final BaseActivityInterface<T> mHelper;
|
||||
private final BaseActivityInterface<T> mActivityInterface;
|
||||
private final int mTargetTaskId;
|
||||
private IconRecentsView mRecentsView;
|
||||
private AppToOverviewAnimationListener mAnimationReadyListener;
|
||||
|
||||
AppToOverviewAnimationProvider(BaseActivityInterface<T> helper, int targetTaskId) {
|
||||
mHelper = helper;
|
||||
AppToOverviewAnimationProvider(BaseActivityInterface<T> activityInterface, int targetTaskId) {
|
||||
mActivityInterface = activityInterface;
|
||||
mTargetTaskId = targetTaskId;
|
||||
}
|
||||
|
||||
|
@ -68,15 +68,15 @@ final class AppToOverviewAnimationProvider<T extends BaseDraggingActivity> 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()
|
||||
|
|
|
@ -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<AnimatorPlaybackController> 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<RecentsActivity, Boolean> onInitListener) {
|
||||
return new ActivityInitListener(onInitListener, RecentsActivity.ACTIVITY_TRACKER);
|
||||
Predicate<Boolean> 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() { }
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public abstract class GoActivityInterface<T extends BaseDraggingActivity> implem
|
|||
BaseActivityInterface<T> {
|
||||
|
||||
@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<T extends BaseDraggingActivity> 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<T extends BaseDraggingActivity> 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<T extends BaseDraggingActivity> implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLaunchTaskFailed(T activity) {
|
||||
public void onLaunchTaskFailed() {
|
||||
// Go does not support gestures from one task to another.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Launcher> {
|
||||
|
||||
@Override
|
||||
public AnimationFactory prepareRecentsUI(Launcher activity,
|
||||
boolean activityVisible, boolean animateActivity,
|
||||
public AnimationFactory prepareRecentsUI(boolean activityVisible, boolean animateActivity,
|
||||
Consumer<AnimatorPlaybackController> callback) {
|
||||
LauncherState fromState = activity.getStateManager().getState();
|
||||
activity.<IconRecentsView>getOverviewPanel().setUsingRemoteAnimation(true);
|
||||
Launcher launcher = getCreatedActivity();
|
||||
LauncherState fromState = launcher.getStateManager().getState();
|
||||
launcher.<IconRecentsView>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<Launche
|
|||
}
|
||||
|
||||
@Override
|
||||
public LauncherInitListener createActivityInitListener(
|
||||
BiPredicate<Launcher, Boolean> onInitListener) {
|
||||
return new LauncherInitListener(onInitListener);
|
||||
public LauncherInitListener createActivityInitListener(Predicate<Boolean> onInitListener) {
|
||||
return new LauncherInitListener((activity, alreadyOnHome) ->
|
||||
onInitListener.test(alreadyOnHome));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,7 +105,8 @@ public final class LauncherActivityInterface extends GoActivityInterface<Launche
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLaunchTaskSuccess(Launcher launcher) {
|
||||
public void onLaunchTaskSuccess() {
|
||||
Launcher launcher = getCreatedActivity();
|
||||
launcher.getStateManager().moveToRestState();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ final class AppToOverviewAnimationProvider<T extends BaseDraggingActivity> imple
|
|||
activity.<RecentsView>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<T extends BaseDraggingActivity> imple
|
|||
anim.addListener(new AnimationSuccessListener() {
|
||||
@Override
|
||||
public void onAnimationSuccess(Animator animator) {
|
||||
mHelper.onSwipeUpToRecentsComplete(mActivity);
|
||||
mHelper.onSwipeUpToRecentsComplete();
|
||||
if (mRecentsView != null) {
|
||||
mRecentsView.animateUpRunningTaskIconScale();
|
||||
}
|
||||
|
|
|
@ -239,10 +239,10 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
|
|||
success -> {
|
||||
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<T extends BaseDraggingActivity, Q exten
|
|||
*/
|
||||
protected abstract boolean moveWindowWithRecentsScroll();
|
||||
|
||||
protected abstract boolean onActivityInit(final T activity, Boolean alreadyOnHome);
|
||||
protected abstract boolean onActivityInit(Boolean alreadyOnHome);
|
||||
|
||||
/**
|
||||
* Called to create a input proxy for the running task
|
||||
|
|
|
@ -30,6 +30,7 @@ import android.graphics.RectF;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.anim.AnimationSuccessListener;
|
||||
import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
|
@ -40,8 +41,8 @@ import com.android.quickstep.util.LayoutUtils;
|
|||
import com.android.quickstep.views.RecentsView;
|
||||
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 recents when the default launcher is different than the
|
||||
|
@ -54,7 +55,7 @@ public final class FallbackActivityInterface implements
|
|||
public FallbackActivityInterface() { }
|
||||
|
||||
@Override
|
||||
public void onTransitionCancelled(RecentsActivity activity, boolean activityVisible) {
|
||||
public void onTransitionCancelled(boolean activityVisible) {
|
||||
// TODO:
|
||||
}
|
||||
|
||||
|
@ -72,7 +73,8 @@ public final class FallbackActivityInterface implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSwipeUpToRecentsComplete(RecentsActivity activity) {
|
||||
public void onSwipeUpToRecentsComplete() {
|
||||
RecentsActivity activity = getCreatedActivity();
|
||||
RecentsView recentsView = activity.getOverviewPanel();
|
||||
recentsView.getClearAllButton().setVisibilityAlpha(1);
|
||||
recentsView.setDisallowScrollToClearAll(false);
|
||||
|
@ -87,7 +89,8 @@ public final class FallbackActivityInterface implements
|
|||
|
||||
@NonNull
|
||||
@Override
|
||||
public HomeAnimationFactory prepareHomeUI(RecentsActivity activity) {
|
||||
public HomeAnimationFactory prepareHomeUI() {
|
||||
RecentsActivity activity = getCreatedActivity();
|
||||
RecentsView recentsView = activity.getOverviewPanel();
|
||||
|
||||
return new HomeAnimationFactory() {
|
||||
|
@ -118,8 +121,9 @@ public final class FallbackActivityInterface implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public AnimationFactory prepareRecentsUI(RecentsActivity activity, boolean activityVisible,
|
||||
public AnimationFactory prepareRecentsUI(boolean activityVisible,
|
||||
boolean animateActivity, Consumer<AnimatorPlaybackController> callback) {
|
||||
RecentsActivity activity = getCreatedActivity();
|
||||
if (activityVisible) {
|
||||
return (transitionLength) -> { };
|
||||
}
|
||||
|
@ -176,8 +180,9 @@ public final class FallbackActivityInterface implements
|
|||
|
||||
@Override
|
||||
public ActivityInitListener createActivityInitListener(
|
||||
BiPredicate<RecentsActivity, Boolean> onInitListener) {
|
||||
return new ActivityInitListener(onInitListener, RecentsActivity.ACTIVITY_TRACKER);
|
||||
Predicate<Boolean> 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.<RecentsView>getOverviewPanel().startHome();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLaunchTaskSuccess(RecentsActivity activity) {
|
||||
public void onLaunchTaskSuccess() {
|
||||
RecentsActivity activity = getCreatedActivity();
|
||||
activity.onTaskLaunched();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<La
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionCancelled(Launcher activity, boolean activityVisible) {
|
||||
LauncherState startState = activity.getStateManager().getRestState();
|
||||
activity.getStateManager().goToState(startState, activityVisible);
|
||||
public void onTransitionCancelled(boolean activityVisible) {
|
||||
Launcher launcher = getCreatedActivity();
|
||||
LauncherState startState = launcher.getStateManager().getRestState();
|
||||
launcher.getStateManager().goToState(startState, activityVisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwipeUpToRecentsComplete(Launcher activity) {
|
||||
public void onSwipeUpToRecentsComplete() {
|
||||
// Re apply state in case we did something funky during the transition.
|
||||
activity.getStateManager().reapplyState();
|
||||
DiscoveryBounce.showForOverviewIfNeeded(activity);
|
||||
Launcher launcher = getCreatedActivity();
|
||||
launcher.getStateManager().reapplyState();
|
||||
DiscoveryBounce.showForOverviewIfNeeded(launcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwipeUpToHomeComplete(Launcher activity) {
|
||||
public void onSwipeUpToHomeComplete() {
|
||||
// Ensure recents is at the correct position for NORMAL state. For example, when we detach
|
||||
// recents, we assume the first task is invisible, making translation off by one task.
|
||||
activity.getStateManager().reapplyState();
|
||||
Launcher launcher = getCreatedActivity();
|
||||
launcher.getStateManager().reapplyState();
|
||||
setLauncherHideBackArrow(false);
|
||||
}
|
||||
|
||||
|
@ -129,13 +132,14 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
|
||||
@NonNull
|
||||
@Override
|
||||
public HomeAnimationFactory prepareHomeUI(Launcher activity) {
|
||||
final DeviceProfile dp = activity.getDeviceProfile();
|
||||
final RecentsView recentsView = activity.getOverviewPanel();
|
||||
public HomeAnimationFactory prepareHomeUI() {
|
||||
Launcher launcher = getCreatedActivity();
|
||||
final DeviceProfile dp = launcher.getDeviceProfile();
|
||||
final RecentsView recentsView = launcher.getOverviewPanel();
|
||||
final TaskView runningTaskView = recentsView.getRunningTaskView();
|
||||
final View workspaceView;
|
||||
if (runningTaskView != null && runningTaskView.getTask().key.getComponent() != null) {
|
||||
workspaceView = activity.getWorkspace().getFirstMatchForAppClose(
|
||||
workspaceView = launcher.getWorkspace().getFirstMatchForAppClose(
|
||||
runningTaskView.getTask().key.getComponent().getPackageName(),
|
||||
UserHandle.of(runningTaskView.getTask().key.userId));
|
||||
} else {
|
||||
|
@ -144,7 +148,7 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
final RectF iconLocation = new RectF();
|
||||
boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow();
|
||||
FloatingIconView floatingIconView = canUseWorkspaceView
|
||||
? FloatingIconView.getFloatingIconView(activity, workspaceView,
|
||||
? FloatingIconView.getFloatingIconView(launcher, workspaceView,
|
||||
true /* hideOriginal */, iconLocation, false /* isOpening */)
|
||||
: null;
|
||||
setLauncherHideBackArrow(true);
|
||||
|
@ -170,14 +174,14 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
public AnimatorPlaybackController createActivityAnimationToHome() {
|
||||
// Return an empty APC here since we have an non-user controlled animation to home.
|
||||
long accuracy = 2 * Math.max(dp.widthPx, dp.heightPx);
|
||||
return activity.getStateManager().createAnimationToNewWorkspace(NORMAL, accuracy,
|
||||
return launcher.getStateManager().createAnimationToNewWorkspace(NORMAL, accuracy,
|
||||
0 /* animComponents */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playAtomicAnimation(float velocity) {
|
||||
// Setup workspace with 0 duration to prepare for our staggered animation.
|
||||
LauncherStateManager stateManager = activity.getStateManager();
|
||||
LauncherStateManager stateManager = launcher.getStateManager();
|
||||
AnimatorSetBuilder builder = new AnimatorSetBuilder();
|
||||
// setRecentsAttachedToAppWindow() will animate recents out.
|
||||
builder.addFlag(AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW);
|
||||
|
@ -187,27 +191,28 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
// Stop scrolling so that it doesn't interfere with the translation offscreen.
|
||||
recentsView.getScroller().forceFinished(true);
|
||||
|
||||
new StaggeredWorkspaceAnim(activity, workspaceView, velocity).start();
|
||||
new StaggeredWorkspaceAnim(launcher, workspaceView, velocity).start();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimationFactory prepareRecentsUI(Launcher activity, boolean activityVisible,
|
||||
public AnimationFactory prepareRecentsUI(boolean activityVisible,
|
||||
boolean animateActivity, Consumer<AnimatorPlaybackController> 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<La
|
|||
|
||||
@Override
|
||||
public void createActivityInterface(long transitionLength) {
|
||||
createActivityInterfaceInternal(activity, fromState, transitionLength, callback);
|
||||
createActivityInterfaceInternal(launcher, fromState, transitionLength, callback);
|
||||
// Creating the activity controller animation sometimes reapplies the launcher state
|
||||
// (because we set the animation as the current state animation), so we reapply the
|
||||
// attached state here as well to ensure recents is shown/hidden appropriately.
|
||||
if (SysUINavigationMode.getMode(activity) == Mode.NO_BUTTON) {
|
||||
if (SysUINavigationMode.getMode(launcher) == Mode.NO_BUTTON) {
|
||||
setRecentsAttachedToAppWindow(mIsAttachedToWindow, false);
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +238,7 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
|
||||
@Override
|
||||
public void onTransitionCancelled() {
|
||||
activity.getStateManager().goToState(startState, false /* animate */);
|
||||
launcher.getStateManager().goToState(startState, false /* animate */);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -243,15 +248,15 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
return;
|
||||
}
|
||||
mShelfState = shelfState;
|
||||
activity.getStateManager().cancelStateElementAnimation(INDEX_SHELF_ANIM);
|
||||
launcher.getStateManager().cancelStateElementAnimation(INDEX_SHELF_ANIM);
|
||||
if (mShelfState == ShelfAnimState.CANCEL) {
|
||||
return;
|
||||
}
|
||||
float shelfHiddenProgress = BACKGROUND_APP.getVerticalProgress(activity);
|
||||
float shelfOverviewProgress = OVERVIEW.getVerticalProgress(activity);
|
||||
float shelfHiddenProgress = BACKGROUND_APP.getVerticalProgress(launcher);
|
||||
float shelfOverviewProgress = OVERVIEW.getVerticalProgress(launcher);
|
||||
// Peek based on default overview progress so we can see hotseat if we're showing
|
||||
// that instead of predictions in overview.
|
||||
float defaultOverviewProgress = OverviewState.getDefaultVerticalProgress(activity);
|
||||
float defaultOverviewProgress = OverviewState.getDefaultVerticalProgress(launcher);
|
||||
float shelfPeekingProgress = shelfHiddenProgress
|
||||
- (shelfHiddenProgress - defaultOverviewProgress) * 0.25f;
|
||||
float toProgress = mShelfState == ShelfAnimState.HIDE
|
||||
|
@ -259,7 +264,7 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
: mShelfState == ShelfAnimState.PEEK
|
||||
? shelfPeekingProgress
|
||||
: shelfOverviewProgress;
|
||||
Animator shelfAnim = activity.getStateManager()
|
||||
Animator shelfAnim = launcher.getStateManager()
|
||||
.createStateElementAnimation(INDEX_SHELF_ANIM, toProgress);
|
||||
shelfAnim.setInterpolator(interpolator);
|
||||
shelfAnim.setDuration(duration).start();
|
||||
|
@ -271,8 +276,8 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
return;
|
||||
}
|
||||
mIsAttachedToWindow = attached;
|
||||
LauncherRecentsView recentsView = activity.getOverviewPanel();
|
||||
Animator fadeAnim = activity.getStateManager()
|
||||
LauncherRecentsView recentsView = launcher.getOverviewPanel();
|
||||
Animator fadeAnim = launcher.getStateManager()
|
||||
.createStateElementAnimation(
|
||||
INDEX_RECENTS_FADE_ANIM, attached ? 1 : 0);
|
||||
|
||||
|
@ -286,7 +291,7 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
|
||||
float fromTranslationX = attached ? offscreenX - scrollOffsetX : 0;
|
||||
float toTranslationX = attached ? 0 : offscreenX - scrollOffsetX;
|
||||
activity.getStateManager()
|
||||
launcher.getStateManager()
|
||||
.cancelStateElementAnimation(INDEX_RECENTS_TRANSLATE_X_ANIM);
|
||||
|
||||
if (!recentsView.isShown() && animate) {
|
||||
|
@ -298,7 +303,7 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
if (!animate) {
|
||||
recentsView.setTranslationX(toTranslationX);
|
||||
} else {
|
||||
activity.getStateManager().createStateElementAnimation(
|
||||
launcher.getStateManager().createStateElementAnimation(
|
||||
INDEX_RECENTS_TRANSLATE_X_ANIM,
|
||||
fromTranslationX, toTranslationX).start();
|
||||
}
|
||||
|
@ -396,9 +401,9 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActivityInitListener createActivityInitListener(
|
||||
BiPredicate<Launcher, Boolean> onInitListener) {
|
||||
return new LauncherInitListenerEx(onInitListener);
|
||||
public ActivityInitListener createActivityInitListener(Predicate<Boolean> onInitListener) {
|
||||
return new LauncherInitListenerEx((activity, alreadyOnHome) ->
|
||||
onInitListener.test(alreadyOnHome));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -469,12 +474,14 @@ public final class LauncherActivityInterface implements BaseActivityInterface<La
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onLaunchTaskFailed(Launcher launcher) {
|
||||
public void onLaunchTaskFailed() {
|
||||
Launcher launcher = getCreatedActivity();
|
||||
launcher.getStateManager().goToState(OVERVIEW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLaunchTaskSuccess(Launcher launcher) {
|
||||
public void onLaunchTaskSuccess() {
|
||||
Launcher launcher = getCreatedActivity();
|
||||
launcher.getStateManager().moveToRestState();
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,8 @@ public class OverviewCommandHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean onActivityReady(T activity, Boolean wasVisible) {
|
||||
private boolean onActivityReady(Boolean wasVisible) {
|
||||
final T activity = mActivityInterface.getCreatedActivity();
|
||||
if (!mUserEventLogged) {
|
||||
activity.getUserEventDispatcher().logActionCommand(
|
||||
LauncherLogProto.Action.Command.RECENTS_BUTTON,
|
||||
|
|
|
@ -646,8 +646,8 @@ public class TouchInteractionService extends Service implements
|
|||
mOverviewComponentObserver.getActivityInterface();
|
||||
if (activityInterface.getCreatedActivity() == null) {
|
||||
// Make sure that UI states will be initialized.
|
||||
activityInterface.createActivityInitListener((activity, wasVisible) -> {
|
||||
AppLaunchTracker.INSTANCE.get(activity);
|
||||
activityInterface.createActivityInitListener((wasVisible) -> {
|
||||
AppLaunchTracker.INSTANCE.get(TouchInteractionService.this);
|
||||
return false;
|
||||
}).register();
|
||||
} else if (fromInit) {
|
||||
|
|
|
@ -268,7 +268,8 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean onActivityInit(final T activity, Boolean alreadyOnHome) {
|
||||
protected boolean onActivityInit(Boolean alreadyOnHome) {
|
||||
final T activity = mActivityInterface.getCreatedActivity();
|
||||
if (mActivity == activity) {
|
||||
return true;
|
||||
}
|
||||
|
@ -320,7 +321,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
|||
// as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL.
|
||||
if (mGestureState.getEndTarget() != HOME) {
|
||||
Runnable initAnimFactory = () -> {
|
||||
mAnimationFactory = mActivityInterface.prepareRecentsUI(mActivity,
|
||||
mAnimationFactory = mActivityInterface.prepareRecentsUI(
|
||||
mWasLauncherAlreadyVisible, true,
|
||||
this::onAnimatorPlaybackControllerCreated);
|
||||
maybeUpdateRecentsAttachedState(false /* animate */);
|
||||
|
@ -888,7 +889,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
|||
if (mGestureState.getEndTarget() == HOME) {
|
||||
HomeAnimationFactory homeAnimFactory;
|
||||
if (mActivity != null) {
|
||||
homeAnimFactory = mActivityInterface.prepareHomeUI(mActivity);
|
||||
homeAnimFactory = mActivityInterface.prepareHomeUI();
|
||||
} else {
|
||||
homeAnimFactory = new HomeAnimationFactory() {
|
||||
@NonNull
|
||||
|
@ -1000,7 +1001,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
|||
}
|
||||
// Make sure recents is in its final state
|
||||
maybeUpdateRecentsAttachedState(false);
|
||||
mActivityInterface.onSwipeUpToHomeComplete(mActivity);
|
||||
mActivityInterface.onSwipeUpToHomeComplete();
|
||||
}
|
||||
});
|
||||
return anim;
|
||||
|
@ -1106,7 +1107,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
|||
|
||||
private void resetStateForAnimationCancel() {
|
||||
boolean wasVisible = mWasLauncherAlreadyVisible || mGestureStarted;
|
||||
mActivityInterface.onTransitionCancelled(mActivity, wasVisible);
|
||||
mActivityInterface.onTransitionCancelled(wasVisible);
|
||||
|
||||
// Leave the pending invisible flag, as it may be used by wallpaper open animation.
|
||||
mActivity.clearForceInvisibleFlag(INVISIBLE_BY_STATE_HANDLER);
|
||||
|
@ -1185,7 +1186,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
|
|||
|
||||
private void setupLauncherUiAfterSwipeUpToRecentsAnimation() {
|
||||
endLauncherTransitionController();
|
||||
mActivityInterface.onSwipeUpToRecentsComplete(mActivity);
|
||||
mActivityInterface.onSwipeUpToRecentsComplete();
|
||||
if (mRecentsAnimationController != null) {
|
||||
mRecentsAnimationController.setDeferCancelUntilNextTransition(true /* defer */,
|
||||
true /* screenshot */);
|
||||
|
|
|
@ -170,9 +170,9 @@ public class FallbackNoButtonInputConsumer extends
|
|||
}
|
||||
|
||||
@Override
|
||||
protected boolean onActivityInit(final RecentsActivity activity, Boolean alreadyOnHome) {
|
||||
mActivity = activity;
|
||||
mRecentsView = activity.getOverviewPanel();
|
||||
protected boolean onActivityInit(Boolean alreadyOnHome) {
|
||||
mActivity = mActivityInterface.getCreatedActivity();
|
||||
mRecentsView = mActivity.getOverviewPanel();
|
||||
linkRecentsViewScroll();
|
||||
mRecentsView.setDisallowScrollToClearAll(true);
|
||||
mRecentsView.getClearAllButton().setVisibilityAlpha(0);
|
||||
|
|
|
@ -69,7 +69,8 @@ public class QuickCaptureInputConsumer<T extends BaseDraggingActivity>
|
|||
|
||||
private final float mSquaredSlop;
|
||||
|
||||
private Context mContext;
|
||||
private final Context mContext;
|
||||
private final GestureState mGestureState;
|
||||
|
||||
private RecentsView mRecentsView;
|
||||
|
||||
|
@ -77,6 +78,7 @@ public class QuickCaptureInputConsumer<T extends BaseDraggingActivity>
|
|||
InputConsumer delegate, InputMonitorCompat inputMonitor) {
|
||||
super(delegate, inputMonitor);
|
||||
mContext = context;
|
||||
mGestureState = gestureState;
|
||||
|
||||
float slop = ViewConfiguration.get(context).getScaledTouchSlop();
|
||||
mSquaredSlop = slop * slop;
|
||||
|
@ -90,8 +92,8 @@ public class QuickCaptureInputConsumer<T extends BaseDraggingActivity>
|
|||
return TYPE_QUICK_CAPTURE | mDelegate.getType();
|
||||
}
|
||||
|
||||
private boolean onActivityInit(final BaseDraggingActivity activity, Boolean alreadyOnHome) {
|
||||
mRecentsView = activity.getOverviewPanel();
|
||||
private boolean onActivityInit(Boolean alreadyOnHome) {
|
||||
mRecentsView = mGestureState.getActivityInterface().getCreatedActivity().getOverviewPanel();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ import com.android.quickstep.util.ActivityInitListener;
|
|||
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;
|
||||
|
||||
/**
|
||||
* Utility class which abstracts out the logical differences between Launcher and RecentsActivity.
|
||||
|
@ -44,21 +44,21 @@ import java.util.function.Consumer;
|
|||
@TargetApi(Build.VERSION_CODES.P)
|
||||
public interface BaseActivityInterface<T extends BaseDraggingActivity> {
|
||||
|
||||
void onTransitionCancelled(T activity, boolean activityVisible);
|
||||
void onTransitionCancelled(boolean activityVisible);
|
||||
|
||||
int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect);
|
||||
|
||||
void onSwipeUpToRecentsComplete(T activity);
|
||||
void onSwipeUpToRecentsComplete();
|
||||
|
||||
default void onSwipeUpToHomeComplete(T activity) { }
|
||||
default void onSwipeUpToHomeComplete() { }
|
||||
void onAssistantVisibilityChanged(float visibility);
|
||||
|
||||
@NonNull HomeAnimationFactory prepareHomeUI(T activity);
|
||||
@NonNull HomeAnimationFactory prepareHomeUI();
|
||||
|
||||
AnimationFactory prepareRecentsUI(T activity, boolean activityVisible,
|
||||
boolean animateActivity, Consumer<AnimatorPlaybackController> callback);
|
||||
AnimationFactory prepareRecentsUI(boolean activityVisible, boolean animateActivity,
|
||||
Consumer<AnimatorPlaybackController> callback);
|
||||
|
||||
ActivityInitListener createActivityInitListener(BiPredicate<T, Boolean> onInitListener);
|
||||
ActivityInitListener createActivityInitListener(Predicate<Boolean> onInitListener);
|
||||
|
||||
/**
|
||||
* Sets a callback to be run when an activity launch happens while launcher is not yet resumed.
|
||||
|
@ -95,9 +95,9 @@ public interface BaseActivityInterface<T extends BaseDraggingActivity> {
|
|||
|
||||
boolean isInLiveTileMode();
|
||||
|
||||
void onLaunchTaskFailed(T activity);
|
||||
void onLaunchTaskFailed();
|
||||
|
||||
void onLaunchTaskSuccess(T activity);
|
||||
void onLaunchTaskSuccess();
|
||||
|
||||
default void closeOverlay() { }
|
||||
|
||||
|
|
Loading…
Reference in New Issue