Search in sources :

Example 6 with SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY in project android_packages_apps_Launcher3 by crdroidandroid.

the class WorkspaceStateTransitionAnimation method getSpringScaleAnimator.

/**
 * Returns a spring based animator for the scale property of {@param v}.
 */
public static ValueAnimator getSpringScaleAnimator(Launcher launcher, View v, float scale) {
    ResourceProvider rp = DynamicResource.provider(launcher);
    float damping = rp.getFloat(R.dimen.hint_scale_damping_ratio);
    float stiffness = rp.getFloat(R.dimen.hint_scale_stiffness);
    float velocityPxPerS = rp.getDimension(R.dimen.hint_scale_velocity_dp_per_s);
    return new SpringAnimationBuilder(v.getContext()).setStiffness(stiffness).setDampingRatio(damping).setMinimumVisibleChange(MIN_VISIBLE_CHANGE_SCALE).setEndValue(scale).setStartValue(SCALE_PROPERTY.get(v)).setStartVelocity(velocityPxPerS).build(v, SCALE_PROPERTY);
}
Also used : ResourceProvider(com.android.systemui.plugins.ResourceProvider) SpringAnimationBuilder(com.android.launcher3.anim.SpringAnimationBuilder)

Example 7 with SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY in project android_packages_apps_Launcher3 by AOSPA.

the class HotseatPredictionController method pinPrediction.

/**
 * Pins a predicted app icon into place.
 */
public void pinPrediction(ItemInfo info) {
    PredictedAppIcon icon = (PredictedAppIcon) mHotseat.getChildAt(mHotseat.getCellXFromOrder(info.rank), mHotseat.getCellYFromOrder(info.rank));
    if (icon == null) {
        return;
    }
    WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo((WorkspaceItemInfo) info);
    mLauncher.getModelWriter().addItemToDatabase(workspaceItemInfo, LauncherSettings.Favorites.CONTAINER_HOTSEAT, workspaceItemInfo.screenId, workspaceItemInfo.cellX, workspaceItemInfo.cellY);
    ObjectAnimator.ofFloat(icon, SCALE_PROPERTY, 1, 0.8f, 1).start();
    icon.pin(workspaceItemInfo);
    mLauncher.getStatsLogManager().logger().withItemInfo(workspaceItemInfo).log(LAUNCHER_HOTSEAT_PREDICTION_PINNED);
}
Also used : PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 8 with SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY in project android_packages_apps_Launcher3 by AOSPA.

the class HotseatPredictionController method removePredictedApps.

private void removePredictedApps(List<PredictedAppIcon.PredictedIconOutlineDrawing> outlines, DropTarget.DragObject dragObject) {
    if (mIconRemoveAnimators != null) {
        mIconRemoveAnimators.end();
    }
    mIconRemoveAnimators = new AnimatorSet();
    removeOutlineDrawings();
    for (PredictedAppIcon icon : getPredictedIcons()) {
        if (!icon.isEnabled()) {
            continue;
        }
        if (dragObject.dragSource == this && icon.equals(dragObject.originalView)) {
            removeIconWithoutNotify(icon);
            continue;
        }
        int rank = ((WorkspaceItemInfo) icon.getTag()).rank;
        outlines.add(new PredictedAppIcon.PredictedIconOutlineDrawing(mHotseat.getCellXFromOrder(rank), mHotseat.getCellYFromOrder(rank), icon));
        icon.setEnabled(false);
        ObjectAnimator animator = ObjectAnimator.ofFloat(icon, SCALE_PROPERTY, 0);
        animator.addListener(new AnimationSuccessListener() {

            @Override
            public void onAnimationSuccess(Animator animator) {
                if (icon.getParent() != null) {
                    removeIconWithoutNotify(icon);
                }
            }
        });
        mIconRemoveAnimators.play(animator);
    }
    mIconRemoveAnimators.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) AnimatorSet(android.animation.AnimatorSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 9 with SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY in project android_packages_apps_Launcher3 by AOSPA.

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);
    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);
    Hotseat hotseat = mWorkspace.getHotseat();
    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);
    }
    mWorkspace.setPivotToScaleWithSelf(hotseat);
    float hotseatScale = hotseatScaleAndTranslation.scale;
    if (shouldSpring) {
        PendingAnimation pa = (PendingAnimation) propertySetter;
        pa.add(getSpringScaleAnimator(mLauncher, hotseat, hotseatScale));
    } else {
        Interpolator hotseatScaleInterpolator = config.getInterpolator(ANIM_HOTSEAT_SCALE, scaleInterpolator);
        propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale, hotseatScaleInterpolator);
    }
    float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
    propertySetter.setViewAlpha(hotseat, hotseatIconsAlpha, fadeInterpolator);
    float workspacePageIndicatorAlpha = (elements & WORKSPACE_PAGE_INDICATOR) != 0 ? 1 : 0;
    propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(), workspacePageIndicatorAlpha, fadeInterpolator);
    Interpolator translationInterpolator = 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);
    if (!config.hasAnimationFlag(SKIP_SCRIM)) {
        setScrim(propertySetter, state, config);
    }
}
Also used : ScaleAndTranslation(com.android.launcher3.LauncherState.ScaleAndTranslation) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PageAlphaProvider(com.android.launcher3.LauncherState.PageAlphaProvider) Interpolator(android.view.animation.Interpolator)

Example 10 with SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY 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)

Aggregations

Animator (android.animation.Animator)31 ObjectAnimator (android.animation.ObjectAnimator)31 AnimatorSet (android.animation.AnimatorSet)30 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)23 PredictedAppIcon (com.android.launcher3.uioverrides.PredictedAppIcon)22 BubbleTextView (com.android.launcher3.BubbleTextView)18 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)18 Rect (android.graphics.Rect)17 View (android.view.View)14 CellLayout (com.android.launcher3.CellLayout)14 Interpolator (android.view.animation.Interpolator)13 TimeInterpolator (android.animation.TimeInterpolator)12 AnimationSuccessListener (com.android.launcher3.anim.AnimationSuccessListener)11 PendingAnimation (com.android.launcher3.anim.PendingAnimation)10 Resources (android.content.res.Resources)9 SCALE_PROPERTY (com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY)9 List (java.util.List)9 DragLayer (com.android.launcher3.dragndrop.DragLayer)8 ItemInfo (com.android.launcher3.model.data.ItemInfo)8 ScaleAndTranslation (com.android.launcher3.LauncherState.ScaleAndTranslation)7