Search in sources :

Example 1 with DEACCEL

use of com.android.launcher3.anim.Interpolators.DEACCEL in project android_packages_apps_Launcher3 by crdroidandroid.

the class AbsSwipeUpHandler method handleNormalGestureEnd.

@UiThread
private void handleNormalGestureEnd(float endVelocity, boolean isFling, PointF velocity, boolean isCancel) {
    long duration = MAX_SWIPE_DURATION;
    float currentShift = mCurrentShift.value;
    final GestureEndTarget endTarget = calculateEndTarget(velocity, endVelocity, isFling, isCancel);
    // Set the state, but don't notify until the animation completes
    mGestureState.setEndTarget(endTarget, false);
    float endShift = endTarget.isLauncher ? 1 : 0;
    final float startShift;
    if (!isFling) {
        long expectedDuration = Math.abs(Math.round((endShift - currentShift) * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
        duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
        startShift = currentShift;
    } else {
        startShift = Utilities.boundToRange(currentShift - velocity.y * getSingleFrameMs(mContext) / mTransitionDragLength, 0, mDragLengthFactor);
        if (mTransitionDragLength > 0) {
            float distanceToTravel = (endShift - currentShift) * mTransitionDragLength;
            // we want the page's snap velocity to approximately match the velocity at
            // which the user flings, so we scale the duration by a value near to the
            // derivative of the scroll interpolator at zero, ie. 2.
            long baseDuration = Math.round(Math.abs(distanceToTravel / velocity.y));
            duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration);
        }
    }
    Interpolator interpolator;
    S state = mActivityInterface.stateFromGestureEndTarget(endTarget);
    if (state.displayOverviewTasksAsGrid(mDp)) {
        interpolator = ACCEL_DEACCEL;
    } else if (endTarget == RECENTS) {
        interpolator = OVERSHOOT_1_2;
    } else {
        interpolator = DEACCEL;
    }
    if (endTarget.isLauncher) {
        mInputConsumerProxy.enable();
    }
    if (endTarget == HOME) {
        duration = HOME_DURATION;
        // Early detach the nav bar once the endTarget is determined as HOME
        if (mRecentsAnimationController != null) {
            mRecentsAnimationController.detachNavigationBarFromApp(true);
        }
    } else if (endTarget == RECENTS) {
        if (mRecentsView != null) {
            int nearestPage = mRecentsView.getDestinationPage();
            boolean isScrolling = false;
            // Update page scroll before snapping to page to make sure we snapped to the
            // position calculated with target gesture in mind.
            mRecentsView.updateScrollSynchronously();
            if (mRecentsView.getNextPage() != nearestPage) {
                // We shouldn't really scroll to the next page when swiping up to recents.
                // Only allow settling on the next page if it's nearest to the center.
                mRecentsView.snapToPage(nearestPage, Math.toIntExact(duration));
                isScrolling = true;
            }
            if (mRecentsView.getScroller().getDuration() > MAX_SWIPE_DURATION) {
                mRecentsView.snapToPage(mRecentsView.getNextPage(), (int) MAX_SWIPE_DURATION);
                isScrolling = true;
            }
            if (!mGestureState.isHandlingAtomicEvent() || isScrolling) {
                duration = Math.max(duration, mRecentsView.getScroller().getDuration());
            }
        }
    }
    // or resumeLastTask().
    if (mRecentsView != null) {
        mRecentsView.setOnPageTransitionEndCallback(() -> mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED));
    } else {
        mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
    }
    animateToProgress(startShift, endShift, duration, interpolator, endTarget, velocity);
}
Also used : DEBUG_STATES(com.android.quickstep.MultiStateCallback.DEBUG_STATES) RECENTS(com.android.quickstep.GestureState.GestureEndTarget.RECENTS) CLOSE_SYSTEM_WINDOWS_REASON_RECENTS(com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS) STATE_HANDLER_INVISIBILITY_FLAGS(com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS) Interpolator(android.view.animation.Interpolator) GestureEndTarget(com.android.quickstep.GestureState.GestureEndTarget) UiThread(androidx.annotation.UiThread)

