Search in sources :

Example 16 with RemoteTargetHandle

use of com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle in project android_packages_apps_Launcher3 by ProtonAOSP.

the class SwipeUpAnimationLogic method initTransitionEndpoints.

protected void initTransitionEndpoints(DeviceProfile dp) {
    mDp = dp;
    mTransitionDragLength = mGestureState.getActivityInterface().getSwipeUpDestinationAndLength(dp, mContext, TEMP_RECT, mRemoteTargetHandles[0].getTaskViewSimulator().getOrientationState().getOrientationHandler());
    mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
    for (RemoteTargetHandle remoteHandle : mRemoteTargetHandles) {
        PendingAnimation pendingAnimation = new PendingAnimation(mTransitionDragLength * 2);
        TaskViewSimulator taskViewSimulator = remoteHandle.getTaskViewSimulator();
        taskViewSimulator.setDp(dp);
        taskViewSimulator.addAppToOverviewAnim(pendingAnimation, LINEAR);
        AnimatorPlaybackController playbackController = pendingAnimation.createPlaybackController();
        remoteHandle.setPlaybackController(AnimatorControllerWithResistance.createForRecents(playbackController, mContext, taskViewSimulator.getOrientationState(), mDp, taskViewSimulator.recentsViewScale, AnimatedFloat.VALUE, taskViewSimulator.recentsViewSecondaryTranslation, AnimatedFloat.VALUE));
    }
}
Also used : RemoteTargetHandle(com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle) PendingAnimation(com.android.launcher3.anim.PendingAnimation) TaskViewSimulator(com.android.quickstep.util.TaskViewSimulator) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 17 with RemoteTargetHandle

use of com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle in project android_packages_apps_Launcher3 by ProtonAOSP.

the class TaskViewUtils method createRecentsWindowAnimator.

