Search in sources :

Example 61 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project android_packages_apps_Launcher3 by ArrowOS.

the class SwipeUpGestureTutorialController method fadeOutFakeTaskView.

/**
 * Fades the task view, optionally after animating to a fake Overview.
 */
void fadeOutFakeTaskView(boolean toOverviewFirst, boolean reset, @Nullable Runnable onEndRunnable) {
    cancelRunningAnimation();
    PendingAnimation anim = new PendingAnimation(300);
    if (toOverviewFirst) {
        anim.setFloat(mTaskViewSwipeUpAnimation.getCurrentShift(), AnimatedFloat.VALUE, 1, ACCEL);
        anim.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation, boolean isReverse) {
                PendingAnimation fadeAnim = new PendingAnimation(TASK_VIEW_END_ANIMATION_DURATION_MILLIS);
                if (reset) {
                    fadeAnim.setFloat(mTaskViewSwipeUpAnimation.getCurrentShift(), AnimatedFloat.VALUE, 0, ACCEL);
                    fadeAnim.addListener(mResetTaskView);
                } else {
                    fadeAnim.setViewAlpha(mFakeTaskView, 0, ACCEL);
                    fadeAnim.setViewAlpha(mFakePreviousTaskView, 0, ACCEL);
                }
                if (onEndRunnable != null) {
                    fadeAnim.addListener(AnimatorListeners.forSuccessCallback(onEndRunnable));
                }
                AnimatorSet animset = fadeAnim.buildAnim();
                if (reset && mTutorialFragment.isLargeScreen()) {
                    animset.addListener(new AnimatorListenerAdapter() {

                        @Override
                        public void onAnimationStart(Animator animation) {
                            super.onAnimationStart(animation);
                            Animator multiRowAnimation = mFakePreviousTaskView.createAnimationToMultiRowLayout();
                            if (multiRowAnimation != null) {
                                multiRowAnimation.setDuration(TASK_VIEW_END_ANIMATION_DURATION_MILLIS).start();
                            }
                        }
                    });
                }
                animset.setStartDelay(100);
                animset.start();
                mRunningWindowAnim = RunningWindowAnim.wrap(animset);
            }
        });
    } else {
        if (reset) {
            anim.setFloat(mTaskViewSwipeUpAnimation.getCurrentShift(), AnimatedFloat.VALUE, 0, ACCEL);
            anim.addListener(mResetTaskView);
        } else {
            anim.setViewAlpha(mFakeTaskView, 0, ACCEL);
            anim.setViewAlpha(mFakePreviousTaskView, 0, ACCEL);
        }
        if (onEndRunnable != null) {
            anim.addListener(AnimatorListeners.forSuccessCallback(onEndRunnable));
        }
    }
    AnimatorSet animset = anim.buildAnim();
    hideFakeTaskbar(/* animateToHotseat= */
    false);
    animset.start();
    mRunningWindowAnim = RunningWindowAnim.wrap(animset);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet)

Example 62 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project android_packages_apps_Launcher3 by ArrowOS.

the class OverviewToHomeAnim method animateWithVelocity.

/**
 * Starts the animation. If velocity < 0 (i.e. upwards), also plays a
 * {@link WorkspaceRevealAnim}.
 */
