Search in sources :

Example 46 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.

the class NavBarToHomeTouchController method initCurrentAnimation.

private void initCurrentAnimation() {
    long accuracy = (long) (getShiftRange() * 2);
    final AnimatorSet anim = new AnimatorSet();
    if (mStartState == OVERVIEW) {
        RecentsView recentsView = mLauncher.getOverviewPanel();
        float pullbackDist = mPullbackDistance;
        if (!recentsView.isRtl()) {
            pullbackDist = -pullbackDist;
        }
        Animator pullback = ObjectAnimator.ofFloat(recentsView, TRANSLATION_X, pullbackDist);
        pullback.setInterpolator(PULLBACK_INTERPOLATOR);
        anim.play(pullback);
    } else if (mStartState == ALL_APPS) {
        AnimatorSetBuilder builder = new AnimatorSetBuilder();
        AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
        Animator allAppsProgress = ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, -mPullbackDistance / allAppsController.getShiftRange());
        allAppsProgress.setInterpolator(PULLBACK_INTERPOLATOR);
        builder.play(allAppsProgress);
        // Slightly fade out all apps content to further distinguish from scrolling.
        builder.setInterpolator(AnimatorSetBuilder.ANIM_ALL_APPS_FADE, Interpolators.mapToProgress(PULLBACK_INTERPOLATOR, 0, 0.5f));
        AnimationConfig config = new AnimationConfig();
        config.duration = accuracy;
        allAppsController.setAlphas(mEndState.getVisibleElements(mLauncher), config, builder);
        anim.play(builder.build());
    }
    AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mLauncher);
    if (topView != null) {
        Animator hintCloseAnim = topView.createHintCloseAnim(mPullbackDistance);
        if (hintCloseAnim != null) {
            hintCloseAnim.setInterpolator(PULLBACK_INTERPOLATOR);
            anim.play(hintCloseAnim);
        }
    }
    anim.setDuration(accuracy);
    mCurrentAnimation = AnimatorPlaybackController.wrap(anim, accuracy, this::clearState);
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) RecentsView(com.android.quickstep.views.RecentsView) AnimatorSet(android.animation.AnimatorSet) AnimationConfig(com.android.launcher3.LauncherStateManager.AnimationConfig) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 47 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.

the class NoButtonQuickSwitchTouchController method setupAnimators.

private void setupAnimators() {
    // Animate the non-overview components (e.g. workspace, shelf) out of the way.
    AnimatorSetBuilder nonOverviewBuilder = new AnimatorSetBuilder();
    nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_FADE, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_ALL_APPS_FADE, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, TRANSLATE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, TRANSLATE_OUT_INTERPOLATOR);
    updateNonOverviewAnim(QUICK_SWITCH, nonOverviewBuilder, ANIM_ALL);
    mNonOverviewAnim.dispatchOnStart();
    setupOverviewAnimators();
}
Also used : AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder)

Example 48 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.

the class RecentsView method updateDeadZoneRects.

private void updateDeadZoneRects() {
    // Get the deadzone rect surrounding the clear all button to not dismiss overview to home
    mClearAllButtonDeadZoneRect.setEmpty();
    if (mClearAllButton.getWidth() > 0) {
        int verticalMargin = getResources().getDimensionPixelSize(R.dimen.recents_clear_all_deadzone_vertical_margin);
        mClearAllButton.getHitRect(mClearAllButtonDeadZoneRect);
        mClearAllButtonDeadZoneRect.inset(-getPaddingRight() / 2, -verticalMargin);
    }
    // Get the deadzone rect between the task views
    mTaskViewDeadZoneRect.setEmpty();
    int count = getTaskViewCount();
    if (count > 0) {
        final View taskView = getTaskViewAt(0);
        getTaskViewAt(count - 1).getHitRect(mTaskViewDeadZoneRect);
        mTaskViewDeadZoneRect.union(taskView.getLeft(), taskView.getTop(), taskView.getRight(), taskView.getBottom());
    }
}
Also used : View(android.view.View) ListView(android.widget.ListView) PagedView(com.android.launcher3.PagedView) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 49 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.

the class QuickstepAppTransitionManagerImpl method getLauncherContentAnimator.

/**
 * Content is everything on screen except the background and the floating view (if any).
 *
 * @param isAppOpening True when this is called when an app is opening.
 *                     False when this is called when an app is closing.
 * @param trans        Array that contains the start and end translation values for the content.
 */
