Search in sources :

Example 46 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Trebuchet by LineageOS.

the class NoButtonQuickSwitchTouchController method setupOverviewAnimators.

private void setupOverviewAnimators() {
    final LauncherState fromState = QUICK_SWITCH;
    final LauncherState toState = OVERVIEW;
    // Set RecentView's initial properties.
    RECENTS_SCALE_PROPERTY.set(mRecentsView, fromState.getOverviewScaleAndOffset(mLauncher)[0]);
    ADJACENT_PAGE_OFFSET.set(mRecentsView, 1f);
    mRecentsView.setContentAlpha(1);
    mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress());
    mLauncher.getActionsView().getVisibilityAlpha().setValue((fromState.getVisibleElements(mLauncher) & OVERVIEW_BUTTONS) != 0 ? 1f : 0f);
    float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher);
    // As we drag right, animate the following properties:
    // - RecentsView translationX
    // - OverviewScrim
    PendingAnimation xAnim = new PendingAnimation((long) (mXRange * 2));
    xAnim.setFloat(mRecentsView, ADJACENT_PAGE_OFFSET, scaleAndOffset[1], LINEAR);
    xAnim.setFloat(mLauncher.getDragLayer().getOverviewScrim(), OverviewScrim.SCRIM_PROGRESS, toState.getOverviewScrimAlpha(mLauncher), LINEAR);
    mXOverviewAnim = xAnim.createPlaybackController();
    mXOverviewAnim.dispatchOnStart();
    // As we drag up, animate the following properties:
    // - RecentsView scale
    // - RecentsView fullscreenProgress
    PendingAnimation yAnim = new PendingAnimation((long) (mYRange * 2));
    yAnim.setFloat(mRecentsView, RECENTS_SCALE_PROPERTY, scaleAndOffset[0], SCALE_DOWN_INTERPOLATOR);
    yAnim.setFloat(mRecentsView, FULLSCREEN_PROGRESS, toState.getOverviewFullscreenProgress(), SCALE_DOWN_INTERPOLATOR);
    AnimatorPlaybackController yNormalController = yAnim.createPlaybackController();
    AnimatorControllerWithResistance yAnimWithResistance = AnimatorControllerWithResistance.createForRecents(yNormalController, mLauncher, mRecentsView.getPagedViewOrientedState(), mLauncher.getDeviceProfile(), mRecentsView, RECENTS_SCALE_PROPERTY, mRecentsView, TASK_SECONDARY_TRANSLATION);
    mYOverviewAnim = new AnimatedFloat(() -> {
        if (mYOverviewAnim != null) {
            yAnimWithResistance.setProgress(mYOverviewAnim.value, mMaxYProgress);
        }
    });
    yNormalController.dispatchOnStart();
}
Also used : AnimatedFloat(com.android.quickstep.AnimatedFloat) LauncherState(com.android.launcher3.LauncherState) PendingAnimation(com.android.launcher3.anim.PendingAnimation) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) AnimatorControllerWithResistance(com.android.quickstep.util.AnimatorControllerWithResistance)

Example 47 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Trebuchet by LineageOS.

the class AnimatorControllerWithResistance method createRecentsResistanceAnim.

/**
 * Creates the resistance animation for {@link #createForRecents}, or can be used separately
 * when starting from recents, i.e. {@link #createRecentsResistanceFromOverviewAnim}.
 */
