Search in sources :

Example 1 with DepthController

use of com.android.launcher3.statehandlers.DepthController in project android_packages_apps_Launcher3 by crdroidandroid.

the class QuickstepTransitionManager method getBackgroundAnimator.

private ObjectAnimator getBackgroundAnimator(RemoteAnimationTargetCompat[] appTargets) {
    // When launching an app from overview that doesn't map to a task, we still want to just
    // blur the wallpaper instead of the launcher surface as well
    boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW;
    DepthController depthController = mLauncher.getDepthController();
    ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(mLauncher)).setDuration(APP_LAUNCH_DURATION);
    if (allowBlurringLauncher) {
        final SurfaceControl dimLayer;
        if (BlurUtils.supportsBlursOnWindows()) {
            // Create a temporary effect layer, that lives on top of launcher, so we can apply
            // the blur to it. The EffectLayer will be fullscreen, which will help with caching
            // optimizations on the SurfaceFlinger side:
            // - Results would be able to be cached as a texture
            // - There won't be texture allocation overhead, because EffectLayers don't have
            // buffers
            ViewRootImpl viewRootImpl = mLauncher.getDragLayer().getViewRootImpl();
            SurfaceControl parent = viewRootImpl != null ? viewRootImpl.getSurfaceControl() : null;
            dimLayer = new SurfaceControl.Builder().setName("Blur layer").setParent(parent).setOpaque(false).setHidden(false).setEffectLayer().build();
        } else {
            dimLayer = null;
        }
        depthController.setSurface(dimLayer);
        backgroundRadiusAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
                depthController.setIsInLaunchTransition(true);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                depthController.setIsInLaunchTransition(false);
                depthController.setSurface(null);
                if (dimLayer != null) {
                    new SurfaceControl.Transaction().remove(dimLayer).apply();
                }
            }
        });
    }
    return backgroundRadiusAnim;
}
Also used : ViewRootImpl(android.view.ViewRootImpl) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) SurfaceControl(android.view.SurfaceControl) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) DepthController(com.android.launcher3.statehandlers.DepthController)

Example 2 with DepthController

use of com.android.launcher3.statehandlers.DepthController in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskViewUtils method composeRecentsSplitLaunchAnimatorLegacy.

/**
 * Legacy version (until shell transitions are enabled)
 */
public static void composeRecentsSplitLaunchAnimatorLegacy(@NonNull AnimatorSet anim, @NonNull TaskView v, @NonNull RemoteAnimationTargetCompat[] appTargets, @NonNull RemoteAnimationTargetCompat[] wallpaperTargets, @NonNull RemoteAnimationTargetCompat[] nonAppTargets, boolean launcherClosing, @NonNull StateManager stateManager, @NonNull DepthController depthController, int targetStage) {
    PendingAnimation out = new PendingAnimation(RECENTS_LAUNCH_DURATION);
    boolean isRunningTask = v.isRunningTask();
    TransformParams params = null;
    TaskViewSimulator tvs = null;
    RecentsView recentsView = v.getRecentsView();
    if (ENABLE_QUICKSTEP_LIVE_TILE.get() && isRunningTask) {
        params = recentsView.getLiveTileParams();
        tvs = recentsView.getLiveTileTaskViewSimulator();
    }
    boolean inLiveTileMode = ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1;
    final RemoteAnimationTargets targets = new RemoteAnimationTargets(appTargets, wallpaperTargets, nonAppTargets, inLiveTileMode ? MODE_CLOSING : MODE_OPENING);
    if (params == null) {
        SurfaceTransactionApplier applier = new SurfaceTransactionApplier(v);
        targets.addReleaseCheck(applier);
        params = new TransformParams().setSyncTransactionApplier(applier).setTargetSet(targets);
    }
    Rect crop = new Rect();
    Context context = v.getContext();
    DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
    if (tvs == null && targets.apps.length > 0) {
        tvs = new TaskViewSimulator(recentsView.getContext(), recentsView.getSizeStrategy());
        tvs.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(recentsView.getContext()).getInfo().rotation;
        tvs.getOrientationState().update(displayRotation, displayRotation);
        tvs.setPreview(targets.apps[targets.apps.length - 1]);
        tvs.fullScreenProgress.value = 0;
        tvs.recentsViewScale.value = 1;
        // tvs.setScroll(startScroll);
        // Fade in the task during the initial 20% of the animation
        out.addFloat(params, TransformParams.TARGET_ALPHA, 0, 1, clampToProgress(LINEAR, 0, 0.2f));
    }
    TaskViewSimulator topMostSimulator = null;
    if (tvs != null) {
        out.setFloat(tvs.fullScreenProgress, AnimatedFloat.VALUE, 1, TOUCH_RESPONSE_INTERPOLATOR);
        out.setFloat(tvs.recentsViewScale, AnimatedFloat.VALUE, tvs.getFullScreenScale(), TOUCH_RESPONSE_INTERPOLATOR);
        out.setFloat(tvs.recentsViewScroll, AnimatedFloat.VALUE, 0, TOUCH_RESPONSE_INTERPOLATOR);
        TaskViewSimulator finalTsv = tvs;
        TransformParams finalParams = params;
        out.addOnFrameCallback(() -> finalTsv.apply(finalParams));
        topMostSimulator = tvs;
    }
    anim.play(out.buildAnim());
}
Also used : Context(android.content.Context) PendingAnimation(com.android.launcher3.anim.PendingAnimation) DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) TaskViewSimulator(com.android.quickstep.util.TaskViewSimulator) TransformParams(com.android.quickstep.util.TransformParams) RecentsView(com.android.quickstep.views.RecentsView)