Example 2 with DEACCEL

use of com.android.launcher3.anim.Interpolators.DEACCEL in project android_packages_apps_Launcher3 by crdroidandroid.

the class PortraitStatesTouchController method getAllAppsToNormalAnimation.

private StateAnimationConfig getAllAppsToNormalAnimation() {
    StateAnimationConfig builder = new StateAnimationConfig();
    builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(DEACCEL, 1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD, 1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
    builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(DEACCEL, 1 - ALL_APPS_SCRIM_OPAQUE_THRESHOLD, 1 - ALL_APPS_SCRIM_VISIBLE_THRESHOLD));
    return builder;
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig)

Example 3 with DEACCEL

use of com.android.launcher3.anim.Interpolators.DEACCEL in project android_packages_apps_Launcher3 by crdroidandroid.

the class QuickstepAtomicAnimationFactory method prepareForAtomicAnimation.

@Override
public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState, StateAnimationConfig config) {
    RecentsView overview = mActivity.getOverviewPanel();
    if (toState == NORMAL && fromState == OVERVIEW) {
        config.setInterpolator(ANIM_OVERVIEW_ACTIONS_FADE, clampToProgress(LINEAR, 0, 0.25f));
        config.setInterpolator(ANIM_SCRIM_FADE, LINEAR);
        config.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL);
        config.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL);
        if (SysUINavigationMode.getMode(mActivity).hasGestures && overview.getTaskViewCount() > 0) {
            // Overview is going offscreen, so keep it at its current scale and opacity.
            config.setInterpolator(ANIM_OVERVIEW_SCALE, FINAL_FRAME);
            config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
            config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, clampToProgress(FAST_OUT_SLOW_IN, 0, 0.75f));
            config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, FINAL_FRAME);
        } else {
            config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL_DEACCEL);
            config.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f));
            config.setInterpolator(ANIM_OVERVIEW_FADE, DEACCEL_1_7);
        }
        // Scroll RecentsView to page 0 as it goes offscreen, if necessary.
        int numPagesToScroll = overview.getNextPage() - DEFAULT_PAGE;
        long scrollDuration = Math.min(MAX_PAGE_SCROLL_DURATION, numPagesToScroll * PER_PAGE_SCROLL_DURATION);
        config.duration = Math.max(config.duration, scrollDuration);
        overview.snapToPage(DEFAULT_PAGE, Math.toIntExact(config.duration));
        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(WORKSPACE_PREPARE_SCALE);
            workspace.setScaleY(WORKSPACE_PREPARE_SCALE);
        }
        Hotseat hotseat = mActivity.getHotseat();
        boolean isHotseatVisible = hotseat.getVisibility() == VISIBLE && hotseat.getAlpha() > 0;
        if (!isHotseatVisible) {
            hotseat.setScaleX(WORKSPACE_PREPARE_SCALE);
            hotseat.setScaleY(WORKSPACE_PREPARE_SCALE);
        }
    } else if ((fromState == NORMAL || fromState == HINT_STATE || fromState == HINT_STATE_TWO_BUTTON) && toState == OVERVIEW) {
        if (SysUINavigationMode.getMode(mActivity).hasGestures) {
            config.setInterpolator(ANIM_WORKSPACE_SCALE, fromState == NORMAL ? ACCEL : OVERSHOOT_1_2);
            config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL);
            // Scrolling in tasks, so show straight away
            if (overview.getTaskViewCount() > 0) {
                config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
            } else {
                config.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2);
            }
        } 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
            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);
        config.setInterpolator(ANIM_SCRIM_FADE, t -> {
            // Animate at the same rate until reaching progress 1, and skip the overshoot.
            return Math.min(1, OVERSHOOT_1_2.getInterpolation(t));
        });
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_2);
        config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, OVERSHOOT_1_2);
    } 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 : ANIM_OVERVIEW_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE) ANIM_WORKSPACE_TRANSLATE(com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE) Interpolators.clampToProgress(com.android.launcher3.anim.Interpolators.clampToProgress) DEACCEL(com.android.launcher3.anim.Interpolators.DEACCEL) ANIM_OVERVIEW_TRANSLATE_X(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X) OVERVIEW(com.android.launcher3.LauncherState.OVERVIEW) INSTANT(com.android.launcher3.anim.Interpolators.INSTANT) OVERSHOOT_1_2(com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2) ANIM_OVERVIEW_TRANSLATE_Y(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y) DEACCEL_1_7(com.android.launcher3.anim.Interpolators.DEACCEL_1_7) FAST_OUT_SLOW_IN(com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN) ANIM_OVERVIEW_SCALE(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE) VISIBLE(android.view.View.VISIBLE) SysUINavigationMode(com.android.quickstep.SysUINavigationMode) QuickstepLauncher(com.android.launcher3.uioverrides.QuickstepLauncher) ANIM_WORKSPACE_SCALE(com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE) ANIM_OVERVIEW_ACTIONS_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_ACTIONS_FADE) DEACCEL_3(com.android.launcher3.anim.Interpolators.DEACCEL_3) RecentsAtomicAnimationFactory(com.android.quickstep.util.RecentsAtomicAnimationFactory) CellLayout(com.android.launcher3.CellLayout) LauncherState(com.android.launcher3.LauncherState) WorkspaceStateTransitionAnimation.getSpringScaleAnimator(com.android.launcher3.WorkspaceStateTransitionAnimation.getSpringScaleAnimator) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) Hotseat(com.android.launcher3.Hotseat) ANIM_DEPTH(com.android.launcher3.states.StateAnimationConfig.ANIM_DEPTH) RECENTS_SCALE_PROPERTY(com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY) FINAL_FRAME(com.android.launcher3.anim.Interpolators.FINAL_FRAME) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) ANIM_WORKSPACE_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE) ANIM_ALL_APPS_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE) RecentsView(com.android.quickstep.views.RecentsView) Workspace(com.android.launcher3.Workspace) ANIM_SCRIM_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE) HINT_STATE(com.android.launcher3.LauncherState.HINT_STATE) NORMAL(com.android.launcher3.LauncherState.NORMAL) HINT_STATE_TWO_BUTTON(com.android.launcher3.LauncherState.HINT_STATE_TWO_BUTTON) ACCEL(com.android.launcher3.anim.Interpolators.ACCEL) ACCEL_DEACCEL(com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL) ValueAnimator(android.animation.ValueAnimator) Hotseat(com.android.launcher3.Hotseat) CellLayout(com.android.launcher3.CellLayout) RecentsView(com.android.quickstep.views.RecentsView) ValueAnimator(android.animation.ValueAnimator) Workspace(com.android.launcher3.Workspace)