public static <SCALE, TRANSLATION> PendingAnimation createRecentsResistanceAnim(RecentsParams<SCALE, TRANSLATION> params) {
    Rect startRect = new Rect();
    PagedOrientationHandler orientationHandler = params.recentsOrientedState.getOrientationHandler();
    LauncherActivityInterface.INSTANCE.calculateTaskSize(params.context, params.dp, startRect, orientationHandler);
    long distanceToCover = startRect.bottom;
    boolean isTwoButtonMode = SysUINavigationMode.getMode(params.context) == TWO_BUTTONS;
    if (isTwoButtonMode) {
        // We can only drag a small distance past overview, not to the top of the screen.
        distanceToCover = (long) ((params.dp.heightPx - startRect.bottom) * TWO_BUTTON_EXTRA_DRAG_FACTOR);
    }
    PendingAnimation resistAnim = params.resistAnim != null ? params.resistAnim : new PendingAnimation(distanceToCover * 2);
    PointF pivot = new PointF();
    float fullscreenScale = params.recentsOrientedState.getFullScreenScaleAndPivot(startRect, params.dp, pivot);
    float prevScaleRate = (fullscreenScale - params.startScale) / (params.dp.heightPx - startRect.bottom);
    // This is what the scale would be at the end of the drag if we didn't apply resistance.
    float endScale = params.startScale - prevScaleRate * distanceToCover;
    final TimeInterpolator scaleInterpolator;
    if (isTwoButtonMode) {
        // We are bounded by the distance of the drag, so we don't need to apply resistance.
        scaleInterpolator = LINEAR;
    } else {
        // Create an interpolator that resists the scale so the scale doesn't get smaller than
        // RECENTS_SCALE_MAX_RESIST.
        float startResist = Utilities.getProgress(params.resistanceParams.scaleStartResist, params.startScale, endScale);
        float maxResist = Utilities.getProgress(params.resistanceParams.scaleMaxResist, params.startScale, endScale);
        scaleInterpolator = t -> {
            if (t < startResist) {
                return t;
            }
            float resistProgress = Utilities.getProgress(t, startResist, 1);
            resistProgress = RECENTS_SCALE_RESIST_INTERPOLATOR.getInterpolation(resistProgress);
            return startResist + resistProgress * (maxResist - startResist);
        };
    }
    resistAnim.addFloat(params.scaleTarget, params.scaleProperty, params.startScale, endScale, scaleInterpolator);
    if (!isTwoButtonMode) {
        // Compute where the task view would be based on the end scale, if we didn't translate.
        RectF endRectF = new RectF(startRect);
        Matrix temp = new Matrix();
        temp.setScale(params.resistanceParams.scaleMaxResist, params.resistanceParams.scaleMaxResist, pivot.x, pivot.y);
        temp.mapRect(endRectF);
        // Translate such that the task view touches the top of the screen when drag does.
        float endTranslation = endRectF.top * orientationHandler.getSecondaryTranslationDirectionFactor() * params.resistanceParams.translationFactor;
        resistAnim.addFloat(params.translationTarget, params.translationProperty, params.startTranslation, endTranslation, RECENTS_TRANSLATE_RESIST_INTERPOLATOR);
    }
    return resistAnim;
}
Also used : RectF(android.graphics.RectF) PendingAnimation(com.android.launcher3.anim.PendingAnimation) Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) PointF(android.graphics.PointF) TimeInterpolator(android.animation.TimeInterpolator)

Example 48 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project android_packages_apps_Trebuchet by LineageOS.

the class BaseRecentsViewStateController method setStateWithAnimationInternal.

/**
 * Core logic for animating the recents view UI.
 *
 * @param toState state to animate to
 * @param config current animation config
 * @param setter animator set builder
 */
void setStateWithAnimationInternal(@NonNull final LauncherState toState, @NonNull StateAnimationConfig config, @NonNull PendingAnimation setter) {
    float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher);
    setter.setFloat(mRecentsView, RECENTS_SCALE_PROPERTY, scaleAndOffset[0], config.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR));
    setter.setFloat(mRecentsView, ADJACENT_PAGE_OFFSET, scaleAndOffset[1], config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_X, LINEAR));
    setter.setFloat(mRecentsView, TASK_SECONDARY_TRANSLATION, 0f, config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR));
    setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0, config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
    OverviewScrim scrim = mLauncher.getDragLayer().getOverviewScrim();
    setter.setFloat(scrim, SCRIM_PROGRESS, toState.getOverviewScrimAlpha(mLauncher), config.getInterpolator(ANIM_OVERVIEW_SCRIM_FADE, LINEAR));
    setter.setFloat(scrim, SCRIM_MULTIPLIER, 1f, config.getInterpolator(ANIM_OVERVIEW_SCRIM_FADE, LINEAR));
    setter.setFloat(mRecentsView, getTaskModalnessProperty(), toState.getOverviewModalness(), config.getInterpolator(ANIM_OVERVIEW_MODAL, LINEAR));
}
Also used : OverviewScrim(com.android.launcher3.graphics.OverviewScrim)

Example 49 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project Neo-Launcher by NeoApplications.

the class RecentsView method runDismissAnimation.

