Search in sources :

Example 6 with TaskView

use of com.android.quickstep.views.TaskView in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskViewUtils method composeRecentsLaunchAnimator.

public static void composeRecentsLaunchAnimator(@NonNull AnimatorSet anim, @NonNull View v, @NonNull RemoteAnimationTargetCompat[] appTargets, @NonNull RemoteAnimationTargetCompat[] wallpaperTargets, @NonNull RemoteAnimationTargetCompat[] nonAppTargets, boolean launcherClosing, @NonNull StateManager stateManager, @NonNull RecentsView recentsView, @NonNull DepthController depthController) {
    boolean skipLauncherChanges = !launcherClosing;
    TaskView taskView = findTaskViewToLaunch(recentsView, v, appTargets);
    PendingAnimation pa = new PendingAnimation(RECENTS_LAUNCH_DURATION);
    createRecentsWindowAnimator(taskView, skipLauncherChanges, appTargets, wallpaperTargets, nonAppTargets, depthController, pa);
    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) {
        Context context = v.getContext();
        DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
        launcherAnim = dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get() ? ObjectAnimator.ofFloat(recentsView, RecentsView.CONTENT_ALPHA, 0) : recentsView.createAdjacentPageAnimForTaskLaunch(taskView);
        launcherAnim.setInterpolator(Interpolators.TOUCH_RESPONSE_INTERPOLATOR);
        launcherAnim.setDuration(RECENTS_LAUNCH_DURATION);
        // Make sure recents gets fixed up by resetting task alphas and scales, etc.
        windowAnimEndListener = new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                recentsView.finishRecentsAnimation(false, /* toRecents */
                () -> {
                    recentsView.post(() -> {
                        stateManager.moveToRestState();
                        stateManager.reapplyState();
                    });
                });
            }
        };
    } else {
        AnimatorPlaybackController controller = stateManager.createAnimationToNewWorkspace(NORMAL, RECENTS_LAUNCH_DURATION);
        controller.dispatchOnStart();
        childStateAnimation = controller.getTarget();
        launcherAnim = controller.getAnimationPlayer().setDuration(RECENTS_LAUNCH_DURATION);
        windowAnimEndListener = new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                recentsView.finishRecentsAnimation(false, /* toRecents */
                () -> stateManager.goToState(NORMAL, false));
            }
        };
    }
    pa.add(launcherAnim);
    if (ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1) {
        pa.addOnFrameCallback(recentsView::redrawLiveTile);
    }
    anim.play(pa.buildAnim());
    // 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).
    stateManager.setCurrentAnimation(anim, childStateAnimation);
    anim.addListener(windowAnimEndListener);
}
Also used : Context(android.content.Context) PendingAnimation(com.android.launcher3.anim.PendingAnimation) DeviceProfile(com.android.launcher3.DeviceProfile) TaskView(com.android.quickstep.views.TaskView) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 7 with TaskView

use of com.android.quickstep.views.TaskView in project android_packages_apps_Launcher3 by crdroidandroid.

the class FallbackRecentsView method onPrepareGestureEndAnimation.

/**
 * When the gesture ends and we're going to recents view, we also remove the temporary
 * invisible tile added for the home task. This also pushes the remaining tiles back
 * to the center.
 */
@Override
public void onPrepareGestureEndAnimation(@Nullable AnimatorSet animatorSet, GestureState.GestureEndTarget endTarget) {
    super.onPrepareGestureEndAnimation(animatorSet, endTarget);
    if (mHomeTaskInfo != null && endTarget == RECENTS && animatorSet != null) {
        TaskView tv = getTaskView(mHomeTaskInfo.taskId);
        if (tv != null) {
            PendingAnimation pa = createTaskDismissAnimation(tv, true, false, 150);
            pa.addEndListener(e -> setCurrentTask(-1));
            AnimatorPlaybackController controller = pa.createPlaybackController();
            controller.dispatchOnStart();
            animatorSet.play(controller.getAnimationPlayer());
        }
    }
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) TaskView(com.android.quickstep.views.TaskView) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 8 with TaskView

use of com.android.quickstep.views.TaskView in project android_packages_apps_Launcher3 by crdroidandroid.

the class AbsSwipeUpHandler method updateThumbnail.

// Returns whether finish transition was posted.
private boolean updateThumbnail(int runningTaskId, boolean refreshView) {
    boolean finishTransitionPosted = false;
    final TaskView taskView;
    if (mGestureState.getEndTarget() == HOME || mGestureState.getEndTarget() == NEW_TASK) {
        // Capture the screenshot before finishing the transition to home or quickswitching to
        // ensure it's taken in the correct orientation, but no need to update the thumbnail.
        taskView = null;
    } else {
        taskView = mRecentsView.updateThumbnail(runningTaskId, mTaskSnapshot, refreshView);
    }
    if (taskView != null && refreshView && !mCanceled) {
        // Defer finishing the animation until the next launcher frame with the
        // new thumbnail
        finishTransitionPosted = ViewUtils.postFrameDrawn(taskView, () -> mStateCallback.setStateOnUiThread(STATE_SCREENSHOT_CAPTURED), this::isCanceled);
    }
    return finishTransitionPosted;
}
Also used : TaskView(com.android.quickstep.views.TaskView)

