Search in sources :

Example 31 with StateAnimationConfig

use of com.android.launcher3.states.StateAnimationConfig in project android_packages_apps_Trebuchet by LineageOS.

the class StaggeredWorkspaceAnim method prepareToAnimate.

/**
 * Setup workspace with 0 duration to prepare for our staggered animation.
 */
private void prepareToAnimate(Launcher launcher, boolean animateOverviewScrim) {
    StateAnimationConfig config = new StateAnimationConfig();
    config.animFlags = ANIM_ALL_COMPONENTS | SKIP_OVERVIEW | SKIP_DEPTH_CONTROLLER;
    config.duration = 0;
    // setRecentsAttachedToAppWindow() will animate recents out.
    launcher.getStateManager().createAtomicAnimation(BACKGROUND_APP, NORMAL, config).start();
    // Stop scrolling so that it doesn't interfere with the translation offscreen.
    launcher.<RecentsView>getOverviewPanel().getScroller().forceFinished(true);
    if (animateOverviewScrim) {
        addScrimAnimationForState(launcher, BACKGROUND_APP, NO_ANIM_PROPERTY_SETTER);
    }
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) RecentsView(com.android.quickstep.views.RecentsView)

Example 32 with StateAnimationConfig

use of com.android.launcher3.states.StateAnimationConfig in project android_packages_apps_Trebuchet by LineageOS.

the class StateManager method createAtomicAnimation.

/**
 * Creates an animation representing atomic transitions between the provided states
 */
public AnimatorSet createAtomicAnimation(STATE_TYPE fromState, STATE_TYPE toState, StateAnimationConfig config) {
    PendingAnimation builder = new PendingAnimation(config.duration);
    prepareForAtomicAnimation(fromState, toState, config);
    for (StateHandler handler : mActivity.getStateManager().getStateHandlers()) {
        handler.setStateWithAnimation(toState, config, builder);
    }
    return builder.buildAnim();
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation)

Example 33 with StateAnimationConfig

use of com.android.launcher3.states.StateAnimationConfig in project android_packages_apps_Trebuchet by LineageOS.

the class QuickstepAtomicAnimationFactory method prepareForAtomicAnimation.

@Override
public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState, StateAnimationConfig config) {
    if (toState == NORMAL && fromState == OVERVIEW) {
        config.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL);
        config.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL);
        config.setInterpolator(ANIM_ALL_APPS_FADE, ACCEL);
        config.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f));
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL_DEACCEL);
        if (SysUINavigationMode.getMode(mActivity) == NO_BUTTON) {
            config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
        } else {
            config.setInterpolator(ANIM_OVERVIEW_FADE, DEACCEL_1_7);
        }
        Workspace workspace = mActivity.getWorkspace();
        // Start from a higher workspace scale, but only if we're invisible so we don't jump.
        boolean isWorkspaceVisible = workspace.getVisibility() == VISIBLE;
        if (isWorkspaceVisible) {
            CellLayout currentChild = (CellLayout) workspace.getChildAt(workspace.getCurrentPage());
            isWorkspaceVisible = currentChild.getVisibility() == VISIBLE && currentChild.getShortcutsAndWidgets().getAlpha() > 0;
        }
        if (!isWorkspaceVisible) {
            workspace.setScaleX(0.92f);
            workspace.setScaleY(0.92f);
        }
        Hotseat hotseat = mActivity.getHotseat();
        boolean isHotseatVisible = hotseat.getVisibility() == VISIBLE && hotseat.getAlpha() > 0;
        if (!isHotseatVisible) {
            hotseat.setScaleX(0.92f);
            hotseat.setScaleY(0.92f);
            if (ENABLE_OVERVIEW_ACTIONS.get()) {
                AllAppsContainerView qsbContainer = mActivity.getAppsView();
                View qsb = qsbContainer.getSearchView();
                boolean qsbVisible = qsb.getVisibility() == VISIBLE && qsb.getAlpha() > 0;
                if (!qsbVisible) {
                    qsbContainer.setScaleX(0.92f);
                    qsbContainer.setScaleY(0.92f);
                }
            }
        }
    } else if (toState == NORMAL && fromState == OVERVIEW_PEEK) {
        // Keep fully visible until the very end (when overview is offscreen) to make invisible.
        config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
    } else if (toState == OVERVIEW_PEEK && fromState == NORMAL) {
        config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_7);
        config.setInterpolator(ANIM_OVERVIEW_SCRIM_FADE, FAST_OUT_SLOW_IN);
    } else if ((fromState == NORMAL || fromState == HINT_STATE) && toState == OVERVIEW) {
        if (SysUINavigationMode.getMode(mActivity) == NO_BUTTON) {
            config.setInterpolator(ANIM_WORKSPACE_SCALE, fromState == NORMAL ? ACCEL : OVERSHOOT_1_2);
            config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL);
            config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
        } else {
            config.setInterpolator(ANIM_WORKSPACE_SCALE, OVERSHOOT_1_2);
            config.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2);
            // Scale up the recents, if it is not coming from the side
            RecentsView overview = mActivity.getOverviewPanel();
            if (overview.getVisibility() != VISIBLE || overview.getContentAlpha() == 0) {
                RECENTS_SCALE_PROPERTY.set(overview, RECENTS_PREPARE_SCALE);
            }
        }
        config.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_ALL_APPS_FADE, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_OVERVIEW_SCALE, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_DEPTH, OVERSHOOT_1_2);
        Interpolator translationInterpolator = ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(mActivity) ? OVERSHOOT_1_2 : OVERSHOOT_1_7;
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, translationInterpolator);
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, translationInterpolator);
    } else if (fromState == HINT_STATE && toState == NORMAL) {
        config.setInterpolator(ANIM_DEPTH, DEACCEL_3);
        if (mHintToNormalDuration == -1) {
            ValueAnimator va = getSpringScaleAnimator(mActivity, mActivity.getWorkspace(), toState.getWorkspaceScaleAndTranslation(mActivity).scale);
            mHintToNormalDuration = (int) va.getDuration();
        }
        config.duration = Math.max(config.duration, mHintToNormalDuration);
    }
}
Also used : AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) Hotseat(com.android.launcher3.Hotseat) CellLayout(com.android.launcher3.CellLayout) RecentsView(com.android.quickstep.views.RecentsView) Interpolator(android.view.animation.Interpolator) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) RecentsView(com.android.quickstep.views.RecentsView) Workspace(com.android.launcher3.Workspace)