public static void createRecentsWindowAnimator(@NonNull TaskView v, boolean skipViewChanges, @NonNull RemoteAnimationTargetCompat[] appTargets, @NonNull RemoteAnimationTargetCompat[] wallpaperTargets, @NonNull RemoteAnimationTargetCompat[] nonAppTargets, @Nullable DepthController depthController, PendingAnimation out) {
    RecentsView recentsView = v.getRecentsView();
    boolean isQuickSwitch = v.isEndQuickswitchCuj();
    v.setEndQuickswitchCuj(false);
    boolean inLiveTileMode = ENABLE_QUICKSTEP_LIVE_TILE.get() && v.getRecentsView().getRunningTaskIndex() != -1;
    final RemoteAnimationTargets targets = new RemoteAnimationTargets(appTargets, wallpaperTargets, nonAppTargets, inLiveTileMode ? MODE_CLOSING : MODE_OPENING);
    final RemoteAnimationTargetCompat navBarTarget = targets.getNavBarRemoteAnimationTarget();
    SurfaceTransactionApplier applier = new SurfaceTransactionApplier(v);
    targets.addReleaseCheck(applier);
    RemoteTargetHandle[] remoteTargetHandles;
    RemoteTargetHandle[] recentsViewHandles = recentsView.getRemoteTargetHandles();
    if (v.isRunningTask() && recentsViewHandles != null) {
        // Re-use existing handles
        remoteTargetHandles = recentsViewHandles;
    } else {
        RemoteTargetGluer gluer = new RemoteTargetGluer(v.getContext(), recentsView.getSizeStrategy(), targets);
        if (v.containsMultipleTasks()) {
            remoteTargetHandles = gluer.assignTargetsForSplitScreen(targets, v.getTaskIds());
        } else {
            remoteTargetHandles = gluer.assignTargets(targets);
        }
    }
    for (RemoteTargetHandle remoteTargetGluer : remoteTargetHandles) {
        remoteTargetGluer.getTransformParams().setSyncTransactionApplier(applier);
    }
    int taskIndex = recentsView.indexOfChild(v);
    Context context = v.getContext();
    DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
    boolean showAsGrid = dp.overviewShowAsGrid;
    boolean parallaxCenterAndAdjacentTask = taskIndex != recentsView.getCurrentPage() && !showAsGrid;
    int taskRectTranslationPrimary = recentsView.getScrollOffset(taskIndex);
    int taskRectTranslationSecondary = showAsGrid ? (int) v.getGridTranslationY() : 0;
    RemoteTargetHandle[] topMostSimulators = null;
    if (!v.isRunningTask()) {
        // TVSs already initialized from the running task, no need to re-init
        for (RemoteTargetHandle targetHandle : remoteTargetHandles) {
            TaskViewSimulator tvsLocal = targetHandle.getTaskViewSimulator();
            tvsLocal.setDp(dp);
            // RecentsView never updates the display rotation until swipe-up so the value may
            // be stale. Use the display value instead.
            int displayRotation = DisplayController.INSTANCE.get(context).getInfo().rotation;
            tvsLocal.getOrientationState().update(displayRotation, displayRotation);
            tvsLocal.fullScreenProgress.value = 0;
            tvsLocal.recentsViewScale.value = 1;
            tvsLocal.setIsGridTask(v.isGridTask());
            tvsLocal.getOrientationState().getOrientationHandler().set(tvsLocal, TaskViewSimulator::setTaskRectTranslation, taskRectTranslationPrimary, taskRectTranslationSecondary);
            // Fade in the task during the initial 20% of the animation
            out.addFloat(targetHandle.getTransformParams(), TransformParams.TARGET_ALPHA, 0, 1, clampToProgress(LINEAR, 0, 0.2f));
        }
    }
    for (RemoteTargetHandle targetHandle : remoteTargetHandles) {
        TaskViewSimulator tvsLocal = targetHandle.getTaskViewSimulator();
        out.setFloat(tvsLocal.fullScreenProgress, AnimatedFloat.VALUE, 1, TOUCH_RESPONSE_INTERPOLATOR);
        out.setFloat(tvsLocal.recentsViewScale, AnimatedFloat.VALUE, tvsLocal.getFullScreenScale(), TOUCH_RESPONSE_INTERPOLATOR);
        out.setFloat(tvsLocal.recentsViewScroll, AnimatedFloat.VALUE, 0, TOUCH_RESPONSE_INTERPOLATOR);
        out.addOnFrameCallback(() -> {
            for (RemoteTargetHandle handle : remoteTargetHandles) {
                handle.getTaskViewSimulator().apply(handle.getTransformParams());
            }
        });
        if (navBarTarget != null) {
            final Rect cropRect = new Rect();
            out.addOnFrameListener(new MultiValueUpdateListener() {

                FloatProp mNavFadeOut = new FloatProp(1f, 0f, 0, ANIMATION_NAV_FADE_OUT_DURATION, NAV_FADE_OUT_INTERPOLATOR);

                FloatProp mNavFadeIn = new FloatProp(0f, 1f, ANIMATION_DELAY_NAV_FADE_IN, ANIMATION_NAV_FADE_IN_DURATION, NAV_FADE_IN_INTERPOLATOR);

                @Override
                public void onUpdate(float percent, boolean initOnly) {
                    final SurfaceParams.Builder navBuilder = new SurfaceParams.Builder(navBarTarget.leash);
                    // TODO Do we need to operate over multiple TVSs for the navbar leash?
                    for (RemoteTargetHandle handle : remoteTargetHandles) {
                        if (mNavFadeIn.value > mNavFadeIn.getStartValue()) {
                            TaskViewSimulator taskViewSimulator = handle.getTaskViewSimulator();
                            taskViewSimulator.getCurrentCropRect().round(cropRect);
                            navBuilder.withMatrix(taskViewSimulator.getCurrentMatrix()).withWindowCrop(cropRect).withAlpha(mNavFadeIn.value);
                        } else {
                            navBuilder.withAlpha(mNavFadeOut.value);
                        }
                        handle.getTransformParams().applySurfaceParams(navBuilder.build());
                    }
                }
            });
        } else if (inLiveTileMode) {
            // There is no transition animation for app launch from recent in live tile mode so
            // we have to trigger the navigation bar animation from system here.
            final RecentsAnimationController controller = recentsView.getRecentsAnimationController();
            if (controller != null) {
                controller.animateNavigationBarToApp(RECENTS_LAUNCH_DURATION);
            }
        }
        topMostSimulators = remoteTargetHandles;
    }
    if (!skipViewChanges && parallaxCenterAndAdjacentTask && topMostSimulators.length > 0) {
        out.addFloat(v, VIEW_ALPHA, 1, 0, clampToProgress(LINEAR, 0.2f, 0.4f));
        RemoteTargetHandle[] simulatorCopies = topMostSimulators;
        for (RemoteTargetHandle handle : simulatorCopies) {
            handle.getTaskViewSimulator().apply(handle.getTransformParams());
        }
        // Mt represents the overall transformation on the thumbnailView relative to the
        // Launcher's rootView
        // K(t) represents transformation on the running window by the taskViewSimulator at
        // any time t.
        // at t = 0, we know that the simulator matches the thumbnailView. So if we apply K(0)`
        // on the Launcher's rootView, the thumbnailView would match the full running task
        // window. If we apply "K(0)` K(t)" thumbnailView will match the final transformed
        // window at any time t. This gives the overall matrix on thumbnailView to be:
        // Mt K(0)` K(t)
        // During animation we apply transformation on the thumbnailView (and not the rootView)
        // to follow the TaskViewSimulator. So the final matrix applied on the thumbnailView is:
        // Mt K(0)` K(t) Mt`
        TaskThumbnailView[] thumbnails = v.getThumbnails();
        Matrix[] mt = new Matrix[simulatorCopies.length];
        Matrix[] mti = new Matrix[simulatorCopies.length];
        for (int i = 0; i < thumbnails.length; i++) {
            TaskThumbnailView ttv = thumbnails[i];
            RectF localBounds = new RectF(0, 0, ttv.getWidth(), ttv.getHeight());
            float[] tvBoundsMapped = new float[] { 0, 0, ttv.getWidth(), ttv.getHeight() };
            getDescendantCoordRelativeToAncestor(ttv, ttv.getRootView(), tvBoundsMapped, false);
            RectF localBoundsInRoot = new RectF(tvBoundsMapped[0], tvBoundsMapped[1], tvBoundsMapped[2], tvBoundsMapped[3]);
            Matrix localMt = new Matrix();
            localMt.setRectToRect(localBounds, localBoundsInRoot, ScaleToFit.FILL);
            mt[i] = localMt;
            Matrix localMti = new Matrix();
            localMt.invert(localMti);
            mti[i] = localMti;
        }
        Matrix[] k0i = new Matrix[simulatorCopies.length];
        for (int i = 0; i < simulatorCopies.length; i++) {
            k0i[i] = new Matrix();
            simulatorCopies[i].getTaskViewSimulator().getCurrentMatrix().invert(k0i[i]);
        }
        Matrix animationMatrix = new Matrix();
        out.addOnFrameCallback(() -> {
            for (int i = 0; i < simulatorCopies.length; i++) {
                animationMatrix.set(mt[i]);
                animationMatrix.postConcat(k0i[i]);
                animationMatrix.postConcat(simulatorCopies[i].getTaskViewSimulator().getCurrentMatrix());
                animationMatrix.postConcat(mti[i]);
                thumbnails[i].setAnimationMatrix(animationMatrix);
            }
        });
        out.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                for (TaskThumbnailView ttv : thumbnails) {
                    ttv.setAnimationMatrix(null);
                }
            }
        });
    }
    out.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            if (isQuickSwitch) {
                InteractionJankMonitorWrapper.end(InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH);
            }
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            targets.release();
            super.onAnimationEnd(animation);
        }
    });
    if (depthController != null) {
        out.setFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(context), TOUCH_RESPONSE_INTERPOLATOR);
    }
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) Matrix(android.graphics.Matrix) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SurfaceParams(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener) Context(android.content.Context) Rect(android.graphics.Rect) TaskViewSimulator(com.android.quickstep.util.TaskViewSimulator) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) RectF(android.graphics.RectF) RemoteTargetHandle(com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) RecentsView(com.android.quickstep.views.RecentsView) TaskThumbnailView(com.android.quickstep.views.TaskThumbnailView)

