Search in sources :

Example 11 with SUCCESS_TRANSITION_PROGRESS

use of com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS in project android_packages_apps_Trebuchet by LineageOS.

the class TaskViewTouchController method onDragEnd.

@Override
public void onDragEnd(float velocity) {
    boolean fling = mDetector.isFling(velocity);
    final boolean goingToEnd;
    final int logAction;
    boolean blockedFling = fling && mFlingBlockCheck.isBlocked();
    if (blockedFling) {
        fling = false;
    }
    PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
    float progress = mCurrentAnimation.getProgressFraction();
    float interpolatedProgress = mCurrentAnimation.getInterpolatedProgress();
    if (fling) {
        logAction = Touch.FLING;
        boolean goingUp = orientationHandler.isGoingUp(velocity, mIsRtl);
        goingToEnd = goingUp == mCurrentAnimationIsGoingUp;
    } else {
        logAction = Touch.SWIPE;
        goingToEnd = interpolatedProgress > SUCCESS_TRANSITION_PROGRESS;
    }
    long animationDuration = BaseSwipeDetector.calculateDuration(velocity, goingToEnd ? (1 - progress) : progress);
    if (blockedFling && !goingToEnd) {
        animationDuration *= LauncherAnimUtils.blockedFlingDurationFactor(velocity);
    }
    mCurrentAnimation.setEndAction(() -> onCurrentAnimationEnd(goingToEnd, logAction));
    if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
        mCurrentAnimation.getAnimationPlayer().addUpdateListener(valueAnimator -> {
            if (mRecentsView.getCurrentPage() != 0 || mCurrentAnimationIsGoingUp) {
                mRecentsView.redrawLiveTile(true);
            }
        });
    }
    mCurrentAnimation.startWithVelocity(mActivity, goingToEnd, velocity, mEndDisplacement, animationDuration);
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Example 12 with SUCCESS_TRANSITION_PROGRESS

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

Example 13 with SUCCESS_TRANSITION_PROGRESS

use of com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS in project android_packages_apps_Launcher3 by ArrowOS.

the class TaskViewTouchController method reInitAnimationController.

private void reInitAnimationController(boolean goingUp) {
    if (mCurrentAnimation != null && mCurrentAnimationIsGoingUp == goingUp) {
        // No need to init
        return;
    }
    if ((goingUp && !mAllowGoingUp) || (!goingUp && !mAllowGoingDown)) {
        // Trying to re-init in an unsupported direction.
        return;
    }
    if (mCurrentAnimation != null) {
        mCurrentAnimation.setPlayFraction(0);
        mCurrentAnimation.getTarget().removeListener(this);
        mCurrentAnimation.dispatchOnCancel();
    }
    PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
    mCurrentAnimationIsGoingUp = goingUp;
    BaseDragLayer dl = mActivity.getDragLayer();
    final int secondaryLayerDimension = orientationHandler.getSecondaryDimension(dl);
    long maxDuration = 2 * secondaryLayerDimension;
    int verticalFactor = orientationHandler.getTaskDragDisplacementFactor(mIsRtl);
    int secondaryTaskDimension = orientationHandler.getSecondaryDimension(mTaskBeingDragged);
    // The interpolator controlling the most prominent visual movement. We use this to determine
    // whether we passed SUCCESS_TRANSITION_PROGRESS.
    final Interpolator currentInterpolator;
    PendingAnimation pa;
    if (goingUp) {
        currentInterpolator = Interpolators.LINEAR;
        pa = mRecentsView.createTaskDismissAnimation(mTaskBeingDragged, true, /* animateTaskView */
        true, /* removeTask */
        maxDuration, false);
        mEndDisplacement = -secondaryTaskDimension;
    } else {
        currentInterpolator = Interpolators.ZOOM_IN;
        pa = mRecentsView.createTaskLaunchAnimation(mTaskBeingDragged, maxDuration, currentInterpolator);
        // Since the thumbnail is what is filling the screen, based the end displacement on it.
        View thumbnailView = mTaskBeingDragged.getThumbnail();
        mTempCords[1] = orientationHandler.getSecondaryDimension(thumbnailView);
        dl.getDescendantCoordRelativeToSelf(thumbnailView, mTempCords);
        mEndDisplacement = secondaryLayerDimension - mTempCords[1];
    }
    mEndDisplacement *= verticalFactor;
    mCurrentAnimation = pa.createPlaybackController();
    // Setting this interpolator doesn't affect the visual motion, but is used to determine
    // whether we successfully reached the target state in onDragEnd().
    mCurrentAnimation.getTarget().setInterpolator(currentInterpolator);
    onUserControlledAnimationCreated(mCurrentAnimation);
    mCurrentAnimation.getTarget().addListener(this);
    mCurrentAnimation.dispatchOnStart();
    mProgressMultiplier = 1 / mEndDisplacement;
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler) Interpolator(android.view.animation.Interpolator) TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 14 with SUCCESS_TRANSITION_PROGRESS

