Search in sources :

Example 6 with AnimatorPlaybackController

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

the class StateManager method createAnimationToNewWorkspace.

public AnimatorPlaybackController createAnimationToNewWorkspace(STATE_TYPE state, long duration, @AnimationFlags int animFlags) {
    StateAnimationConfig config = new StateAnimationConfig();
    config.duration = duration;
    config.animFlags = animFlags;
    return createAnimationToNewWorkspace(state, config);
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig)

Example 7 with AnimatorPlaybackController

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

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);
    xAnim.setViewBackgroundColor(mLauncher.getScrimView(), toState.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 8 with AnimatorPlaybackController

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

the class LauncherSwipeHandlerV2 method createHomeAnimationFactory.

@Override
protected HomeAnimationFactory createHomeAnimationFactory(ArrayList<IBinder> launchCookies, long duration, boolean isTargetTranslucent, boolean appCanEnterPip, RemoteAnimationTargetCompat runningTaskTarget) {
    if (mActivity == null) {
        mStateCallback.addChangeListener(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED, isPresent -> mRecentsView.startHome());
        return new HomeAnimationFactory() {

            @Override
            public AnimatorPlaybackController createActivityAnimationToHome() {
                return AnimatorPlaybackController.wrap(new AnimatorSet(), duration);
            }
        };
    }
    final View workspaceView = findWorkspaceView(launchCookies, mRecentsView.getRunningTaskView());
    boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow();
    mActivity.getRootView().setForceHideBackArrow(true);
    mActivity.setHintUserWillBeActive();
    if (!canUseWorkspaceView || appCanEnterPip) {
        return new LauncherHomeAnimationFactory();
    }
    if (workspaceView instanceof LauncherAppWidgetHostView) {
        return createWidgetHomeAnimationFactory((LauncherAppWidgetHostView) workspaceView, isTargetTranslucent, runningTaskTarget);
    }
    return createIconHomeAnimationFactory(workspaceView);
}
Also used : AnimatorSet(android.animation.AnimatorSet) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) FloatingView(com.android.launcher3.views.FloatingView) View(android.view.View) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) FloatingIconView(com.android.launcher3.views.FloatingIconView) TaskView(com.android.quickstep.views.TaskView) FloatingIconView.getFloatingIconView(com.android.launcher3.views.FloatingIconView.getFloatingIconView) RecentsView(com.android.quickstep.views.RecentsView) FloatingWidgetView(com.android.quickstep.views.FloatingWidgetView)

Example 9 with AnimatorPlaybackController

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

the class SwipeUpAnimationLogic method initTransitionEndpoints.