Aggregations

StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)2 ValueAnimator (android.animation.ValueAnimator)1 VISIBLE (android.view.View.VISIBLE)1 Interpolator (android.view.animation.Interpolator)1 UiThread (androidx.annotation.UiThread)1 STATE_HANDLER_INVISIBILITY_FLAGS (com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS)1 CellLayout (com.android.launcher3.CellLayout)1 Hotseat (com.android.launcher3.Hotseat)1 LauncherState (com.android.launcher3.LauncherState)1 HINT_STATE (com.android.launcher3.LauncherState.HINT_STATE)1 HINT_STATE_TWO_BUTTON (com.android.launcher3.LauncherState.HINT_STATE_TWO_BUTTON)1 NORMAL (com.android.launcher3.LauncherState.NORMAL)1 OVERVIEW (com.android.launcher3.LauncherState.OVERVIEW)1 Workspace (com.android.launcher3.Workspace)1 WorkspaceStateTransitionAnimation.getSpringScaleAnimator (com.android.launcher3.WorkspaceStateTransitionAnimation.getSpringScaleAnimator)1 ACCEL (com.android.launcher3.anim.Interpolators.ACCEL)1 ACCEL_DEACCEL (com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL)1 DEACCEL (com.android.launcher3.anim.Interpolators.DEACCEL)1 DEACCEL_1_7 (com.android.launcher3.anim.Interpolators.DEACCEL_1_7)1 DEACCEL_3 (com.android.launcher3.anim.Interpolators.DEACCEL_3)1