Example 18 with RemoteTargetHandle

use of com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle in project android_packages_apps_404Launcher by P-404.

the class SwipeUpAnimationLogic method initTransitionEndpoints.

protected void initTransitionEndpoints(DeviceProfile dp) {
    mDp = dp;
    mTransitionDragLength = mGestureState.getActivityInterface().getSwipeUpDestinationAndLength(dp, mContext, TEMP_RECT, mRemoteTargetHandles[0].getTaskViewSimulator().getOrientationState().getOrientationHandler());
    mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
    for (RemoteTargetHandle remoteHandle : mRemoteTargetHandles) {
        PendingAnimation pendingAnimation = new PendingAnimation(mTransitionDragLength * 2);
        TaskViewSimulator taskViewSimulator = remoteHandle.getTaskViewSimulator();
        taskViewSimulator.setDp(dp);
        taskViewSimulator.addAppToOverviewAnim(pendingAnimation, LINEAR);
        AnimatorPlaybackController playbackController = pendingAnimation.createPlaybackController();
        remoteHandle.setPlaybackController(AnimatorControllerWithResistance.createForRecents(playbackController, mContext, taskViewSimulator.getOrientationState(), mDp, taskViewSimulator.recentsViewScale, AnimatedFloat.VALUE, taskViewSimulator.recentsViewSecondaryTranslation, AnimatedFloat.VALUE));
    }
}
Also used : RemoteTargetHandle(com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle) PendingAnimation(com.android.launcher3.anim.PendingAnimation) TaskViewSimulator(com.android.quickstep.util.TaskViewSimulator) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 19 with RemoteTargetHandle