use of com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS in project android_packages_apps_Launcher3 by ArrowOS.

the class RecentsView method createTaskLaunchAnimation.

public PendingAnimation createTaskLaunchAnimation(TaskView tv, long duration, Interpolator interpolator) {
    if (FeatureFlags.IS_STUDIO_BUILD && mPendingAnimation != null) {
        throw new IllegalStateException("Another pending animation is still running");
    }
    int count = getTaskViewCount();
    if (count == 0) {
        return new PendingAnimation(duration);
    }
    // When swiping down from overview to tasks, ensures the snapped page's scroll maintain
    // invariant between quick switch and overview, to ensure a smooth animation transition.
    updateGridProperties();
    updateScrollSynchronously();
    int targetSysUiFlags = tv.getThumbnail().getSysUiStatusNavFlags();
    final boolean[] passedOverviewThreshold = new boolean[] { false };
    ValueAnimator progressAnim = ValueAnimator.ofFloat(0, 1);
    progressAnim.addUpdateListener(animator -> {
        // tasks' flags
        if (animator.getAnimatedFraction() > UPDATE_SYSUI_FLAGS_THRESHOLD) {
            mActivity.getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, targetSysUiFlags);
        } else {
            mActivity.getSystemUiController().updateUiState(UI_STATE_FULLSCREEN_TASK, 0);
        }
        // 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);
        }
    });
    AnimatorSet anim = createAdjacentPageAnimForTaskLaunch(tv);
    DepthController depthController = getDepthController();
    if (depthController != null) {
        ObjectAnimator depthAnimator = ObjectAnimator.ofFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(mActivity));
        anim.play(depthAnimator);
    }
    anim.play(progressAnim);
    anim.setInterpolator(interpolator);
    mPendingAnimation = new PendingAnimation(duration);
    mPendingAnimation.add(anim);
    if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
        runActionOnRemoteHandles(remoteTargetHandle -> remoteTargetHandle.getTaskViewSimulator().addOverviewToAppAnim(mPendingAnimation, interpolator));
        mPendingAnimation.addOnFrameCallback(this::redrawLiveTile);
    }
    mPendingAnimation.addEndListener(isSuccess -> {
        if (isSuccess) {
            if (tv.getTaskIds()[1] != -1) {
                // TODO(b/194414938): make this part of the animations instead.
                TaskViewUtils.setSplitAuxiliarySurfacesShown(mRemoteTargetHandles[0].getTransformParams().getTargetSet().nonApps, true, /*shown*/
                false);
            }
            if (ENABLE_QUICKSTEP_LIVE_TILE.get() && tv.isRunningTask()) {
                finishRecentsAnimation(false, /* toRecents */
                null);
                onTaskLaunchAnimationEnd(true);
            } else {
                tv.launchTask(this::onTaskLaunchAnimationEnd);
            }
            Task task = tv.getTask();
            if (task != null) {
                mActivity.getStatsLogManager().logger().withItemInfo(tv.getItemInfo()).log(LAUNCHER_TASK_LAUNCH_SWIPE_DOWN);
            }
        } else {
            onTaskLaunchAnimationEnd(false);
        }
        mPendingAnimation = null;
    });
    return mPendingAnimation;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) Task(com.android.systemui.shared.recents.model.Task) GroupTask(com.android.quickstep.util.GroupTask) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) DepthController(com.android.launcher3.statehandlers.DepthController) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 15 with SUCCESS_TRANSITION_PROGRESS

