Search in sources :

Example 16 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Trebuchet by LineageOS.

the class WorkspaceStateTransitionAnimation method setScrim.

public void setScrim(PropertySetter propertySetter, LauncherState state) {
    WorkspaceAndHotseatScrim scrim = mLauncher.getDragLayer().getScrim();
    propertySetter.setFloat(scrim, SCRIM_PROGRESS, state.getWorkspaceScrimAlpha(mLauncher), LINEAR);
    propertySetter.setFloat(scrim, SYSUI_PROGRESS, state.hasFlag(FLAG_HAS_SYS_UI_SCRIM) ? 1 : 0, LINEAR);
}
Also used : WorkspaceAndHotseatScrim(com.android.launcher3.graphics.WorkspaceAndHotseatScrim)

Example 17 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Trebuchet by LineageOS.

the class TaskViewUtils method createRecentsWindowAnimator.

/**
 * Creates an animation that controls the window of the opening targets for the recents launch
 * animation.
 */
public static void createRecentsWindowAnimator(TaskView v, boolean skipViewChanges, RemoteAnimationTargetCompat[] appTargets, RemoteAnimationTargetCompat[] wallpaperTargets, DepthController depthController, PendingAnimation out) {
    SurfaceTransactionApplier applier = new SurfaceTransactionApplier(v);
    final RemoteAnimationTargets targets = new RemoteAnimationTargets(appTargets, wallpaperTargets, MODE_OPENING);
    targets.addReleaseCheck(applier);
    TransformParams params = new TransformParams().setSyncTransactionApplier(applier).setTargetSet(targets);
    final RecentsView recentsView = v.getRecentsView();
    int taskIndex = recentsView.indexOfChild(v);
    boolean parallaxCenterAndAdjacentTask = taskIndex != recentsView.getCurrentPage();
    int startScroll = recentsView.getScrollOffset(taskIndex);
    Context context = v.getContext();
    DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
    // RecentsView never updates the display rotation until swipe-up so the value may be stale.
    // Use the display value instead.
    int displayRotation = DefaultDisplay.INSTANCE.get(context).getInfo().rotation;
    TaskViewSimulator topMostSimulator = null;
    if (targets.apps.length > 0) {
        TaskViewSimulator tsv = new TaskViewSimulator(context, recentsView.getSizeStrategy());
        tsv.setDp(dp);
        tsv.setLayoutRotation(displayRotation, displayRotation);
        tsv.setPreview(targets.apps[targets.apps.length - 1]);
        tsv.fullScreenProgress.value = 0;
        tsv.recentsViewScale.value = 1;
        tsv.setScroll(startScroll);
        out.setFloat(tsv.fullScreenProgress, AnimatedFloat.VALUE, 1, TOUCH_RESPONSE_INTERPOLATOR);
        out.setFloat(tsv.recentsViewScale, AnimatedFloat.VALUE, tsv.getFullScreenScale(), TOUCH_RESPONSE_INTERPOLATOR);
        out.setInt(tsv, TaskViewSimulator.SCROLL, 0, TOUCH_RESPONSE_INTERPOLATOR);
        out.addOnFrameCallback(() -> tsv.apply(params));
        topMostSimulator = tsv;
    }
    // Fade in the task during the initial 20% of the animation
    out.addFloat(params, TransformParams.TARGET_ALPHA, 0, 1, clampToProgress(LINEAR, 0, 0.2f));
    if (!skipViewChanges && parallaxCenterAndAdjacentTask && topMostSimulator != null) {
        out.addFloat(v, VIEW_ALPHA, 1, 0, clampToProgress(LINEAR, 0.2f, 0.4f));
        TaskViewSimulator simulatorToCopy = topMostSimulator;
        simulatorToCopy.apply(params);
        // Mt represents the overall transformation on the thumbnailView relative to the
        // Launcher's rootView
        // K(t) represents transformation on the running window by the taskViewSimulator at
        // any time t.
        // at t = 0, we know that the simulator matches the thumbnailView. So if we apply K(0)`
        // on the Launcher's rootView, the thumbnailView would match the full running task
        // window. If we apply "K(0)` K(t)" thumbnailView will match the final transformed
        // window at any time t. This gives the overall matrix on thumbnailView to be:
        // Mt K(0)` K(t)
        // During animation we apply transformation on the thumbnailView (and not the rootView)
        // to follow the TaskViewSimulator. So the final matrix applied on the thumbnailView is:
        // Mt K(0)` K(t) Mt`
        TaskThumbnailView ttv = v.getThumbnail();
        RectF tvBounds = new RectF(0, 0, ttv.getWidth(), ttv.getHeight());
        float[] tvBoundsMapped = new float[] { 0, 0, ttv.getWidth(), ttv.getHeight() };
        getDescendantCoordRelativeToAncestor(ttv, ttv.getRootView(), tvBoundsMapped, false);
        RectF tvBoundsInRoot = new RectF(tvBoundsMapped[0], tvBoundsMapped[1], tvBoundsMapped[2], tvBoundsMapped[3]);
        Matrix mt = new Matrix();
        mt.setRectToRect(tvBounds, tvBoundsInRoot, ScaleToFit.FILL);
        Matrix mti = new Matrix();
        mt.invert(mti);
        Matrix k0i = new Matrix();
        simulatorToCopy.getCurrentMatrix().invert(k0i);
        Matrix animationMatrix = new Matrix();
        out.addOnFrameCallback(() -> {
            animationMatrix.set(mt);
            animationMatrix.postConcat(k0i);
            animationMatrix.postConcat(simulatorToCopy.getCurrentMatrix());
            animationMatrix.postConcat(mti);
            ttv.setAnimationMatrix(animationMatrix);
        });
        out.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                ttv.setAnimationMatrix(null);
            }
        });
    }
    out.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            targets.release();
        }
    });
    if (depthController != null) {
        out.setFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(context), TOUCH_RESPONSE_INTERPOLATOR);
    }
}
Also used : Context(android.content.Context) TaskViewSimulator(com.android.quickstep.util.TaskViewSimulator) RectF(android.graphics.RectF) DeviceProfile(com.android.launcher3.DeviceProfile) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) Matrix(android.graphics.Matrix) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) TransformParams(com.android.quickstep.util.TransformParams) RecentsView(com.android.quickstep.views.RecentsView) TaskThumbnailView(com.android.quickstep.views.TaskThumbnailView)

