2019-01-16 18:51:53 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2018 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;
|
|
|
|
|
|
|
|
|
|
import static com.android.launcher3.LauncherState.NORMAL;
|
|
|
|
|
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
|
|
|
|
|
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
2020-05-18 14:02:49 -07:00
|
|
|
import static com.android.quickstep.TaskViewUtils.createRecentsWindowAnimator;
|
2019-01-29 16:42:26 -08:00
|
|
|
import static com.android.quickstep.TaskViewUtils.findTaskViewToLaunch;
|
2019-01-16 18:51:53 -08:00
|
|
|
|
|
|
|
|
import android.animation.Animator;
|
|
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
|
|
import android.animation.AnimatorSet;
|
|
|
|
|
import android.animation.ObjectAnimator;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
|
2019-09-10 15:19:05 -07:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
2019-01-16 18:51:53 -08:00
|
|
|
import com.android.launcher3.anim.AnimatorPlaybackController;
|
|
|
|
|
import com.android.launcher3.anim.Interpolators;
|
2020-05-18 14:02:49 -07:00
|
|
|
import com.android.launcher3.anim.PendingAnimation;
|
2019-01-16 18:51:53 -08:00
|
|
|
import com.android.quickstep.views.RecentsView;
|
|
|
|
|
import com.android.quickstep.views.TaskView;
|
|
|
|
|
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A {@link QuickstepAppTransitionManagerImpl} that also implements recents transitions from
|
|
|
|
|
* {@link RecentsView}.
|
|
|
|
|
*/
|
|
|
|
|
public final class LauncherAppTransitionManagerImpl extends QuickstepAppTransitionManagerImpl {
|
|
|
|
|
|
|
|
|
|
public LauncherAppTransitionManagerImpl(Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean isLaunchingFromRecents(@NonNull View v,
|
|
|
|
|
@Nullable RemoteAnimationTargetCompat[] targets) {
|
|
|
|
|
return mLauncher.getStateManager().getState().overviewUi
|
|
|
|
|
&& findTaskViewToLaunch(mLauncher, v, targets) != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void composeRecentsLaunchAnimator(@NonNull AnimatorSet anim, @NonNull View v,
|
2019-09-10 15:19:05 -07:00
|
|
|
@NonNull RemoteAnimationTargetCompat[] appTargets,
|
|
|
|
|
@NonNull RemoteAnimationTargetCompat[] wallpaperTargets, boolean launcherClosing) {
|
2019-01-16 18:51:53 -08:00
|
|
|
RecentsView recentsView = mLauncher.getOverviewPanel();
|
|
|
|
|
boolean skipLauncherChanges = !launcherClosing;
|
|
|
|
|
|
2019-09-10 15:19:05 -07:00
|
|
|
TaskView taskView = findTaskViewToLaunch(mLauncher, v, appTargets);
|
2020-05-18 14:02:49 -07:00
|
|
|
PendingAnimation pa = new PendingAnimation(RECENTS_LAUNCH_DURATION);
|
|
|
|
|
createRecentsWindowAnimator(taskView, skipLauncherChanges, appTargets, wallpaperTargets,
|
|
|
|
|
mLauncher.getDepthController(), pa);
|
|
|
|
|
anim.play(pa.buildAnim());
|
2019-01-16 18:51:53 -08:00
|
|
|
|
|
|
|
|
Animator childStateAnimation = null;
|
|
|
|
|
// Found a visible recents task that matches the opening app, lets launch the app from there
|
|
|
|
|
Animator launcherAnim;
|
|
|
|
|
final AnimatorListenerAdapter windowAnimEndListener;
|
|
|
|
|
if (launcherClosing) {
|
2020-05-06 02:14:20 -07:00
|
|
|
launcherAnim = recentsView.createAdjacentPageAnimForTaskLaunch(taskView);
|
2019-01-16 18:51:53 -08:00
|
|
|
launcherAnim.setInterpolator(Interpolators.TOUCH_RESPONSE_INTERPOLATOR);
|
2019-02-13 14:57:52 -08:00
|
|
|
launcherAnim.setDuration(RECENTS_LAUNCH_DURATION);
|
2019-01-16 18:51:53 -08:00
|
|
|
|
|
|
|
|
// Make sure recents gets fixed up by resetting task alphas and scales, etc.
|
|
|
|
|
windowAnimEndListener = new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
mLauncher.getStateManager().moveToRestState();
|
|
|
|
|
mLauncher.getStateManager().reapplyState();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
AnimatorPlaybackController controller =
|
2019-02-13 14:57:52 -08:00
|
|
|
mLauncher.getStateManager().createAnimationToNewWorkspace(NORMAL,
|
|
|
|
|
RECENTS_LAUNCH_DURATION);
|
2019-01-16 18:51:53 -08:00
|
|
|
controller.dispatchOnStart();
|
|
|
|
|
childStateAnimation = controller.getTarget();
|
2019-02-13 14:57:52 -08:00
|
|
|
launcherAnim = controller.getAnimationPlayer().setDuration(RECENTS_LAUNCH_DURATION);
|
2019-01-16 18:51:53 -08:00
|
|
|
windowAnimEndListener = new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
mLauncher.getStateManager().goToState(NORMAL, false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
anim.play(launcherAnim);
|
|
|
|
|
|
|
|
|
|
// Set the current animation first, before adding windowAnimEndListener. Setting current
|
|
|
|
|
// animation adds some listeners which need to be called before windowAnimEndListener
|
|
|
|
|
// (the ordering of listeners matter in this case).
|
|
|
|
|
mLauncher.getStateManager().setCurrentAnimation(anim, childStateAnimation);
|
|
|
|
|
anim.addListener(windowAnimEndListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Runnable composeViewContentAnimator(@NonNull AnimatorSet anim, float[] alphas,
|
|
|
|
|
float[] trans) {
|
|
|
|
|
RecentsView overview = mLauncher.getOverviewPanel();
|
|
|
|
|
ObjectAnimator alpha = ObjectAnimator.ofFloat(overview,
|
|
|
|
|
RecentsView.CONTENT_ALPHA, alphas);
|
|
|
|
|
alpha.setDuration(CONTENT_ALPHA_DURATION);
|
|
|
|
|
alpha.setInterpolator(LINEAR);
|
|
|
|
|
anim.play(alpha);
|
2019-06-05 12:07:07 -07:00
|
|
|
overview.setFreezeViewVisibility(true);
|
2019-01-16 18:51:53 -08:00
|
|
|
|
|
|
|
|
ObjectAnimator transY = ObjectAnimator.ofFloat(overview, View.TRANSLATION_Y, trans);
|
|
|
|
|
transY.setInterpolator(AGGRESSIVE_EASE);
|
|
|
|
|
transY.setDuration(CONTENT_TRANSLATION_DURATION);
|
|
|
|
|
anim.play(transY);
|
|
|
|
|
|
2019-06-05 12:07:07 -07:00
|
|
|
return () -> {
|
|
|
|
|
overview.setFreezeViewVisibility(false);
|
2020-04-30 17:04:39 -07:00
|
|
|
overview.setTranslationY(0);
|
2019-06-05 12:07:07 -07:00
|
|
|
mLauncher.getStateManager().reapplyState();
|
|
|
|
|
};
|
2019-01-16 18:51:53 -08:00
|
|
|
}
|
|
|
|
|
}
|