Example 3 with DepthController

use of com.android.launcher3.statehandlers.DepthController 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 4 with DepthController

use of com.android.launcher3.statehandlers.DepthController in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsView method createTaskLaunchAnimation.

public PendingAnimation createTaskLaunchAnimation(TaskView tv, long duration, Interpolator interpolator) {
    if (FeatureFlags.IS_STUDIO_BUILD && mPendingAnimation != null) {
        throw new IllegalStateException("Another pending animation is still running");
    }
    int count = getTaskViewCount();
    if (count == 0) {
        return new PendingAnimation(duration);
    }
    // When swiping down from overview to tasks, ensures the snapped page's scroll maintain
    // invariant between quick switch and overview, to ensure a smooth animation transition.
    updateGridProperties();
    updateScrollSynchronously();
    int targetSysUiFlags = tv.getThumbnail().getSysUiStatusNavFlags();
    final boolean[] passedOverviewThreshold = new boolean[] { false };
    ValueAnimator progressAnim = ValueAnimator.ofFloat(0, 1);
    progressAnim.addUpdateListener(animator -> {
        // tasks' flags
        if (animator.getAnimatedFraction() > UPDATE_SYSUI_FLAGS_THRESHOLD) {
            mActivity.getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, targetSysUiFlags);
        } else {
            mActivity.getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, 0);
        }
        // Passing the threshold from taskview to fullscreen app will vibrate
        final boolean passed = animator.getAnimatedFraction() >= SUCCESS_TRANSITION_PROGRESS;
        if (passed != passedOverviewThreshold[0]) {
            passedOverviewThreshold[0] = passed;
            performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
        }
    });
    AnimatorSet anim = createAdjacentPageAnimForTaskLaunch(tv);
    DepthController depthController = getDepthController();
    if (depthController != null) {
        ObjectAnimator depthAnimator = ObjectAnimator.ofFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(mActivity));
        anim.play(depthAnimator);
    }
    anim.play(progressAnim);
    anim.setInterpolator(interpolator);
    mPendingAnimation = new PendingAnimation(duration);
    mPendingAnimation.add(anim);
    if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
        mLiveTileTaskViewSimulator.addOverviewToAppAnim(mPendingAnimation, interpolator);
        mPendingAnimation.addOnFrameCallback(this::redrawLiveTile);
    }
    mPendingAnimation.addEndListener(isSuccess -> {
        if (isSuccess) {
            if (ENABLE_QUICKSTEP_LIVE_TILE.get() && tv.isRunningTask()) {
                finishRecentsAnimation(false, /* toRecents */
                null);
                onTaskLaunchAnimationEnd(true);
            } else {
                tv.launchTask(this::onTaskLaunchAnimationEnd);
            }
            Task task = tv.getTask();
            if (task != null) {
                mActivity.getStatsLogManager().logger().withItemInfo(tv.getItemInfo()).log(LAUNCHER_TASK_LAUNCH_SWIPE_DOWN);
            }
        } else {
            onTaskLaunchAnimationEnd(false);
        }
        mPendingAnimation = null;
    });
    return mPendingAnimation;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) Task(com.android.systemui.shared.recents.model.Task) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) DepthController(com.android.launcher3.statehandlers.DepthController) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 5 with DepthController

use of com.android.launcher3.statehandlers.DepthController in project android_packages_apps_Launcher3 by crdroidandroid.

the class StaggeredWorkspaceAnim method addDepthAnimationForState.

private void addDepthAnimationForState(Launcher launcher, LauncherState state, long duration) {
    if (!(launcher instanceof BaseQuickstepLauncher)) {
        return;
    }
    PendingAnimation builder = new PendingAnimation(duration);
    DepthController depthController = ((BaseQuickstepLauncher) launcher).getDepthController();
    depthController.setStateWithAnimation(state, new StateAnimationConfig(), builder);
    mAnimators.play(builder.buildAnim());
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) BaseQuickstepLauncher(com.android.launcher3.BaseQuickstepLauncher) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) DepthController(com.android.launcher3.statehandlers.DepthController)

Aggregations

PendingAnimation (com.android.launcher3.anim.PendingAnimation)5 Animator (android.animation.Animator)4 ObjectAnimator (android.animation.ObjectAnimator)4 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 Context (android.content.Context)3 DeviceProfile (com.android.launcher3.DeviceProfile)3 DepthController (com.android.launcher3.statehandlers.DepthController)3 AnimatorSet (android.animation.AnimatorSet)2 ValueAnimator (android.animation.ValueAnimator)2 Rect (android.graphics.Rect)2 SurfaceTransactionApplier (com.android.quickstep.util.SurfaceTransactionApplier)2 TaskViewSimulator (com.android.quickstep.util.TaskViewSimulator)2 TransformParams (com.android.quickstep.util.TransformParams)2 RecentsView (com.android.quickstep.views.RecentsView)2 Matrix (android.graphics.Matrix)1 Point (android.graphics.Point)1 RectF (android.graphics.RectF)1 TextPaint (android.text.TextPaint)1 SurfaceControl (android.view.SurfaceControl)1 ViewRootImpl (android.view.ViewRootImpl)1