Example 18 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Trebuchet by LineageOS.

the class RecentsView method addDismissedTaskAnimations.

private void addDismissedTaskAnimations(View taskView, long duration, PendingAnimation anim) {
    // Use setFloat instead of setViewAlpha as we want to keep the view visible even when it's
    // alpha is set to 0 so that it can be recycled in the view pool properly
    anim.setFloat(taskView, VIEW_ALPHA, 0, ACCEL_2);
    FloatProperty<View> secondaryViewTranslate = mOrientationHandler.getSecondaryViewTranslate();
    int secondaryTaskDimension = mOrientationHandler.getSecondaryDimension(taskView);
    int verticalFactor = mOrientationHandler.getSecondaryTranslationDirectionFactor();
    ResourceProvider rp = DynamicResource.provider(mActivity);
    SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_START).setDampingRatio(rp.getFloat(R.dimen.dismiss_task_trans_y_damping_ratio)).setStiffness(rp.getFloat(R.dimen.dismiss_task_trans_y_stiffness));
    anim.add(ObjectAnimator.ofFloat(taskView, secondaryViewTranslate, verticalFactor * secondaryTaskDimension).setDuration(duration), LINEAR, sp);
}
Also used : SpringProperty(com.android.launcher3.anim.SpringProperty) ResourceProvider(com.android.systemui.plugins.ResourceProvider) View(android.view.View) ListView(android.widget.ListView) PagedView(com.android.launcher3.PagedView) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 19 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Trebuchet by LineageOS.

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;
    StateAnimationConfig config = new StateAnimationConfig();
    config.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(ACCEL, 0, 0.08f));
    config.duration = secondPart;
    config.userControlled = false;
    AnimatorPlaybackController stateAnimationController = mLauncher.getStateManager().createAnimationToNewWorkspace(ALL_APPS, config);
    float maxAllAppsProgress = mLauncher.getDeviceProfile().isLandscape ? 0.35f : 0.15f;
    AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
    PendingAnimation allAppsAlpha = new PendingAnimation(config.duration);
    allAppsController.setAlphas(ALL_APPS, config, allAppsAlpha);
    mAnimation.play(allAppsAlpha.buildAnim());
    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) {
            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);
        }
    });
    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 : PendingAnimation(com.android.launcher3.anim.PendingAnimation) Rect(android.graphics.Rect) StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AllAppsTransitionController(com.android.launcher3.allapps.AllAppsTransitionController) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 20 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Trebuchet by LineageOS.

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());
    if (mDeviceState.isFullyGesturalNavMode()) {
        // We can drag all the way to the top of the screen.
        mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
    } else {
        mDragLengthFactor = 1 + AnimatorControllerWithResistance.TWO_BUTTON_EXTRA_DRAG_FACTOR;
    }
    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)

Aggregations

ValueAnimator (android.animation.ValueAnimator)52 Animator (android.animation.Animator)45 Rect (android.graphics.Rect)43 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)38 PendingAnimation (com.android.launcher3.anim.PendingAnimation)35 RectF (android.graphics.RectF)34 ObjectAnimator (android.animation.ObjectAnimator)33 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)29 MultiValueUpdateListener (com.android.quickstep.util.MultiValueUpdateListener)28 AnimatorSet (android.animation.AnimatorSet)26 View (android.view.View)25 Matrix (android.graphics.Matrix)24 RecentsView (com.android.quickstep.views.RecentsView)24 Point (android.graphics.Point)23 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)23 Context (android.content.Context)22 SurfaceTransactionApplier (com.android.quickstep.util.SurfaceTransactionApplier)22 SurfaceParams (com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams)21 ResourceProvider (com.android.systemui.plugins.ResourceProvider)20 LauncherState (com.android.launcher3.LauncherState)19