Search in sources :

Example 71 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.

the class StateManager method createAtomicAnimation.

/**
 * Creates an animation representing atomic transitions between the provided states
 */
public AnimatorSet createAtomicAnimation(STATE_TYPE fromState, STATE_TYPE toState, StateAnimationConfig config) {
    PendingAnimation builder = new PendingAnimation(config.duration);
    prepareForAtomicAnimation(fromState, toState, config);
    for (StateHandler handler : mActivity.getStateManager().getStateHandlers()) {
        handler.setStateWithAnimation(toState, config, builder);
    }
    return builder.buildAnim();
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation)

Example 72 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.

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 73 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.

the class TaskbarViewController method createIconAlignmentController.

/**
 * Creates an animation for aligning the taskbar icons with the provided Launcher device profile
 */
private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp) {
    mOnControllerPreCreateCallback.run();
    PendingAnimation setter = new PendingAnimation(100);
    Rect hotseatPadding = launcherDp.getHotseatLayoutPadding(mActivity);
    float scaleUp = ((float) launcherDp.iconSizePx) / mActivity.getDeviceProfile().iconSizePx;
    int hotseatCellSize = (launcherDp.availableWidthPx - hotseatPadding.left - hotseatPadding.right) / launcherDp.numShownHotseatIcons;
    int offsetY = launcherDp.getTaskbarOffsetY();
    setter.setFloat(mTaskbarIconTranslationYForHome, VALUE, -offsetY, LINEAR);
    setter.setFloat(mTaskbarNavButtonTranslationY, VALUE, -offsetY, LINEAR);
    int collapsedHeight = mActivity.getDefaultTaskbarWindowHeight();
    int expandedHeight = Math.max(collapsedHeight, mActivity.getDeviceProfile().taskbarSize + offsetY);
    setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowHeight(anim.getAnimatedFraction() > 0 ? expandedHeight : collapsedHeight));
    int count = mTaskbarView.getChildCount();
    for (int i = 0; i < count; i++) {
        View child = mTaskbarView.getChildAt(i);
        ItemInfo info = (ItemInfo) child.getTag();
        setter.setFloat(child, SCALE_PROPERTY, scaleUp, LINEAR);
        float childCenter = (child.getLeft() + child.getRight()) / 2;
        float hotseatIconCenter = hotseatPadding.left + hotseatCellSize * info.screenId + hotseatCellSize / 2;
        setter.setFloat(child, ICON_TRANSLATE_X, hotseatIconCenter - childCenter, LINEAR);
    }
    AnimatorPlaybackController controller = setter.createPlaybackController();
    mOnControllerPreCreateCallback = () -> controller.setPlayFraction(0);
    return controller;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) Rect(android.graphics.Rect) ItemInfo(com.android.launcher3.model.data.ItemInfo) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View)

Example 74 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.

the class RecentsViewStateController method handleSplitSelectionState.

/**
 * Create or dismiss split screen select animations.
 * @param builder if null then this will run the split select animations right away, otherwise
 *                will add animations to builder.
 */
private void handleSplitSelectionState(@NonNull LauncherState toState, @Nullable PendingAnimation builder) {
    LauncherState currentState = mLauncher.getStateManager().getState();
    boolean animate = builder != null;
    PagedOrientationHandler orientationHandler = ((RecentsView) mLauncher.getOverviewPanel()).getPagedOrientationHandler();
    Pair<FloatProperty, FloatProperty> taskViewsFloat = orientationHandler.getSplitSelectTaskOffset(TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION, mLauncher.getDeviceProfile());
    if (isSplitSelectionState(currentState, toState)) {
        // Animation to "dismiss" selected taskView
        PendingAnimation splitSelectInitAnimation = mRecentsView.createSplitSelectInitAnimation();
        // Add properties to shift remaining taskViews to get out of placeholder view
        splitSelectInitAnimation.setFloat(mRecentsView, taskViewsFloat.first, toState.getSplitSelectTranslation(mLauncher), LINEAR);
        splitSelectInitAnimation.setFloat(mRecentsView, taskViewsFloat.second, 0, LINEAR);
        if (!animate && isSplitSelectionState(currentState, toState)) {
            splitSelectInitAnimation.buildAnim().start();
        } else if (animate && isSplitSelectionState(currentState, toState)) {
            builder.add(splitSelectInitAnimation.buildAnim());
        }
    }
    if (isSplitSelectionState(currentState, toState)) {
        mRecentsView.applySplitPrimaryScrollOffset();
    } else {
        mRecentsView.resetSplitPrimaryScrollOffset();
    }
}
Also used : LauncherState(com.android.launcher3.LauncherState) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) LauncherRecentsView(com.android.quickstep.views.LauncherRecentsView) RecentsView(com.android.quickstep.views.RecentsView) FloatProperty(android.util.FloatProperty)

Example 75 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherActivityInterface method prepareRecentsUI.

@Override
public AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState, boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback) {
    notifyRecentsOfOrientation(deviceState.getRotationTouchHelper());
    DefaultAnimationFactory factory = new DefaultAnimationFactory(callback) {

        @Override
        protected void createBackgroundToOverviewAnim(BaseQuickstepLauncher activity, PendingAnimation pa) {
            super.createBackgroundToOverviewAnim(activity, pa);
            // Animate the blur and wallpaper zoom
            float fromDepthRatio = BACKGROUND_APP.getDepth(activity);
            float toDepthRatio = OVERVIEW.getDepth(activity);
            pa.addFloat(getDepthController(), new ClampedDepthProperty(fromDepthRatio, toDepthRatio), fromDepthRatio, toDepthRatio, LINEAR);
        }
    };
    BaseQuickstepLauncher launcher = factory.initUI();
    // Since all apps is not visible, we can safely reset the scroll position.
    // This ensures then the next swipe up to all-apps starts from scroll 0.
    launcher.getAppsView().reset(false);
    return factory;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) BaseQuickstepLauncher(com.android.launcher3.BaseQuickstepLauncher) ClampedDepthProperty(com.android.launcher3.statehandlers.DepthController.ClampedDepthProperty)

Aggregations

PendingAnimation (com.android.launcher3.anim.PendingAnimation)145 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)58 Animator (android.animation.Animator)46 AnimatorSet (android.animation.AnimatorSet)45 Rect (android.graphics.Rect)36 ValueAnimator (android.animation.ValueAnimator)34 Point (android.graphics.Point)32 TextPaint (android.text.TextPaint)32 ObjectAnimator (android.animation.ObjectAnimator)31 Context (android.content.Context)31 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)29 View (android.view.View)29 RecentsView (com.android.quickstep.views.RecentsView)29 DeviceProfile (com.android.launcher3.DeviceProfile)27 RectF (android.graphics.RectF)26 Interpolator (android.view.animation.Interpolator)26 PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)25 FloatProperty (android.util.FloatProperty)23 Matrix (android.graphics.Matrix)21 SpringProperty (com.android.launcher3.anim.SpringProperty)21