public void animateWithVelocity(float velocity) {
    StateManager<LauncherState> stateManager = mLauncher.getStateManager();
    LauncherState startState = stateManager.getState();
    if (startState != OVERVIEW) {
        Log.e(TAG, "animateFromOverviewToHome: unexpected start state " + startState);
    }
    AnimatorSet anim = new AnimatorSet();
    boolean playWorkspaceRevealAnim = velocity < 0;
    if (playWorkspaceRevealAnim) {
        WorkspaceRevealAnim workspaceRevealAnim = new WorkspaceRevealAnim(mLauncher, false);
        workspaceRevealAnim.addAnimatorListener(new AnimationSuccessListener() {

            @Override
            public void onAnimationSuccess(Animator animator) {
                mIsHomeStaggeredAnimFinished = true;
                maybeOverviewToHomeAnimComplete();
            }
        });
        anim.play(workspaceRevealAnim.getAnimators());
    } else {
        mIsHomeStaggeredAnimFinished = true;
    }
    StateAnimationConfig config = new StateAnimationConfig();
    if (playWorkspaceRevealAnim) {
        // WorkspaceRevealAnim handles the depth, so don't interfere.
        config.animFlags |= StateAnimationConfig.SKIP_DEPTH_CONTROLLER;
    }
    config.duration = startState.getTransitionDuration(mLauncher);
    AnimatorSet stateAnim = stateManager.createAtomicAnimation(startState, NORMAL, config);
    stateAnim.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            mIsOverviewHidden = true;
            maybeOverviewToHomeAnimComplete();
        }
    });
    anim.play(stateAnim);
    stateManager.setCurrentAnimation(anim, NORMAL);
    anim.start();
}
Also used : LauncherState(com.android.launcher3.LauncherState) Animator(android.animation.Animator) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AnimatorSet(android.animation.AnimatorSet) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 63 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project android_packages_apps_Launcher3 by ArrowOS.

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);
    } else if (fromState == ALL_APPS && toState == NORMAL) {
        config.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(DEACCEL, 1 - ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD, 1 - ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD));
        config.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(DEACCEL, 1 - ALL_APPS_SCRIM_OPAQUE_THRESHOLD, 1 - ALL_APPS_SCRIM_VISIBLE_THRESHOLD));
    }
}
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) ALL_APPS_SCRIM_VISIBLE_THRESHOLD(com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_SCRIM_VISIBLE_THRESHOLD) ANIM_OVERVIEW_SCALE(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE) Interpolators(com.android.launcher3.anim.Interpolators) VISIBLE(android.view.View.VISIBLE) SysUINavigationMode(com.android.quickstep.SysUINavigationMode) ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD(com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD) 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) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) 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) ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD(com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD) Workspace(com.android.launcher3.Workspace) ANIM_SCRIM_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE) HINT_STATE(com.android.launcher3.LauncherState.HINT_STATE) ALL_APPS_SCRIM_OPAQUE_THRESHOLD(com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.ALL_APPS_SCRIM_OPAQUE_THRESHOLD) 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)

Example 64 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project android_packages_apps_Launcher3 by ArrowOS.

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_HORIZONTAL_OFFSET.set(mRecentsView, 1f);
    mRecentsView.setContentAlpha(1);
    mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress());
    mLauncher.getActionsView().getVisibilityAlpha().setValue((fromState.getVisibleElements(mLauncher) & OVERVIEW_ACTIONS) != 0 ? 1f : 0f);
    float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher);
    // As we drag right, animate the following properties:
    // - RecentsView translationX
    // - OverviewScrim
    // - RecentsView fade (if it's empty)
    PendingAnimation xAnim = new PendingAnimation((long) (mXRange * 2));
    xAnim.setFloat(mRecentsView, ADJACENT_PAGE_HORIZONTAL_OFFSET, scaleAndOffset[1], LINEAR);
    // Use QuickSwitchState instead of OverviewState to determine scrim color,
    // since we need to take potential taskbar into account.
    xAnim.setViewBackgroundColor(mLauncher.getScrimView(), QUICK_SWITCH.getWorkspaceScrimColor(mLauncher), LINEAR);
    if (mRecentsView.getTaskViewCount() == 0) {
        xAnim.addFloat(mRecentsView, CONTENT_ALPHA, 0f, 1f, 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 65 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project android_packages_apps_Launcher3 by ArrowOS.

the class NoButtonQuickSwitchTouchController method setupAnimators.

private void setupAnimators() {
    // Animate the non-overview components (e.g. workspace, shelf) out of the way.
    StateAnimationConfig nonOverviewBuilder = new StateAnimationConfig();
    nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_FADE, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_ALL_APPS_FADE, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_SCALE, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_DEPTH, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, TRANSLATE_OUT_INTERPOLATOR);
    updateNonOverviewAnim(QUICK_SWITCH, nonOverviewBuilder);
    mNonOverviewAnim.dispatchOnStart();
    if (mRecentsView.getTaskViewCount() == 0) {
        mRecentsView.setOnEmptyMessageUpdatedListener(isEmpty -> {
            if (!isEmpty && mSwipeDetector.isDraggingState()) {
                // We have loaded tasks, update the animators to start at the correct scale etc.
                setupOverviewAnimators();
            }
        });
    }
    setupOverviewAnimators();
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig)

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