Search in sources :

Example 1 with OverviewToHomeAnim

use of com.android.quickstep.util.OverviewToHomeAnim in project android_packages_apps_Launcher3 by crdroidandroid.

the class NavBarToHomeTouchController method onDragEnd.

@Override
public void onDragEnd(float velocity) {
    boolean fling = mSwipeDetector.isFling(velocity);
    float progress = mCurrentAnimation.getProgressFraction();
    float interpolatedProgress = PULLBACK_INTERPOLATOR.getInterpolation(progress);
    boolean success = interpolatedProgress >= SUCCESS_TRANSITION_PROGRESS || (velocity < 0 && fling);
    if (success) {
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            RecentsView recentsView = mLauncher.getOverviewPanel();
            recentsView.switchToScreenshot(null, () -> recentsView.finishRecentsAnimation(true, /* toRecents */
            null));
        }
        if (mStartState.overviewUi) {
            new OverviewToHomeAnim(mLauncher, () -> onSwipeInteractionCompleted(mEndState)).animateWithVelocity(velocity);
        } else {
            mLauncher.getStateManager().goToState(mEndState, true, forSuccessCallback(() -> onSwipeInteractionCompleted(mEndState)));
        }
        if (mStartState != mEndState) {
            logHomeGesture();
        }
        AbstractFloatingView topOpenView = AbstractFloatingView.getTopOpenView(mLauncher);
        if (topOpenView != null) {
            AbstractFloatingView.closeAllOpenViews(mLauncher);
        // TODO: add to WW log
        }
        TaskUtils.closeSystemWindowsAsync(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS);
    } else {
        // Quickly return to the state we came from (we didn't move far).
        ValueAnimator anim = mCurrentAnimation.getAnimationPlayer();
        anim.setFloatValues(progress, 0);
        anim.addListener(forSuccessCallback(() -> onSwipeInteractionCompleted(mStartState)));
        anim.setDuration(80).start();
    }
}
Also used : RecentsView(com.android.quickstep.views.RecentsView) OverviewToHomeAnim(com.android.quickstep.util.OverviewToHomeAnim) ValueAnimator(android.animation.ValueAnimator) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 2 with OverviewToHomeAnim

use of com.android.quickstep.util.OverviewToHomeAnim in project android_packages_apps_Launcher3 by crdroidandroid.

the class NoButtonNavbarToOverviewTouchController method goToOverviewOrHomeOnDragEnd.

private void goToOverviewOrHomeOnDragEnd(float velocity) {
    boolean goToHomeInsteadOfOverview = !mMotionPauseDetector.isPaused();
    if (goToHomeInsteadOfOverview) {
        new OverviewToHomeAnim(mLauncher, () -> onSwipeInteractionCompleted(NORMAL)).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)

Aggregations

OverviewToHomeAnim (com.android.quickstep.util.OverviewToHomeAnim)2 ValueAnimator (android.animation.ValueAnimator)1 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)1 LauncherState (com.android.launcher3.LauncherState)1 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)1 RecentsView (com.android.quickstep.views.RecentsView)1