Search in sources :

Example 1 with ACCEL

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

the class PortraitStatesTouchController method getNormalToAllAppsAnimation.

private StateAnimationConfig getNormalToAllAppsAnimation() {
    StateAnimationConfig builder = new StateAnimationConfig();
    builder.setInterpolator(ANIM_ALL_APPS_FADE, Interpolators.clampToProgress(ACCEL, ALL_APPS_CONTENT_FADE_MIN_CLAMPING_THRESHOLD, ALL_APPS_CONTENT_FADE_MAX_CLAMPING_THRESHOLD));
    builder.setInterpolator(ANIM_SCRIM_FADE, Interpolators.clampToProgress(ACCEL, ALL_APPS_SCRIM_VISIBLE_THRESHOLD, ALL_APPS_SCRIM_OPAQUE_THRESHOLD));
    return builder;
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig)

Example 2 with ACCEL

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

the class RecentsView method cancelSplitSelect.

public PendingAnimation cancelSplitSelect(boolean animate) {
    SplitSelectStateController splitController = mSplitPlaceholderView.getSplitController();
    SplitPositionOption splitOption = splitController.getActiveSplitPositionOption();
    Rect initialBounds = splitController.getInitialBounds();
    splitController.resetState();
    int duration = mActivity.getStateManager().getState().getTransitionDuration(getContext());
    PendingAnimation pendingAnim = new PendingAnimation(duration);
    if (!animate) {
        resetFromSplitSelectionState();
        return pendingAnim;
    }
    addViewInLayout(mSplitHiddenTaskView, mSplitHiddenTaskViewIndex, mSplitHiddenTaskView.getLayoutParams());
    mSplitHiddenTaskView.setAlpha(0);
    int[] oldScroll = new int[getChildCount()];
    getPageScrolls(oldScroll, false, view -> view.getVisibility() != GONE && view != mSplitHiddenTaskView);
    int[] newScroll = new int[getChildCount()];
    getPageScrolls(newScroll, false, SIMPLE_SCROLL_LOGIC);
    boolean needsCurveUpdates = false;
    for (int i = mSplitHiddenTaskViewIndex; i >= 0; i--) {
        View child = getChildAt(i);
        if (child == mSplitHiddenTaskView) {
            TaskView taskView = (TaskView) child;
            int dir = mOrientationHandler.getSplitTaskViewDismissDirection(splitOption, mActivity.getDeviceProfile());
            FloatProperty<TaskView> dismissingTaskViewTranslate;
            Rect hiddenBounds = new Rect(taskView.getLeft(), taskView.getTop(), taskView.getRight(), taskView.getBottom());
            int distanceDelta = 0;
            if (dir == PagedOrientationHandler.SPLIT_TRANSLATE_SECONDARY_NEGATIVE) {
                dismissingTaskViewTranslate = taskView.getSecondaryDissmissTranslationProperty();
                distanceDelta = initialBounds.top - hiddenBounds.top;
                taskView.layout(initialBounds.left, hiddenBounds.top, initialBounds.right, hiddenBounds.bottom);
            } else {
                dismissingTaskViewTranslate = taskView.getPrimaryDismissTranslationProperty();
                distanceDelta = initialBounds.left - hiddenBounds.left;
                taskView.layout(hiddenBounds.left, initialBounds.top, hiddenBounds.right, initialBounds.bottom);
                if (dir == PagedOrientationHandler.SPLIT_TRANSLATE_PRIMARY_POSITIVE) {
                    distanceDelta *= -1;
                }
            }
            pendingAnim.add(ObjectAnimator.ofFloat(mSplitHiddenTaskView, dismissingTaskViewTranslate, distanceDelta));
            pendingAnim.add(ObjectAnimator.ofFloat(mSplitHiddenTaskView, ALPHA, 1));
        } else {
            // ignore views to left
            if (showAsGrid()) {
                // TODO(b/186800707) handle more elegantly for grid
                continue;
            }
            int scrollDiff = newScroll[i] - oldScroll[i];
            if (scrollDiff != 0) {
                FloatProperty translationProperty = child instanceof TaskView ? ((TaskView) child).getPrimaryDismissTranslationProperty() : mOrientationHandler.getPrimaryViewTranslate();
                ResourceProvider rp = DynamicResource.provider(mActivity);
                SpringProperty sp = new SpringProperty(SpringProperty.FLAG_CAN_SPRING_ON_END).setDampingRatio(rp.getFloat(R.dimen.dismiss_task_trans_x_damping_ratio)).setStiffness(rp.getFloat(R.dimen.dismiss_task_trans_x_stiffness));
                pendingAnim.add(ObjectAnimator.ofFloat(child, translationProperty, scrollDiff).setDuration(duration), ACCEL, sp);
                needsCurveUpdates = true;
            }
        }
    }
    if (needsCurveUpdates) {
        pendingAnim.addOnFrameCallback(this::updateCurveProperties);
    }
    pendingAnim.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            // TODO(b/186800707) Figure out how to undo for grid view
            // Need to handle cases where dismissed task is
            // * Top Row
            // * Bottom Row
            // * Focused Task
            updateGridProperties();
            resetFromSplitSelectionState();
        }
    });
    return pendingAnim;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) SpringProperty(com.android.launcher3.anim.SpringProperty) Rect(android.graphics.Rect) ImageView(android.widget.ImageView) View(android.view.View) ListView(android.widget.ListView) PagedView(com.android.launcher3.PagedView) TextPaint(android.text.TextPaint) Point(android.graphics.Point) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) SplitPositionOption(com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption) ResourceProvider(com.android.systemui.plugins.ResourceProvider) SplitSelectStateController(com.android.quickstep.util.SplitSelectStateController) FloatProperty(android.util.FloatProperty) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 3 with ACCEL

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

