Search in sources :

Example 6 with PropertySetter

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

the class WorkspaceStateTransitionAnimation method setWorkspaceProperty.

/**
 * Starts a transition animation for the workspace.
 */
private void setWorkspaceProperty(LauncherState state, PropertySetter propertySetter, StateAnimationConfig config) {
    ScaleAndTranslation scaleAndTranslation = state.getWorkspaceScaleAndTranslation(mLauncher);
    ScaleAndTranslation hotseatScaleAndTranslation = state.getHotseatScaleAndTranslation(mLauncher);
    ScaleAndTranslation qsbScaleAndTranslation = state.getQsbScaleAndTranslation(mLauncher);
    mNewScale = scaleAndTranslation.scale;
    PageAlphaProvider pageAlphaProvider = state.getWorkspacePageAlphaProvider(mLauncher);
    final int childCount = mWorkspace.getChildCount();
    for (int i = 0; i < childCount; i++) {
        applyChildState(state, (CellLayout) mWorkspace.getChildAt(i), i, pageAlphaProvider, propertySetter, config);
    }
    int elements = state.getVisibleElements(mLauncher);
    Interpolator fadeInterpolator = config.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator);
    boolean playAtomicComponent = config.playAtomicOverviewScaleComponent();
    Hotseat hotseat = mWorkspace.getHotseat();
    // Since we set the pivot relative to mWorkspace, we need to scale a sibling of Workspace.
    AllAppsContainerView qsbScaleView = mLauncher.getAppsView();
    View qsbView = qsbScaleView.getSearchView();
    if (playAtomicComponent) {
        Interpolator scaleInterpolator = config.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
        LauncherState fromState = mLauncher.getStateManager().getState();
        boolean shouldSpring = propertySetter instanceof PendingAnimation && fromState == HINT_STATE && state == NORMAL;
        if (shouldSpring) {
            ((PendingAnimation) propertySetter).add(getSpringScaleAnimator(mLauncher, mWorkspace, mNewScale));
        } else {
            propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
        }
        setPivotToScaleWithWorkspace(hotseat);
        setPivotToScaleWithWorkspace(qsbScaleView);
        float hotseatScale = hotseatScaleAndTranslation.scale;
        if (shouldSpring) {
            PendingAnimation pa = (PendingAnimation) propertySetter;
            pa.add(getSpringScaleAnimator(mLauncher, hotseat, hotseatScale));
            pa.add(getSpringScaleAnimator(mLauncher, qsbScaleView, qsbScaleAndTranslation.scale));
        } else {
            Interpolator hotseatScaleInterpolator = config.getInterpolator(ANIM_HOTSEAT_SCALE, scaleInterpolator);
            propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale, hotseatScaleInterpolator);
            propertySetter.setFloat(qsbScaleView, SCALE_PROPERTY, qsbScaleAndTranslation.scale, hotseatScaleInterpolator);
        }
        float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
        propertySetter.setViewAlpha(hotseat, hotseatIconsAlpha, fadeInterpolator);
        propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(), hotseatIconsAlpha, fadeInterpolator);
    }
    if (config.onlyPlayAtomicComponent()) {
        // Only the alpha and scale, handled above, are included in the atomic animation.
        return;
    }
    Interpolator translationInterpolator = !playAtomicComponent ? LINEAR : config.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
    propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_X, scaleAndTranslation.translationX, translationInterpolator);
    propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_Y, scaleAndTranslation.translationY, translationInterpolator);
    Interpolator hotseatTranslationInterpolator = config.getInterpolator(ANIM_HOTSEAT_TRANSLATE, translationInterpolator);
    propertySetter.setFloat(hotseat, VIEW_TRANSLATE_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    propertySetter.setFloat(mWorkspace.getPageIndicator(), VIEW_TRANSLATE_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    propertySetter.setFloat(qsbView, VIEW_TRANSLATE_Y, qsbScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    setScrim(propertySetter, state);
}
Also used : ScaleAndTranslation(com.android.launcher3.LauncherState.ScaleAndTranslation) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PageAlphaProvider(com.android.launcher3.LauncherState.PageAlphaProvider) Interpolator(android.view.animation.Interpolator) View(android.view.View) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView)

Example 7 with PropertySetter

use of com.android.launcher3.anim.PropertySetter 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 8 with PropertySetter

use of com.android.launcher3.anim.PropertySetter in project Neo-Launcher by NeoApplications.

the class RecentsViewStateController method setStateWithAnimationInternal.

@Override
void setStateWithAnimationInternal(@NonNull final LauncherState toState, @NonNull AnimatorSetBuilder builder, @NonNull AnimationConfig config) {
    super.setStateWithAnimationInternal(toState, builder, config);
    if (!toState.overviewUi) {
        builder.addOnFinishRunnable(mRecentsView::resetTaskVisuals);
    }
    if (toState.overviewUi) {
        ValueAnimator updateAnim = ValueAnimator.ofFloat(0, 1);
        updateAnim.addUpdateListener(valueAnimator -> {
            // While animating into recents, update the visible task data as needed
            mRecentsView.loadVisibleTaskData();
        });
        updateAnim.setDuration(config.duration);
        builder.play(updateAnim);
        mRecentsView.updateEmptyMessage();
    }
    PropertySetter propertySetter = config.getPropertySetter(builder);
    setAlphas(propertySetter, toState.getVisibleElements(mLauncher));
    float fullscreenProgress = toState.getOverviewFullscreenProgress();
    propertySetter.setFloat(mRecentsView, FULLSCREEN_PROGRESS, fullscreenProgress, LINEAR);
}
Also used : PropertySetter(com.android.launcher3.anim.PropertySetter) ValueAnimator(android.animation.ValueAnimator)

Example 9 with PropertySetter

use of com.android.launcher3.anim.PropertySetter in project Neo-Launcher by NeoApplications.

the class BaseRecentsViewStateController method setStateWithAnimationInternal.

/**
 * Core logic for animating the recents view UI.
 *
 * @param toState state to animate to
 * @param builder animator set builder
 * @param config current animation config
 */
void setStateWithAnimationInternal(@NonNull final LauncherState toState, @NonNull AnimatorSetBuilder builder, @NonNull AnimationConfig config) {
    PropertySetter setter = config.getPropertySetter(builder);
    ScaleAndTranslation scaleAndTranslation = toState.getOverviewScaleAndTranslation(mLauncher);
    Interpolator scaleInterpolator = builder.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR);
    setter.setFloat(mRecentsView, SCALE_PROPERTY, scaleAndTranslation.scale, scaleInterpolator);
    Interpolator translateXInterpolator = builder.getInterpolator(ANIM_OVERVIEW_TRANSLATE_X, LINEAR);
    Interpolator translateYInterpolator = builder.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR);
    float translationX = scaleAndTranslation.translationX;
    if (mRecentsView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
        translationX = -translationX;
    }
    setter.setFloat(mRecentsView, View.TRANSLATION_X, translationX, translateXInterpolator);
    setter.setFloat(mRecentsView, View.TRANSLATION_Y, scaleAndTranslation.translationY, translateYInterpolator);
    setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0, builder.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
    OverviewScrim scrim = mLauncher.getDragLayer().getOverviewScrim();
    setter.setFloat(scrim, SCRIM_PROGRESS, toState.getOverviewScrimAlpha(mLauncher), builder.getInterpolator(ANIM_OVERVIEW_SCRIM_FADE, LINEAR));
}
Also used : ScaleAndTranslation(com.android.launcher3.LauncherState.ScaleAndTranslation) OverviewScrim(com.android.launcher3.graphics.OverviewScrim) PropertySetter(com.android.launcher3.anim.PropertySetter) Interpolator(android.view.animation.Interpolator)

