Search in sources :

Example 31 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_Trebuchet by LineageOS.

the class FlingAndHoldTouchController method goToOverviewOnDragEnd.

protected void goToOverviewOnDragEnd(float velocity) {
    if (mPeekAnim != null) {
        mPeekAnim.cancel();
    }
    Animator overviewAnim = mLauncher.createAtomicAnimationFactory().createStateElementAnimation(INDEX_PAUSE_TO_OVERVIEW_ANIM);
    mAtomicAnim = new AnimatorSet();
    mAtomicAnim.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            onSwipeInteractionCompleted(OVERVIEW, Touch.SWIPE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (mCancelled) {
                StateAnimationConfig config = new StateAnimationConfig();
                config.animFlags = PLAY_ATOMIC_OVERVIEW_PEEK;
                config.duration = PEEK_OUT_ANIM_DURATION;
                mPeekAnim = mLauncher.getStateManager().createAtomicAnimation(mFromState, mToState, config);
                mPeekAnim.start();
            }
            mAtomicAnim = null;
        }
    });
    mAtomicAnim.play(overviewAnim);
    mAtomicAnim.start();
}
Also used : Animator(android.animation.Animator) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AnimatorSet(android.animation.AnimatorSet) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 32 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_Trebuchet by LineageOS.

the class NoButtonNavbarToOverviewTouchController method goToOverviewOnDragEnd.

@Override
protected void goToOverviewOnDragEnd(float velocity) {
    float velocityDp = dpiFromPx(velocity);
    boolean isFling = Math.abs(velocityDp) > 1;
    StateManager<LauncherState> stateManager = mLauncher.getStateManager();
    boolean goToHomeInsteadOfOverview = isFling;
    if (goToHomeInsteadOfOverview) {
        new OverviewToHomeAnim(mLauncher, () -> onSwipeInteractionCompleted(NORMAL, Touch.FLING)).animateWithVelocity(velocity);
    }
    if (mReachedOverview) {
        float distanceDp = dpiFromPx(Math.max(Math.abs(mRecentsView.getTranslationX()), Math.abs(mRecentsView.getTranslationY())));
        long duration = (long) Math.max(TRANSLATION_ANIM_MIN_DURATION_MS, distanceDp / TRANSLATION_ANIM_VELOCITY_DP_PER_MS);
        mRecentsView.animate().translationX(0).translationY(0).setInterpolator(ACCEL_DEACCEL).setDuration(duration).withEndAction(goToHomeInsteadOfOverview ? null : this::maybeSwipeInteractionToOverviewComplete);
        if (!goToHomeInsteadOfOverview) {
            // Return to normal properties for the overview state.
            StateAnimationConfig config = new StateAnimationConfig();
            config.duration = duration;
            LauncherState state = mLauncher.getStateManager().getState();
            mLauncher.getStateManager().createAtomicAnimation(state, state, config).start();
        }
    }
}
Also used : LauncherState(com.android.launcher3.LauncherState) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) OverviewToHomeAnim(com.android.quickstep.util.OverviewToHomeAnim)

Example 33 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_Trebuchet by LineageOS.

the class NoButtonQuickSwitchTouchController method setupOverviewAnimators.

private void setupOverviewAnimators() {
    final LauncherState fromState = QUICK_SWITCH;
    final LauncherState toState = OVERVIEW;
    // Set RecentView's initial properties.
    RECENTS_SCALE_PROPERTY.set(mRecentsView, fromState.getOverviewScaleAndOffset(mLauncher)[0]);
    ADJACENT_PAGE_OFFSET.set(mRecentsView, 1f);
    mRecentsView.setContentAlpha(1);
    mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress());
    mLauncher.getActionsView().getVisibilityAlpha().setValue((fromState.getVisibleElements(mLauncher) & OVERVIEW_BUTTONS) != 0 ? 1f : 0f);
    float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher);
    // As we drag right, animate the following properties:
    // - RecentsView translationX
    // - OverviewScrim
    PendingAnimation xAnim = new PendingAnimation((long) (mXRange * 2));
    xAnim.setFloat(mRecentsView, ADJACENT_PAGE_OFFSET, scaleAndOffset[1], LINEAR);
    xAnim.setFloat(mLauncher.getDragLayer().getOverviewScrim(), OverviewScrim.SCRIM_PROGRESS, toState.getOverviewScrimAlpha(mLauncher), LINEAR);
    mXOverviewAnim = xAnim.createPlaybackController();
    mXOverviewAnim.dispatchOnStart();
    // As we drag up, animate the following properties:
    // - RecentsView scale
    // - RecentsView fullscreenProgress
    PendingAnimation yAnim = new PendingAnimation((long) (mYRange * 2));
    yAnim.setFloat(mRecentsView, RECENTS_SCALE_PROPERTY, scaleAndOffset[0], SCALE_DOWN_INTERPOLATOR);
    yAnim.setFloat(mRecentsView, FULLSCREEN_PROGRESS, toState.getOverviewFullscreenProgress(), SCALE_DOWN_INTERPOLATOR);
    AnimatorPlaybackController yNormalController = yAnim.createPlaybackController();
    AnimatorControllerWithResistance yAnimWithResistance = AnimatorControllerWithResistance.createForRecents(yNormalController, mLauncher, mRecentsView.getPagedViewOrientedState(), mLauncher.getDeviceProfile(), mRecentsView, RECENTS_SCALE_PROPERTY, mRecentsView, TASK_SECONDARY_TRANSLATION);
    mYOverviewAnim = new AnimatedFloat(() -> {
        if (mYOverviewAnim != null) {
            yAnimWithResistance.setProgress(mYOverviewAnim.value, mMaxYProgress);
        }
    });
    yNormalController.dispatchOnStart();
}
Also used : AnimatedFloat(com.android.quickstep.AnimatedFloat) LauncherState(com.android.launcher3.LauncherState) PendingAnimation(com.android.launcher3.anim.PendingAnimation) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) AnimatorControllerWithResistance(com.android.quickstep.util.AnimatorControllerWithResistance)