the class SwipeUpGestureTutorialController method resetFakeTaskView.

void resetFakeTaskView() {
    PendingAnimation anim = new PendingAnimation(300);
    anim.setFloat(mTaskViewSwipeUpAnimation.getCurrentShift(), AnimatedFloat.VALUE, 0, ACCEL);
    anim.setViewAlpha(mFakeTaskView, 1, ACCEL);
    anim.addListener(mResetTaskView);
    AnimatorSet animset = anim.buildAnim();
    animset.start();
    mRunningWindowAnim = RunningWindowAnim.wrap(animset);
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) AnimatorSet(android.animation.AnimatorSet)

Example 4 with ACCEL

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

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);
    }
}
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) ANIM_OVERVIEW_SCALE(com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE) VISIBLE(android.view.View.VISIBLE) SysUINavigationMode(com.android.quickstep.SysUINavigationMode) 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) 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) Workspace(com.android.launcher3.Workspace) ANIM_SCRIM_FADE(com.android.launcher3.states.StateAnimationConfig.ANIM_SCRIM_FADE) HINT_STATE(com.android.launcher3.LauncherState.HINT_STATE) 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 5 with ACCEL

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

the class RecentsView method addDismissedTaskAnimations.

private void addDismissedTaskAnimations(TaskView 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, clampToProgress(ACCEL, 0, 0.5f));
    SplitSelectStateController splitController = mSplitPlaceholderView.getSplitController();
    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));
    FloatProperty<TaskView> dismissingTaskViewTranslate = taskView.getSecondaryDissmissTranslationProperty();
    // TODO(b/186800707) translate entire grid size distance
    int translateDistance = mOrientationHandler.getSecondaryDimension(taskView);
    int positiveNegativeFactor = mOrientationHandler.getSecondaryTranslationDirectionFactor();
    if (splitController.isSplitSelectActive()) {
        // Have the task translate towards whatever side was just pinned
        int dir = mOrientationHandler.getSplitTaskViewDismissDirection(splitController.getActiveSplitPositionOption(), mActivity.getDeviceProfile());
        switch(dir) {
            case PagedOrientationHandler.SPLIT_TRANSLATE_SECONDARY_NEGATIVE:
                dismissingTaskViewTranslate = taskView.getSecondaryDissmissTranslationProperty();
                positiveNegativeFactor = -1;
                break;
            case PagedOrientationHandler.SPLIT_TRANSLATE_PRIMARY_POSITIVE:
                dismissingTaskViewTranslate = taskView.getPrimaryDismissTranslationProperty();
                positiveNegativeFactor = 1;
                break;
            case PagedOrientationHandler.SPLIT_TRANSLATE_PRIMARY_NEGATIVE:
                dismissingTaskViewTranslate = taskView.getPrimaryDismissTranslationProperty();
                positiveNegativeFactor = -1;
                break;
            default:
                throw new IllegalStateException("Invalid split task translation: " + dir);
        }
    }
    // Double translation distance so dismissal drag is the full height, as we only animate
    // the drag for the first half of the progress.
    anim.add(ObjectAnimator.ofFloat(taskView, dismissingTaskViewTranslate, positiveNegativeFactor * translateDistance * 2).setDuration(duration), LINEAR, sp);
    if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile && taskView.isRunningTask()) {
        anim.addOnFrameCallback(() -> {
            mLiveTileTaskViewSimulator.taskSecondaryTranslation.value = mOrientationHandler.getSecondaryValue(taskView.getTranslationX(), taskView.getTranslationY());
            redrawLiveTile();
        });
    }
}
Also used : SpringProperty(com.android.launcher3.anim.SpringProperty) ResourceProvider(com.android.systemui.plugins.ResourceProvider) SplitSelectStateController(com.android.quickstep.util.SplitSelectStateController) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Aggregations

PendingAnimation (com.android.launcher3.anim.PendingAnimation)5 AnimatorSet (android.animation.AnimatorSet)4 Animator (android.animation.Animator)2 ValueAnimator (android.animation.ValueAnimator)2 Point (android.graphics.Point)2 TextPaint (android.text.TextPaint)2 SpringProperty (com.android.launcher3.anim.SpringProperty)2 StateAnimationConfig (com.android.launcher3.states.StateAnimationConfig)2 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ObjectAnimator (android.animation.ObjectAnimator)1 Rect (android.graphics.Rect)1 FloatProperty (android.util.FloatProperty)1 View (android.view.View)1 VISIBLE (android.view.View.VISIBLE)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 CellLayout (com.android.launcher3.CellLayout)1 Hotseat (com.android.launcher3.Hotseat)1 LauncherState (com.android.launcher3.LauncherState)1 HINT_STATE (com.android.launcher3.LauncherState.HINT_STATE)1