Search in sources :

Example 6 with SyncRtSurfaceTransactionApplierCompat

use of com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat in project Neo-Launcher by NeoApplications.

the class AppToOverviewAnimationProvider method createWindowAnimation.

/**
 * Create remote window animation from the currently running app to the overview panel.
 *
 * @param targetCompats the target apps
 * @return animation from app to overview
 */
@Override
public AnimatorSet createWindowAnimation(RemoteAnimationTargetCompat[] targetCompats) {
    if (mRecentsView != null) {
        mRecentsView.setRunningTaskIconScaledDown(true);
    }
    AnimatorSet anim = new AnimatorSet();
    anim.addListener(new AnimationSuccessListener() {

        @Override
        public void onAnimationSuccess(Animator animator) {
            mHelper.onSwipeUpToRecentsComplete(mActivity);
            if (mRecentsView != null) {
                mRecentsView.animateUpRunningTaskIconScale();
            }
        }
    });
    if (mActivity == null) {
        Log.e(TAG, "Animation created, before activity");
        anim.play(ValueAnimator.ofInt(0, 1).setDuration(RECENTS_LAUNCH_DURATION));
        return anim;
    }
    RemoteAnimationTargetSet targetSet = new RemoteAnimationTargetSet(targetCompats, MODE_CLOSING);
    // Use the top closing app to determine the insets for the animation
    RemoteAnimationTargetCompat runningTaskTarget = targetSet.findTask(mTargetTaskId);
    if (runningTaskTarget == null) {
        Log.e(TAG, "No closing app");
        anim.play(ValueAnimator.ofInt(0, 1).setDuration(RECENTS_LAUNCH_DURATION));
        return anim;
    }
    final ClipAnimationHelper clipHelper = new ClipAnimationHelper(mActivity);
    // At this point, the activity is already started and laid-out. Get the home-bounds
    // relative to the screen using the rootView of the activity.
    int[] loc = new int[2];
    View rootView = mActivity.getRootView();
    rootView.getLocationOnScreen(loc);
    Rect homeBounds = new Rect(loc[0], loc[1], loc[0] + rootView.getWidth(), loc[1] + rootView.getHeight());
    clipHelper.updateSource(homeBounds, runningTaskTarget);
    Rect targetRect = new Rect();
    mHelper.getSwipeUpDestinationAndLength(mActivity.getDeviceProfile(), mActivity, targetRect);
    clipHelper.updateTargetRect(targetRect);
    clipHelper.prepareAnimation(mActivity.getDeviceProfile(), false);
    ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams().setSyncTransactionApplier(new SyncRtSurfaceTransactionApplierCompat(rootView));
    ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
    valueAnimator.setDuration(RECENTS_LAUNCH_DURATION);
    valueAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
    valueAnimator.addUpdateListener((v) -> {
        params.setProgress((float) v.getAnimatedValue());
        clipHelper.applyTransform(targetSet, params);
    });
    if (targetSet.isAnimatingHome()) {
        // If we are animating home, fade in the opening targets
        RemoteAnimationTargetSet openingSet = new RemoteAnimationTargetSet(targetCompats, MODE_OPENING);
        TransactionCompat transaction = new TransactionCompat();
        valueAnimator.addUpdateListener((v) -> {
            for (RemoteAnimationTargetCompat app : openingSet.apps) {
                transaction.setAlpha(app.leash, (float) v.getAnimatedValue());
            }
            transaction.apply();
        });
    }
    anim.play(valueAnimator);
    return anim;
}
Also used : SyncRtSurfaceTransactionApplierCompat(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat) Rect(android.graphics.Rect) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) AnimatorSet(android.animation.AnimatorSet) TransactionCompat(com.android.systemui.shared.system.TransactionCompat) ValueAnimator(android.animation.ValueAnimator) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) RemoteAnimationTargetSet(com.android.quickstep.util.RemoteAnimationTargetSet) ClipAnimationHelper(com.android.quickstep.util.ClipAnimationHelper) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Aggregations

SyncRtSurfaceTransactionApplierCompat (com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat)6 ValueAnimator (android.animation.ValueAnimator)5 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)5 Animator (android.animation.Animator)4 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 MultiValueUpdateListener (com.android.quickstep.util.MultiValueUpdateListener)3 RemoteAnimationTargetSet (com.android.quickstep.util.RemoteAnimationTargetSet)3 SurfaceParams (com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams)3 ObjectAnimator (android.animation.ObjectAnimator)2 Matrix (android.graphics.Matrix)2 Rect (android.graphics.Rect)2 RectF (android.graphics.RectF)2 View (android.view.View)2 ClipAnimationHelper (com.android.quickstep.util.ClipAnimationHelper)2 RecentsView (com.android.quickstep.views.RecentsView)2 AnimatorSet (android.animation.AnimatorSet)1 ComponentName (android.content.ComponentName)1 Drawable (android.graphics.drawable.Drawable)1 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)1 BaseActivity (com.android.launcher3.BaseActivity)1