Example 34 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_Trebuchet by LineageOS.

the class NoButtonQuickSwitchTouchController method onDragEnd.

@Override
public void onDragEnd(PointF velocity) {
    boolean horizontalFling = mSwipeDetector.isFling(velocity.x);
    boolean verticalFling = mSwipeDetector.isFling(velocity.y);
    boolean noFling = !horizontalFling && !verticalFling;
    int logAction = noFling ? Touch.SWIPE : Touch.FLING;
    if (mMotionPauseDetector.isPaused() && noFling) {
        cancelAnimations();
        Animator overviewAnim = mLauncher.createAtomicAnimationFactory().createStateElementAnimation(INDEX_PAUSE_TO_OVERVIEW_ANIM);
        overviewAnim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                onAnimationToStateCompleted(OVERVIEW, logAction);
            }
        });
        overviewAnim.start();
        return;
    }
    final LauncherState targetState;
    if (horizontalFling && verticalFling) {
        if (velocity.x < 0) {
            // Flinging left and up or down both go back home.
            targetState = NORMAL;
        } else {
            if (velocity.y > 0) {
                // Flinging right and down goes to quick switch.
                targetState = QUICK_SWITCH;
            } else {
                // Flinging up and right could go either home or to quick switch.
                // Determine the target based on the higher velocity.
                targetState = Math.abs(velocity.x) > Math.abs(velocity.y) ? QUICK_SWITCH : NORMAL;
            }
        }
    } else if (horizontalFling) {
        targetState = velocity.x > 0 ? QUICK_SWITCH : NORMAL;
    } else if (verticalFling) {
        targetState = velocity.y > 0 ? QUICK_SWITCH : NORMAL;
    } else {
        // If user isn't flinging, just snap to the closest state.
        boolean passedHorizontalThreshold = mXOverviewAnim.getInterpolatedProgress() > 0.5f;
        boolean passedVerticalThreshold = mYOverviewAnim.value > 1f;
        targetState = passedHorizontalThreshold && !passedVerticalThreshold ? QUICK_SWITCH : NORMAL;
    }
    // Animate the various components to the target state.
    float xProgress = mXOverviewAnim.getProgressFraction();
    float startXProgress = Utilities.boundToRange(xProgress + velocity.x * getSingleFrameMs(mLauncher) / mXRange, 0f, 1f);
    final float endXProgress = targetState == NORMAL ? 0 : 1;
    long xDuration = BaseSwipeDetector.calculateDuration(velocity.x, Math.abs(endXProgress - startXProgress));
    ValueAnimator xOverviewAnim = mXOverviewAnim.getAnimationPlayer();
    xOverviewAnim.setFloatValues(startXProgress, endXProgress);
    xOverviewAnim.setDuration(xDuration).setInterpolator(scrollInterpolatorForVelocity(velocity.x));
    mXOverviewAnim.dispatchOnStart();
    boolean flingUpToNormal = verticalFling && velocity.y < 0 && targetState == NORMAL;
    float yProgress = mYOverviewAnim.value;
    float startYProgress = Utilities.boundToRange(yProgress - velocity.y * getSingleFrameMs(mLauncher) / mYRange, 0f, mMaxYProgress);
    final float endYProgress;
    if (flingUpToNormal) {
        endYProgress = 1;
    } else if (targetState == NORMAL) {
        // Keep overview at its current scale/translationY as it slides off the screen.
        endYProgress = startYProgress;
    } else {
        endYProgress = 0;
    }
    float yDistanceToCover = Math.abs(endYProgress - startYProgress) * mYRange;
    long yDuration = (long) (yDistanceToCover / Math.max(1f, Math.abs(velocity.y)));
    ValueAnimator yOverviewAnim = mYOverviewAnim.animateToValue(startYProgress, endYProgress);
    yOverviewAnim.setDuration(yDuration);
    mYOverviewAnim.updateValue(startYProgress);
    ValueAnimator nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();
    if (flingUpToNormal && !mIsHomeScreenVisible) {
        // We are flinging to home while workspace is invisible, run the same staggered
        // animation as from an app.
        StateAnimationConfig config = new StateAnimationConfig();
        // Update mNonOverviewAnim to do nothing so it doesn't interfere.
        config.animFlags = 0;
        updateNonOverviewAnim(targetState, config);
        nonOverviewAnim = mNonOverviewAnim.getAnimationPlayer();
        new StaggeredWorkspaceAnim(mLauncher, velocity.y, false).start();
    } else {
        boolean canceled = targetState == NORMAL;
        if (canceled) {
            // Let the state manager know that the animation didn't go to the target state,
            // but don't clean up yet (we already clean up when the animation completes).
            mNonOverviewAnim.dispatchOnCancelWithoutCancelRunnable();
        }
        float startProgress = mNonOverviewAnim.getProgressFraction();
        float endProgress = canceled ? 0 : 1;
        nonOverviewAnim.setFloatValues(startProgress, endProgress);
        mNonOverviewAnim.dispatchOnStart();
    }
    nonOverviewAnim.setDuration(Math.max(xDuration, yDuration));
    mNonOverviewAnim.setEndAction(() -> onAnimationToStateCompleted(targetState, logAction));
    cancelAnimations();
    xOverviewAnim.start();
    yOverviewAnim.start();
    nonOverviewAnim.start();
}
Also used : LauncherState(com.android.launcher3.LauncherState) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) StaggeredWorkspaceAnim(com.android.quickstep.util.StaggeredWorkspaceAnim) ValueAnimator(android.animation.ValueAnimator)