private void runDismissAnimation(PendingAnimation pendingAnim) {
    AnimatorPlaybackController controller = AnimatorPlaybackController.wrap(pendingAnim.anim, DISMISS_TASK_DURATION);
    controller.dispatchOnStart();
    controller.setEndAction(() -> pendingAnim.finish(true, Touch.SWIPE));
    controller.getAnimationPlayer().setInterpolator(FAST_OUT_SLOW_IN);
    controller.start();
}
Also used : AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController)

Example 50 with PendingAnimation

use of com.android.launcher3.util.PendingAnimation in project Neo-Launcher by NeoApplications.

the class RecentsView method createTaskLauncherAnimation.

public PendingAnimation createTaskLauncherAnimation(TaskView tv, long duration) {
    if (FeatureFlags.IS_DOGFOOD_BUILD && mPendingAnimation != null) {
        throw new IllegalStateException("Another pending animation is still running");
    }
    int count = getTaskViewCount();
    if (count == 0) {
        return new PendingAnimation(new AnimatorSet());
    }
    int targetSysUiFlags = tv.getThumbnail().getSysUiStatusNavFlags();
    final boolean[] passedOverviewThreshold = new boolean[] { false };
    ValueAnimator progressAnim = ValueAnimator.ofFloat(0, 1);
    progressAnim.setInterpolator(LINEAR);
    progressAnim.addUpdateListener(animator -> {
        // Once we pass a certain threshold, update the sysui flags to match the target
        // tasks' flags
        mActivity.getSystemUiController().updateUiState(UI_STATE_OVERVIEW, animator.getAnimatedFraction() > UPDATE_SYSUI_FLAGS_THRESHOLD ? targetSysUiFlags : 0);
        onTaskLaunchAnimationUpdate(animator.getAnimatedFraction(), tv);
        // Passing the threshold from taskview to fullscreen app will vibrate
        final boolean passed = animator.getAnimatedFraction() >= SUCCESS_TRANSITION_PROGRESS;
        if (passed != passedOverviewThreshold[0]) {
            passedOverviewThreshold[0] = passed;
            performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
        }
    });
    ClipAnimationHelper clipAnimationHelper = new ClipAnimationHelper(mActivity);
    clipAnimationHelper.fromTaskThumbnailView(tv.getThumbnail(), this);
    clipAnimationHelper.prepareAnimation(mActivity.getDeviceProfile(), true);
    AnimatorSet anim = createAdjacentPageAnimForTaskLaunch(tv, clipAnimationHelper);
    anim.play(progressAnim);
    anim.setDuration(duration);
    Consumer<Boolean> onTaskLaunchFinish = this::onTaskLaunched;
    mPendingAnimation = new PendingAnimation(anim);
    mPendingAnimation.addEndListener((onEndListener) -> {
        if (onEndListener.isSuccess) {
            Consumer<Boolean> onLaunchResult = (result) -> {
                onTaskLaunchFinish.accept(result);
                if (!result) {
                    tv.notifyTaskLaunchFailed(TAG);
                }
            };
            tv.launchTask(false, onLaunchResult, getHandler());
            Task task = tv.getTask();
            if (task != null) {
                mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(onEndListener.logAction, Direction.DOWN, indexOfChild(tv), TaskUtils.getLaunchComponentKeyForTask(task.key));
            }
        } else {
            onTaskLaunchFinish.accept(false);
        }
        mPendingAnimation = null;
    });
    return mPendingAnimation;
}
Also used : SyncRtSurfaceTransactionApplierCompat(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat) Drawable(android.graphics.drawable.Drawable) LayoutTransition(android.animation.LayoutTransition) Handler(android.os.Handler) TAP(com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP) Canvas(android.graphics.Canvas) AccessibilityEvent(android.view.accessibility.AccessibilityEvent) PendingAnimation(com.android.launcher3.util.PendingAnimation) SCALE_PROPERTY(com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY) RotationMode(com.android.launcher3.graphics.RotationMode) TargetApi(android.annotation.TargetApi) CLEAR_ALL_BUTTON(com.android.launcher3.userevent.nano.LauncherLogProto.ControlType.CLEAR_ALL_BUTTON) RecentsAnimationWrapper(com.android.quickstep.RecentsAnimationWrapper) DeviceProfile(com.android.launcher3.DeviceProfile) HapticFeedbackConstants(android.view.HapticFeedbackConstants) Nullable(androidx.annotation.Nullable) Layout(android.text.Layout) TextPaint(android.text.TextPaint) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) TimeInterpolator(android.animation.TimeInterpolator) Insettable(com.android.launcher3.Insettable) Utilities.squaredTouchSlop(com.android.launcher3.Utilities.squaredTouchSlop) ArrayList(java.util.ArrayList) TaskUtils.checkCurrentOrManagedUserId(com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId) ComponentName(android.content.ComponentName) ViewPool(com.android.launcher3.util.ViewPool) ViewDebug(android.view.ViewDebug) FeatureFlags(com.android.launcher3.config.FeatureFlags) Direction(com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) SparseBooleanArray(android.util.SparseBooleanArray) R(com.android.launcher3.R) ComponentKey(com.android.launcher3.util.ComponentKey) MIN_VISIBLE_CHANGE_PIXELS(androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_PIXELS) ValueAnimator(android.animation.ValueAnimator) ACCEL(com.android.launcher3.anim.Interpolators.ACCEL) UI_STATE_OVERVIEW(com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW) Rect(android.graphics.Rect) PackageManagerWrapper(com.android.systemui.shared.system.PackageManagerWrapper) Task(com.android.systemui.shared.recents.model.Task) Animator(android.animation.Animator) FloatProperty(android.util.FloatProperty) QUICKSTEP_SPRINGS(com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS) AttributeSet(android.util.AttributeSet) ActivityManagerWrapper(com.android.systemui.shared.system.ActivityManagerWrapper) View(android.view.View) Matrix(android.graphics.Matrix) LauncherEventUtil(com.android.systemui.shared.system.LauncherEventUtil) RectF(android.graphics.RectF) Utilities(com.android.launcher3.Utilities) SpringForce(androidx.dynamicanimation.animation.SpringForce) TransitionListener(android.animation.LayoutTransition.TransitionListener) UI_HELPER_EXECUTOR(com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR) ObjectAnimator(android.animation.ObjectAnimator) EDGE_NAV_BAR(com.android.launcher3.Utilities.EDGE_NAV_BAR) TaskUtils(com.android.quickstep.TaskUtils) TaskStackChangeListener(com.android.systemui.shared.system.TaskStackChangeListener) ViewGroup(android.view.ViewGroup) WindowInsets(android.view.WindowInsets) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData) TaskThumbnailChangeListener(com.android.quickstep.RecentsModel.TaskThumbnailChangeListener) ListView(android.widget.ListView) Themes(com.android.launcher3.util.Themes) SUCCESS_TRANSITION_PROGRESS(com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController.SUCCESS_TRANSITION_PROGRESS) Typeface(android.graphics.Typeface) ActivityManager(android.app.ActivityManager) Context(android.content.Context) StaticLayout(android.text.StaticLayout) AccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo) TaskThumbnailCache(com.android.quickstep.TaskThumbnailCache) CHANGE_FLAG_ICON_PARAMS(com.android.launcher3.InvariantDeviceProfile.CHANGE_FLAG_ICON_PARAMS) KeyEvent(android.view.KeyEvent) Touch(com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch) STATE_HANDLER_INVISIBILITY_FLAGS(com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS) Intent(android.content.Intent) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) SpringObjectAnimator(com.android.launcher3.anim.SpringObjectAnimator) FAST_OUT_SLOW_IN(com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN) Utilities.squaredHypot(com.android.launcher3.Utilities.squaredHypot) MotionEvent(android.view.MotionEvent) BaseActivity(com.android.launcher3.BaseActivity) ENABLE_QUICKSTEP_LIVE_TILE(com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE) AnimatorSet(android.animation.AnimatorSet) Build(android.os.Build) OverScroller(com.android.launcher3.util.OverScroller) LayoutInflater(android.view.LayoutInflater) VIEW_TRANSLATE_Y(com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y) VIEW_TRANSLATE_X(com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X) ClipAnimationHelper(com.android.quickstep.util.ClipAnimationHelper) Point(android.graphics.Point) ACCEL_2(com.android.launcher3.anim.Interpolators.ACCEL_2) LauncherState(com.android.launcher3.LauncherState) Consumer(java.util.function.Consumer) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) PropertyListBuilder(com.android.launcher3.anim.PropertyListBuilder) RecentsModel(com.android.quickstep.RecentsModel) PagedView(com.android.launcher3.PagedView) PendingAnimation(com.android.launcher3.util.PendingAnimation) ClipAnimationHelper(com.android.quickstep.util.ClipAnimationHelper) Task(com.android.systemui.shared.recents.model.Task) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

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