Example 10 with PropertySetter

use of com.android.launcher3.anim.PropertySetter in project Neo-Launcher by NeoApplications.

the class StaggeredWorkspaceAnim method addScrimAnimationForState.

private void addScrimAnimationForState(Launcher launcher, LauncherState state, long duration) {
    AnimatorSetBuilder scrimAnimBuilder = new AnimatorSetBuilder();
    AnimationConfig scrimAnimConfig = new AnimationConfig();
    scrimAnimConfig.duration = duration;
    PropertySetter scrimPropertySetter = scrimAnimConfig.getPropertySetter(scrimAnimBuilder);
    launcher.getWorkspace().getStateTransitionAnimation().setScrim(scrimPropertySetter, state);
    mAnimators.add(scrimAnimBuilder.build());
    Animator fadeOverviewScrim = ObjectAnimator.ofFloat(launcher.getDragLayer().getOverviewScrim(), OverviewScrim.SCRIM_PROGRESS, state.getOverviewScrimAlpha(launcher));
    fadeOverviewScrim.setDuration(duration);
    mAnimators.add(fadeOverviewScrim);
}
Also used : AnimatorSetBuilder(com.android.launcher3.anim.AnimatorSetBuilder) Animator(android.animation.Animator) SpringObjectAnimator(com.android.launcher3.anim.SpringObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) PropertySetter(com.android.launcher3.anim.PropertySetter) AnimationConfig(com.android.launcher3.LauncherStateManager.AnimationConfig)

Aggregations

Interpolator (android.view.animation.Interpolator)14 ScaleAndTranslation (com.android.launcher3.LauncherState.ScaleAndTranslation)8 PageAlphaProvider (com.android.launcher3.LauncherState.PageAlphaProvider)7 PendingAnimation (com.android.launcher3.anim.PendingAnimation)6 Scrim (com.android.launcher3.graphics.Scrim)5 SysUiScrim (com.android.launcher3.graphics.SysUiScrim)5 SpringLoadedState (com.android.launcher3.states.SpringLoadedState)5 PropertySetter (com.android.launcher3.anim.PropertySetter)4 WorkspaceAndHotseatScrim (com.android.launcher3.graphics.WorkspaceAndHotseatScrim)2 Animator (android.animation.Animator)1 ObjectAnimator (android.animation.ObjectAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 View (android.view.View)1 AnimationConfig (com.android.launcher3.LauncherStateManager.AnimationConfig)1 AllAppsContainerView (com.android.launcher3.allapps.AllAppsContainerView)1 AnimatorSetBuilder (com.android.launcher3.anim.AnimatorSetBuilder)1 SpringObjectAnimator (com.android.launcher3.anim.SpringObjectAnimator)1 DragLayer (com.android.launcher3.dragndrop.DragLayer)1 OverviewScrim (com.android.launcher3.graphics.OverviewScrim)1 OmegaBackgroundView (com.saggitt.omega.views.OmegaBackgroundView)1