use of com.android.launcher3.LauncherAnimUtils.SUCCESS_TRANSITION_PROGRESS in project android_packages_apps_Launcher3 by ProtonAOSP.

the class TaskViewTouchController method onDragEnd.

@Override
public void onDragEnd(float velocity) {
    if (mOverrideVelocity != null) {
        velocity = mOverrideVelocity;
        mOverrideVelocity = null;
    }
    // Limit velocity, as very large scalar values make animations play too quickly
    float maxTaskDismissDragVelocity = mTaskBeingDragged.getResources().getDimension(R.dimen.max_task_dismiss_drag_velocity);
    velocity = Utilities.boundToRange(velocity, -maxTaskDismissDragVelocity, maxTaskDismissDragVelocity);
    boolean fling = mDetector.isFling(velocity);
    final boolean goingToEnd;
    boolean blockedFling = fling && mFlingBlockCheck.isBlocked();
    if (blockedFling) {
        fling = false;
    }
    PagedOrientationHandler orientationHandler = mRecentsView.getPagedOrientationHandler();
    boolean goingUp = orientationHandler.isGoingUp(velocity, mIsRtl);
    float progress = mCurrentAnimation.getProgressFraction();
    float interpolatedProgress = mCurrentAnimation.getInterpolatedProgress();
    if (fling) {
        goingToEnd = goingUp == mCurrentAnimationIsGoingUp;
    } else {
        goingToEnd = interpolatedProgress > SUCCESS_TRANSITION_PROGRESS;
    }
    long animationDuration = BaseSwipeDetector.calculateDuration(velocity, goingToEnd ? (1 - progress) : progress);
    if (blockedFling && !goingToEnd) {
        animationDuration *= LauncherAnimUtils.blockedFlingDurationFactor(velocity);
    }
    // Due to very high or low velocity dismissals, animation durations can be inconsistently
    // long or short. Bound the duration for animation of task translations for a more
    // standardized feel.
    animationDuration = Utilities.boundToRange(animationDuration, MIN_TASK_DISMISS_ANIMATION_DURATION, MAX_TASK_DISMISS_ANIMATION_DURATION);
    mCurrentAnimation.setEndAction(this::clearState);
    mCurrentAnimation.startWithVelocity(mActivity, goingToEnd, velocity * orientationHandler.getSecondaryTranslationDirectionFactor(), mEndDisplacement, animationDuration);
    if (goingUp && goingToEnd && !mIsDismissHapticRunning) {
        VibratorWrapper.INSTANCE.get(mActivity).vibrate(TASK_DISMISS_VIBRATION_PRIMITIVE, TASK_DISMISS_VIBRATION_PRIMITIVE_SCALE, TASK_DISMISS_VIBRATION_FALLBACK);
        mIsDismissHapticRunning = true;
    }
}
Also used : PagedOrientationHandler(com.android.launcher3.touch.PagedOrientationHandler)

Aggregations

ValueAnimator (android.animation.ValueAnimator)21 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)13 PagedOrientationHandler (com.android.launcher3.touch.PagedOrientationHandler)13 RecentsView (com.android.quickstep.views.RecentsView)12 PendingAnimation (com.android.launcher3.anim.PendingAnimation)11 LauncherState (com.android.launcher3.LauncherState)9 ObjectAnimator (android.animation.ObjectAnimator)8 View (android.view.View)8 AnimatorSet (android.animation.AnimatorSet)7 Point (android.graphics.Point)7 TextPaint (android.text.TextPaint)7 Interpolator (android.view.animation.Interpolator)7 Task (com.android.systemui.shared.recents.model.Task)7 DepthController (com.android.launcher3.statehandlers.DepthController)6 BaseDragLayer (com.android.launcher3.views.BaseDragLayer)6 OverviewToHomeAnim (com.android.quickstep.util.OverviewToHomeAnim)6 TaskView (com.android.quickstep.views.TaskView)6 LayoutTransition (android.animation.LayoutTransition)2 TransitionListener (android.animation.LayoutTransition.TransitionListener)2 TargetApi (android.annotation.TargetApi)2