Example 34 with StateAnimationConfig

use of com.android.launcher3.states.StateAnimationConfig 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 35 with StateAnimationConfig

use of com.android.launcher3.states.StateAnimationConfig in project android_packages_apps_Trebuchet by LineageOS.

the class NavBarToHomeTouchController method initCurrentAnimation.

private void initCurrentAnimation() {
    long accuracy = (long) (getShiftRange() * 2);
    final PendingAnimation builder = new PendingAnimation(accuracy);
    if (mStartState.overviewUi) {
        RecentsView recentsView = mLauncher.getOverviewPanel();
        AnimatorControllerWithResistance.createRecentsResistanceFromOverviewAnim(mLauncher, builder);
        builder.setFloat(mLauncher.getDragLayer().getOverviewScrim(), OverviewScrim.SCRIM_MULTIPLIER, OVERVIEW_TO_HOME_SCRIM_MULTIPLIER, PULLBACK_INTERPOLATOR);
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            builder.addOnFrameCallback(() -> recentsView.redrawLiveTile(false));
        }
    } else if (mStartState == ALL_APPS) {
        AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
        builder.setFloat(allAppsController, ALL_APPS_PROGRESS, -mPullbackDistance / allAppsController.getShiftRange(), PULLBACK_INTERPOLATOR);
        // Slightly fade out all apps content to further distinguish from scrolling.
        StateAnimationConfig config = new StateAnimationConfig();
        config.duration = accuracy;
        config.setInterpolator(StateAnimationConfig.ANIM_ALL_APPS_FADE, Interpolators.mapToProgress(PULLBACK_INTERPOLATOR, 0, 0.5f));
        allAppsController.setAlphas(mEndState, config, builder);
    }
    AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mLauncher);
    if (topView != null) {
        topView.addHintCloseAnim(mPullbackDistance, PULLBACK_INTERPOLATOR, builder);
    }
    mCurrentAnimation = builder.createPlaybackController().setOnCancelRunnable(this::clearState);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Aggregations

StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)108 PendingAnimation (com.android.launcher3.anim.PendingAnimation)26 LauncherState (com.android.launcher3.LauncherState)25 RecentsView (com.android.quickstep.views.RecentsView)24 Animator (android.animation.Animator)16 ValueAnimator (android.animation.ValueAnimator)13 Interpolator (android.view.animation.Interpolator)12 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)9 AnimatorSet (android.animation.AnimatorSet)8 AllAppsTransitionController (com.android.launcher3.allapps.AllAppsTransitionController)8 AnimationSuccessListener (com.android.launcher3.anim.AnimationSuccessListener)7 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)6 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)6 CellLayout (com.android.launcher3.CellLayout)6 Hotseat (com.android.launcher3.Hotseat)6 Workspace (com.android.launcher3.Workspace)6 DepthController (com.android.launcher3.statehandlers.DepthController)6 VISIBLE (android.view.View.VISIBLE)5 HINT_STATE (com.android.launcher3.LauncherState.HINT_STATE)5 HINT_STATE_TWO_BUTTON (com.android.launcher3.LauncherState.HINT_STATE_TWO_BUTTON)5