Example 9 with TaskView

use of com.android.quickstep.views.TaskView in project android_packages_apps_Launcher3 by crdroidandroid.

the class AbsSwipeUpHandler method startNewTask.

protected void startNewTask(Consumer<Boolean> resultCallback) {
    // Launch the task user scrolled to (mRecentsView.getNextPage()).
    if (!mCanceled) {
        TaskView nextTask = mRecentsView.getNextPageTaskView();
        if (nextTask != null) {
            int taskId = nextTask.getTask().key.id;
            mGestureState.updateLastStartedTaskId(taskId);
            boolean hasTaskPreviouslyAppeared = mGestureState.getPreviouslyAppearedTaskIds().contains(taskId);
            nextTask.launchTask(success -> {
                resultCallback.accept(success);
                if (success) {
                    if (hasTaskPreviouslyAppeared) {
                        onRestartPreviouslyAppearedTask();
                    }
                } else {
                    mActivityInterface.onLaunchTaskFailed();
                    if (mRecentsAnimationController != null) {
                        mRecentsAnimationController.finish(true, /* toRecents */
                        null);
                    }
                }
            }, true);
        } else {
            mActivityInterface.onLaunchTaskFailed();
            Toast.makeText(mContext, R.string.activity_not_available, LENGTH_SHORT).show();
            if (mRecentsAnimationController != null) {
                mRecentsAnimationController.finish(true, /* toRecents */
                null);
            }
        }
    }
    mCanceled = false;
}
Also used : TaskView(com.android.quickstep.views.TaskView)

Example 10 with TaskView

use of com.android.quickstep.views.TaskView in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskViewUtils method findTaskViewToLaunch.

/**
 * Try to find a TaskView that corresponds with the component of the launched view.
 *
 * If this method returns a non-null TaskView, it will be used in composeRecentsLaunchAnimation.
 * Otherwise, we will assume we are using a normal app transition, but it's possible that the
 * opening remote target (which we don't get until onAnimationStart) will resolve to a TaskView.
 */
public static TaskView findTaskViewToLaunch(RecentsView recentsView, View v, RemoteAnimationTargetCompat[] targets) {
    if (v instanceof TaskView) {
        TaskView taskView = (TaskView) v;
        return recentsView.isTaskViewVisible(taskView) ? taskView : null;
    }
    // the task id of the opening task and see if we can find a match.
    if (v.getTag() instanceof ItemInfo) {
        ItemInfo itemInfo = (ItemInfo) v.getTag();
        ComponentName componentName = itemInfo.getTargetComponent();
        int userId = itemInfo.user.getIdentifier();
        if (componentName != null) {
            for (int i = 0; i < recentsView.getTaskViewCount(); i++) {
                TaskView taskView = recentsView.getTaskViewAt(i);
                if (recentsView.isTaskViewVisible(taskView)) {
                    Task.TaskKey key = taskView.getTask().key;
                    if (componentName.equals(key.getComponent()) && userId == key.userId) {
                        return taskView;
                    }
                }
            }
        }
    }
    if (targets == null) {
        return null;
    }
    // Resolve the opening task id
    int openingTaskId = -1;
    for (RemoteAnimationTargetCompat target : targets) {
        if (target.mode == MODE_OPENING) {
            openingTaskId = target.taskId;
            break;
        }
    }
    // If there is no opening task id, fall back to the normal app icon launch animation
    if (openingTaskId == -1) {
        return null;
    }
    // If the opening task id is not currently visible in overview, then fall back to normal app
    // icon launch animation
    TaskView taskView = recentsView.getTaskView(openingTaskId);
    if (taskView == null || !recentsView.isTaskViewVisible(taskView)) {
        return null;
    }
    return taskView;
}
Also used : TaskView(com.android.quickstep.views.TaskView) Task(com.android.systemui.shared.recents.model.Task) ItemInfo(com.android.launcher3.model.data.ItemInfo) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) ComponentName(android.content.ComponentName)

Aggregations

TaskView (com.android.quickstep.views.TaskView)14 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)2 PendingAnimation (com.android.launcher3.anim.PendingAnimation)2 RecentsView (com.android.quickstep.views.RecentsView)2 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 Intent (android.content.Intent)1 PointF (android.graphics.PointF)1 UiThread (androidx.annotation.UiThread)1 DeviceProfile (com.android.launcher3.DeviceProfile)1 LauncherAnimationRunner (com.android.launcher3.LauncherAnimationRunner)1 AnimationResult (com.android.launcher3.LauncherAnimationRunner.AnimationResult)1 RemoteAnimationFactory (com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory)1 ItemInfo (com.android.launcher3.model.data.ItemInfo)1 ActivityOptionsWrapper (com.android.launcher3.util.ActivityOptionsWrapper)1