use of com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle in project android_packages_apps_404Launcher by P-404.

the class AbsSwipeUpHandler method applyScrollAndTransform.

/**
 * Applies the transform on the recents animation
 */
protected void applyScrollAndTransform() {
    // No need to apply any transform if there is ongoing swipe-pip-to-home animator since
    // that animator handles the leash solely.
    boolean notSwipingPipToHome = mRecentsAnimationTargets != null && !mIsSwipingPipToHome;
    boolean setRecentsScroll = mRecentsViewScrollLinked && mRecentsView != null;
    for (RemoteTargetHandle remoteHandle : mRemoteTargetHandles) {
        AnimatorControllerWithResistance playbackController = remoteHandle.getPlaybackController();
        if (playbackController != null) {
            playbackController.setProgress(Math.max(mCurrentShift.value, getScaleProgressDueToScroll()), mDragLengthFactor);
        }
        if (notSwipingPipToHome) {
            TaskViewSimulator taskViewSimulator = remoteHandle.getTaskViewSimulator();
            if (setRecentsScroll) {
                taskViewSimulator.setScroll(mRecentsView.getScrollOffset());
            }
            taskViewSimulator.apply(remoteHandle.getTransformParams());
        }
    }
    ProtoTracer.INSTANCE.get(mContext).scheduleFrameUpdate();
}
Also used : RemoteTargetHandle(com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle) TaskViewSimulator(com.android.quickstep.util.TaskViewSimulator) AnimatorControllerWithResistance(com.android.quickstep.util.AnimatorControllerWithResistance)

Example 20 with RemoteTargetHandle

use of com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle in project android_packages_apps_404Launcher by P-404.

the class RecentsView method createAdjacentPageAnimForTaskLaunch.