protected Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean isAppOpening, float[] trans) {
    AnimatorSet launcherAnimator = new AnimatorSet();
    Runnable endListener;
    float[] alphas = isAppOpening ? new float[] { 1, 0 } : new float[] { 0, 1 };
    if (mLauncher.isInState(ALL_APPS)) {
        // All Apps in portrait mode is full screen, so we only animate AllAppsContainerView.
        final View appsView = mLauncher.getAppsView();
        final float startAlpha = appsView.getAlpha();
        final float startY = appsView.getTranslationY();
        appsView.setAlpha(alphas[0]);
        appsView.setTranslationY(trans[0]);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(appsView, View.ALPHA, alphas);
        alpha.setDuration(CONTENT_ALPHA_DURATION);
        alpha.setInterpolator(LINEAR);
        appsView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        alpha.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                appsView.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        });
        ObjectAnimator transY = ObjectAnimator.ofFloat(appsView, View.TRANSLATION_Y, trans);
        transY.setInterpolator(AGGRESSIVE_EASE);
        transY.setDuration(CONTENT_TRANSLATION_DURATION);
        launcherAnimator.play(alpha);
        launcherAnimator.play(transY);
        endListener = () -> {
            appsView.setAlpha(startAlpha);
            appsView.setTranslationY(startY);
            appsView.setLayerType(View.LAYER_TYPE_NONE, null);
        };
    } else if (mLauncher.isInState(OVERVIEW)) {
        AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
        launcherAnimator.play(ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS, allAppsController.getProgress(), ALL_APPS_PROGRESS_OFF_SCREEN));
        endListener = composeViewContentAnimator(launcherAnimator, alphas, trans);
    } else {
        mDragLayerAlpha.setValue(alphas[0]);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(mDragLayerAlpha, MultiValueAlpha.VALUE, alphas);
        alpha.setDuration(CONTENT_ALPHA_DURATION);
        alpha.setInterpolator(LINEAR);
        launcherAnimator.play(alpha);
        mDragLayer.setTranslationY(trans[0]);
        ObjectAnimator transY = ObjectAnimator.ofFloat(mDragLayer, View.TRANSLATION_Y, trans);
        transY.setInterpolator(AGGRESSIVE_EASE);
        transY.setDuration(CONTENT_TRANSLATION_DURATION);
        launcherAnimator.play(transY);
        mDragLayer.getScrim().hideSysUiScrim(true);
        // Pause page indicator animations as they lead to layer trashing.
        mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
        mDragLayer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        endListener = this::resetContentView;
    }
    return new Pair<>(launcherAnimator, endListener);
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) FloatingIconView(com.android.launcher3.views.FloatingIconView) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) Pair(android.util.Pair)

Example 50 with OVERVIEW

use of com.android.launcher3.LauncherState.OVERVIEW in project Neo-Launcher by NeoApplications.

the class PortraitStatesTouchController method initCurrentAnimation.

@Override
protected float initCurrentAnimation(@AnimationComponents int animComponents) {
    float range = getShiftRange();
    long maxAccuracy = (long) (2 * range);
    float startVerticalShift = mFromState.getVerticalProgress(mLauncher) * range;
    float endVerticalShift = mToState.getVerticalProgress(mLauncher) * range;
    float totalShift = endVerticalShift - startVerticalShift;
    final AnimatorSetBuilder builder = totalShift == 0 ? new AnimatorSetBuilder() : getAnimatorSetBuilderForStates(mFromState, mToState);
    updateAnimatorBuilderOnReinit(builder);
    cancelPendingAnim();
    if (mFromState == OVERVIEW && mToState == NORMAL && mOverviewPortraitStateTouchHelper.shouldSwipeDownReturnToApp()) {
        // Reset the state manager, when changing the interaction mode
        mLauncher.getStateManager().goToState(OVERVIEW, false);
        mPendingAnimation = mOverviewPortraitStateTouchHelper.createSwipeDownToTaskAppAnimation(maxAccuracy);
        mPendingAnimation.anim.setInterpolator(Interpolators.LINEAR);
        Runnable onCancelRunnable = () -> {
            cancelPendingAnim();
            clearState();
        };
        mCurrentAnimation = AnimatorPlaybackController.wrap(mPendingAnimation.anim, maxAccuracy, onCancelRunnable);
        mLauncher.getStateManager().setCurrentUserControlledAnimation(mCurrentAnimation);
        totalShift = LayoutUtils.getShelfTrackingDistance(mLauncher, mLauncher.getDeviceProfile());
    } else {
        mCurrentAnimation = mLauncher.getStateManager().createAnimationToNewWorkspace(mToState, builder, maxAccuracy, this::clearState, animComponents);
    }
    if (totalShift == 0) {
        totalShift = Math.signum(mFromState.ordinal - mToState.ordinal) * OverviewState.getDefaultSwipeHeight(mLauncher);
    }
    return 1 / totalShift;
}
Also used : AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder)

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