protected void initTransitionEndpoints(DeviceProfile dp) {
    mDp = dp;
    mTaskViewSimulator.setDp(dp);
    mTransitionDragLength = mGestureState.getActivityInterface().getSwipeUpDestinationAndLength(dp, mContext, TEMP_RECT, mTaskViewSimulator.getOrientationState().getOrientationHandler());
    mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
    PendingAnimation pa = new PendingAnimation(mTransitionDragLength * 2);
    mTaskViewSimulator.addAppToOverviewAnim(pa, LINEAR);
    AnimatorPlaybackController normalController = pa.createPlaybackController();
    mWindowTransitionController = AnimatorControllerWithResistance.createForRecents(normalController, mContext, mTaskViewSimulator.getOrientationState(), mDp, mTaskViewSimulator.recentsViewScale, AnimatedFloat.VALUE, mTaskViewSimulator.recentsViewSecondaryTranslation, AnimatedFloat.VALUE);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 10 with AnimatorPlaybackController

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

the class AllAppsEduView method playAnimation.

private void playAnimation() {
    if (mAnimation != null) {
        return;
    }
    mAnimation = new AnimatorSet();
    final Rect circleBoundsOg = new Rect(mCircle.getBounds());
    final Rect gradientBoundsOg = new Rect(mGradient.getBounds());
    final Rect temp = new Rect();
    final float transY = mMaxHeightPx - mCircleSizePx - mPaddingPx;
    // 1st: Circle alpha/scale
    int firstPart = 600;
    // 2nd: Circle animates upwards, Gradient alpha fades in, Gradient grows, All Apps hint
    int secondPart = 1200;
    int introDuration = firstPart + secondPart;
    AnimatorPlaybackController stateAnimationController = mTouchController.initAllAppsAnimation();
    float maxAllAppsProgress = 0.75f;
    ValueAnimator intro = ValueAnimator.ofFloat(0, 1f);
    intro.setInterpolator(LINEAR);
    intro.setDuration(introDuration);
    intro.addUpdateListener((new MultiValueUpdateListener() {

        FloatProp mCircleAlpha = new FloatProp(0, 255, 0, firstPart, LINEAR);

        FloatProp mCircleScale = new FloatProp(2f, 1f, 0, firstPart, OVERSHOOT_1_7);

        FloatProp mDeltaY = new FloatProp(0, transY, firstPart, secondPart, FAST_OUT_SLOW_IN);

        FloatProp mGradientAlpha = new FloatProp(0, 255, firstPart, secondPart * 0.3f, LINEAR);

        @Override
        public void onUpdate(float progress, boolean initOnly) {
            temp.set(circleBoundsOg);
            temp.offset(0, (int) -mDeltaY.value);
            Utilities.scaleRectAboutCenter(temp, mCircleScale.value);
            mCircle.setBounds(temp);
            mCircle.setAlpha((int) mCircleAlpha.value);
            mGradient.setAlpha((int) mGradientAlpha.value);
            temp.set(gradientBoundsOg);
            temp.top -= mDeltaY.value;
            mGradient.setBounds(temp);
            invalidate();
            float stateProgress = Utilities.mapToRange(mDeltaY.value, 0, transY, 0, maxAllAppsProgress, LINEAR);
            stateAnimationController.setPlayFraction(stateProgress);
        }
    }));
    intro.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mCircle.setAlpha(0);
            mGradient.setAlpha(0);
        }
    });
    mLauncher.getAppsView().setVisibility(View.VISIBLE);
    mAnimation.play(intro);
    ValueAnimator closeAllApps = ValueAnimator.ofFloat(maxAllAppsProgress, 0f);
    closeAllApps.addUpdateListener(valueAnimator -> {
        stateAnimationController.setPlayFraction((float) valueAnimator.getAnimatedValue());
    });
    closeAllApps.setInterpolator(FAST_OUT_SLOW_IN);
    closeAllApps.setStartDelay(introDuration);
    closeAllApps.setDuration(250);
    mAnimation.play(closeAllApps);
    mAnimation.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mAnimation = null;
            // Handles cancelling the animation used to hint towards All Apps.
            mLauncher.getStateManager().goToState(NORMAL, false);
            handleClose(false);
        }
    });
    mAnimation.start();
}
Also used : Rect(android.graphics.Rect) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator)

Aggregations

AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)8 PendingAnimation (com.android.launcher3.anim.PendingAnimation)5 Animator (android.animation.Animator)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 TaskView (com.android.quickstep.views.TaskView)3 AnimatorSet (android.animation.AnimatorSet)2 ValueAnimator (android.animation.ValueAnimator)2 Rect (android.graphics.Rect)2 ObjectAnimator (android.animation.ObjectAnimator)1 ActivityManager (android.app.ActivityManager)1 Context (android.content.Context)1 Matrix (android.graphics.Matrix)1 RectF (android.graphics.RectF)1 View (android.view.View)1 DeviceProfile (com.android.launcher3.DeviceProfile)1 LauncherState (com.android.launcher3.LauncherState)1 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)1 FloatingIconView (com.android.launcher3.views.FloatingIconView)1 FloatingIconView.getFloatingIconView (com.android.launcher3.views.FloatingIconView.getFloatingIconView)1 FloatingView (com.android.launcher3.views.FloatingView)1