Example 35 with Overview

use of com.android.launcher3.tapl.Overview in project android_packages_apps_Trebuchet by LineageOS.

the class PredictionRowView method fillInLogContainerData.

@Override
public void fillInLogContainerData(ItemInfo childInfo, LauncherLogProto.Target child, ArrayList<LauncherLogProto.Target> parents) {
    for (int i = 0; i < mPredictedApps.size(); i++) {
        ItemInfoWithIcon appInfo = mPredictedApps.get(i);
        if (appInfo == childInfo) {
            child.predictedRank = i;
            break;
        }
    }
    parents.add(newContainerTarget(LauncherLogProto.ContainerType.PREDICTION));
    // include where the prediction is coming this used to be Launcher#modifyUserEvent
    LauncherLogProto.Target parent = newTarget(LauncherLogProto.Target.Type.CONTAINER);
    LauncherState state = mLauncher.getStateManager().getState();
    if (state == LauncherState.ALL_APPS) {
        parent.containerType = LauncherLogProto.ContainerType.ALLAPPS;
    } else if (state == OVERVIEW) {
        parent.containerType = LauncherLogProto.ContainerType.TASKSWITCHER;
    }
    parents.add(parent);
}
Also used : LauncherState(com.android.launcher3.LauncherState) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Aggregations

LauncherState (com.android.launcher3.LauncherState)53 Animator (android.animation.Animator)50 ValueAnimator (android.animation.ValueAnimator)42 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)41 RecentsView (com.android.quickstep.views.RecentsView)40 AnimatorSet (android.animation.AnimatorSet)38 Launcher (com.android.launcher3.Launcher)36 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)34 ObjectAnimator (android.animation.ObjectAnimator)30 LargeTest (androidx.test.filters.LargeTest)29 Test (org.junit.Test)29 Point (android.graphics.Point)24 View (android.view.View)22 DeviceProfile (com.android.launcher3.DeviceProfile)19 PendingAnimation (com.android.launcher3.anim.PendingAnimation)19 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)19 ItemInfo (com.android.launcher3.model.data.ItemInfo)18 DepthController (com.android.launcher3.statehandlers.DepthController)17 Task (com.android.systemui.shared.recents.model.Task)17 Rect (android.graphics.Rect)16