/**
 * Animate adjacent tasks off screen while scaling up.
 *
 * If launching one of the adjacent tasks, parallax the center task and other adjacent task
 * to the right.
 */
public AnimatorSet createAdjacentPageAnimForTaskLaunch(TaskView tv) {
    AnimatorSet anim = new AnimatorSet();
    int taskIndex = indexOfChild(tv);
    int centerTaskIndex = getCurrentPage();
    boolean launchingCenterTask = taskIndex == centerTaskIndex;
    float toScale = getMaxScaleForFullScreen();
    RecentsView recentsView = tv.getRecentsView();
    if (launchingCenterTask) {
        anim.play(ObjectAnimator.ofFloat(recentsView, RECENTS_SCALE_PROPERTY, toScale));
        anim.play(ObjectAnimator.ofFloat(recentsView, FULLSCREEN_PROGRESS, 1));
    } else {
        // We are launching an adjacent task, so parallax the center and other adjacent task.
        float displacementX = tv.getWidth() * (toScale - 1f);
        float primaryTranslation = mIsRtl ? -displacementX : displacementX;
        anim.play(ObjectAnimator.ofFloat(getPageAt(centerTaskIndex), mOrientationHandler.getPrimaryViewTranslate(), primaryTranslation));
        int runningTaskIndex = recentsView.getRunningTaskIndex();
        if (ENABLE_QUICKSTEP_LIVE_TILE.get() && runningTaskIndex != -1 && runningTaskIndex != taskIndex) {
            final RemoteTargetHandle[] remoteTargetHandles = recentsView.getRemoteTargetHandles();
            if (remoteTargetHandles != null) {
                for (RemoteTargetHandle remoteHandle : remoteTargetHandles) {
                    anim.play(ObjectAnimator.ofFloat(remoteHandle.getTaskViewSimulator().taskPrimaryTranslation, AnimatedFloat.VALUE, primaryTranslation));
                }
            }
        }
        int otherAdjacentTaskIndex = centerTaskIndex + (centerTaskIndex - taskIndex);
        if (otherAdjacentTaskIndex >= 0 && otherAdjacentTaskIndex < getPageCount()) {
            PropertyValuesHolder[] properties = new PropertyValuesHolder[3];
            properties[0] = PropertyValuesHolder.ofFloat(mOrientationHandler.getPrimaryViewTranslate(), primaryTranslation);
            properties[1] = PropertyValuesHolder.ofFloat(View.SCALE_X, 1);
            properties[2] = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
            anim.play(ObjectAnimator.ofPropertyValuesHolder(getPageAt(otherAdjacentTaskIndex), properties));
        }
    }
    return anim;
}
Also used : RemoteTargetHandle(com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle) PropertyValuesHolder(android.animation.PropertyValuesHolder) AnimatorSet(android.animation.AnimatorSet) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Aggregations

RemoteTargetHandle (com.android.quickstep.RemoteTargetGluer.RemoteTargetHandle)32 TaskViewSimulator (com.android.quickstep.util.TaskViewSimulator)20 Matrix (android.graphics.Matrix)16 RectF (android.graphics.RectF)16 Animator (android.animation.Animator)12 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)12 AnimatorSet (android.animation.AnimatorSet)12 ObjectAnimator (android.animation.ObjectAnimator)12 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)12 PropertyValuesHolder (android.animation.PropertyValuesHolder)8 ValueAnimator (android.animation.ValueAnimator)8 Context (android.content.Context)8 Point (android.graphics.Point)8 Rect (android.graphics.Rect)8 TextPaint (android.text.TextPaint)8 DeviceProfile (com.android.launcher3.DeviceProfile)8 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)8 PendingAnimation (com.android.launcher3.anim.PendingAnimation)8 RemoteAnimationTargets (com.android.quickstep.RemoteAnimationTargets)8 SystemUiProxy (com.android.quickstep.SystemUiProxy)8