Search in sources :

Example 1 with SyncRtSurfaceTransactionApplierCompat

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

the class TaskViewUtils method getRecentsWindowAnimator.

/**
 * @return Animator that controls the window of the opening targets for the recents launch
 * animation.
 */
public static ValueAnimator getRecentsWindowAnimator(TaskView v, boolean skipViewChanges, RemoteAnimationTargetCompat[] targets, final ClipAnimationHelper inOutHelper) {
    SyncRtSurfaceTransactionApplierCompat applier = new SyncRtSurfaceTransactionApplierCompat(v);
    ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams().setSyncTransactionApplier(applier);
    final RemoteAnimationTargetSet targetSet = new RemoteAnimationTargetSet(targets, MODE_OPENING);
    targetSet.addDependentTransactionApplier(applier);
    final RecentsView recentsView = v.getRecentsView();
    final ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
    appAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
    appAnimator.addUpdateListener(new MultiValueUpdateListener() {

        // Defer fading out the view until after the app window gets faded in
        final FloatProp mViewAlpha = new FloatProp(1f, 0f, 75, 75, LINEAR);

        final FloatProp mTaskAlpha = new FloatProp(0f, 1f, 0, 75, LINEAR);

        final RectF mThumbnailRect;

        {
            inOutHelper.setTaskAlphaCallback((t, alpha) -> mTaskAlpha.value);
            inOutHelper.prepareAnimation(BaseActivity.fromContext(v.getContext()).getDeviceProfile(), true);
            inOutHelper.fromTaskThumbnailView(v.getThumbnail(), (RecentsView) v.getParent(), targetSet.apps.length == 0 ? null : targetSet.apps[0]);
            mThumbnailRect = new RectF(inOutHelper.getTargetRect());
            mThumbnailRect.offset(-v.getTranslationX(), -v.getTranslationY());
            Utilities.scaleRectFAboutCenter(mThumbnailRect, 1 / v.getScaleX());
        }

        @Override
        public void onUpdate(float percent) {
            // TODO: Take into account the current fullscreen progress for animating the insets
            params.setProgress(1 - percent);
            RectF taskBounds = inOutHelper.applyTransform(targetSet, params);
            int taskIndex = recentsView.indexOfChild(v);
            int centerTaskIndex = recentsView.getCurrentPage();
            boolean parallaxCenterAndAdjacentTask = taskIndex != centerTaskIndex;
            if (!skipViewChanges && parallaxCenterAndAdjacentTask) {
                float scale = taskBounds.width() / mThumbnailRect.width();
                v.setScaleX(scale);
                v.setScaleY(scale);
                v.setTranslationX(taskBounds.centerX() - mThumbnailRect.centerX());
                v.setTranslationY(taskBounds.centerY() - mThumbnailRect.centerY());
                v.setAlpha(mViewAlpha.value);
            }
        }
    });
    appAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            targetSet.release();
        }
    });
    return appAnimator;
}
Also used : SyncRtSurfaceTransactionApplierCompat(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat) RectF(android.graphics.RectF) Utilities(com.android.launcher3.Utilities) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) SyncRtSurfaceTransactionApplierCompat(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat) Task(com.android.systemui.shared.recents.model.Task) RemoteAnimationTargetSet(com.android.quickstep.util.RemoteAnimationTargetSet) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) ComponentName(android.content.ComponentName) ItemInfo(com.android.launcher3.ItemInfo) ClipAnimationHelper(com.android.quickstep.util.ClipAnimationHelper) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) TaskView(com.android.quickstep.views.TaskView) TOUCH_RESPONSE_INTERPOLATOR(com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR) MODE_OPENING(com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING) BaseActivity(com.android.launcher3.BaseActivity) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) ValueAnimator(android.animation.ValueAnimator) ValueAnimator(android.animation.ValueAnimator) RemoteAnimationTargetSet(com.android.quickstep.util.RemoteAnimationTargetSet) RectF(android.graphics.RectF) ClipAnimationHelper(com.android.quickstep.util.ClipAnimationHelper) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) RecentsView(com.android.quickstep.views.RecentsView)

Example 2 with SyncRtSurfaceTransactionApplierCompat

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

the class RecentsView method onAttachedToWindow.

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    updateTaskStackListenerState();
    if (Utilities.isRecentsEnabled()) {
        mModel.getThumbnailCache().getHighResLoadingState().addCallback(this);
        mActivity.addMultiWindowModeChangedListener(mMultiWindowModeChangedListener);
        try {
            ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
            mSyncTransactionApplier = new SyncRtSurfaceTransactionApplierCompat(this);
        } catch (NoSuchMethodError error) {
            error.printStackTrace();
        }
    }
    RecentsModel.INSTANCE.get(getContext()).addThumbnailChangeListener(this);
    mIdp.addOnChangeListener(this);
}
Also used : SyncRtSurfaceTransactionApplierCompat(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat)

Example 3 with SyncRtSurfaceTransactionApplierCompat

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

the class QuickstepAppTransitionManagerImpl method getOpeningWindowAnimators.

/**
 * @return Animator that controls the window of the opening targets.
 */
private ValueAnimator getOpeningWindowAnimators(View v, RemoteAnimationTargetCompat[] targets, Rect windowTargetBounds, boolean toggleVisibility) {
    RectF bounds = new RectF();
    FloatingIconView floatingView = FloatingIconView.getFloatingIconView(mLauncher, v, toggleVisibility, bounds, true);
    Rect crop = new Rect();
    Matrix matrix = new Matrix();
    RemoteAnimationTargetSet openingTargets = new RemoteAnimationTargetSet(targets, MODE_OPENING);
    SyncRtSurfaceTransactionApplierCompat surfaceApplier = new SyncRtSurfaceTransactionApplierCompat(floatingView);
    openingTargets.addDependentTransactionApplier(surfaceApplier);
    // Scale the app icon to take up the entire screen. This simplifies the math when
    // animating the app window position / scale.
    float smallestSize = Math.min(windowTargetBounds.height(), windowTargetBounds.width());
    float maxScaleX = smallestSize / bounds.width();
    float maxScaleY = smallestSize / bounds.height();
    float scale = Math.max(maxScaleX, maxScaleY);
    float startScale = 1f;
    if (v instanceof BubbleTextView && !(v.getParent() instanceof DeepShortcutView)) {
        Drawable dr = ((BubbleTextView) v).getIcon();
        if (dr instanceof FastBitmapDrawable) {
            startScale = ((FastBitmapDrawable) dr).getAnimatedScale();
        }
    }
    final float initialStartScale = startScale;
    int[] dragLayerBounds = new int[2];
    mDragLayer.getLocationOnScreen(dragLayerBounds);
    // Animate the app icon to the center of the window bounds in screen coordinates.
    float centerX = windowTargetBounds.centerX() - dragLayerBounds[0];
    float centerY = windowTargetBounds.centerY() - dragLayerBounds[1];
    float dX = centerX - bounds.centerX();
    float dY = centerY - bounds.centerY();
    boolean useUpwardAnimation = bounds.top > centerY || Math.abs(dY) < mLauncher.getDeviceProfile().cellHeightPx;
    final long xDuration = useUpwardAnimation ? APP_LAUNCH_CURVED_DURATION : APP_LAUNCH_DOWN_DURATION;
    final long yDuration = useUpwardAnimation ? APP_LAUNCH_DURATION : APP_LAUNCH_DOWN_CURVED_DURATION;
    final long alphaDuration = useUpwardAnimation ? APP_LAUNCH_ALPHA_DURATION : APP_LAUNCH_ALPHA_DOWN_DURATION;
    RectF targetBounds = new RectF(windowTargetBounds);
    RectF currentBounds = new RectF();
    RectF temp = new RectF();
    ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
    appAnimator.setDuration(APP_LAUNCH_DURATION);
    appAnimator.setInterpolator(LINEAR);
    appAnimator.addListener(floatingView);
    appAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (v instanceof BubbleTextView) {
                ((BubbleTextView) v).setStayPressed(false);
            }
            openingTargets.release();
        }
    });
    float shapeRevealDuration = APP_LAUNCH_DURATION * SHAPE_PROGRESS_DURATION;
    final float startCrop;
    final float endCrop;
    if (mDeviceProfile.isVerticalBarLayout()) {
        startCrop = windowTargetBounds.height();
        endCrop = windowTargetBounds.width();
    } else {
        startCrop = windowTargetBounds.width();
        endCrop = windowTargetBounds.height();
    }
    final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources()) ? startCrop / 2f : 0f;
    final float windowRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher.getResources());
    appAnimator.addUpdateListener(new MultiValueUpdateListener() {

        FloatProp mDx = new FloatProp(0, dX, 0, xDuration, AGGRESSIVE_EASE);

        FloatProp mDy = new FloatProp(0, dY, 0, yDuration, AGGRESSIVE_EASE);

        FloatProp mIconScale = new FloatProp(initialStartScale, scale, 0, APP_LAUNCH_DURATION, EXAGGERATED_EASE);

        FloatProp mIconAlpha = new FloatProp(1f, 0f, APP_LAUNCH_ALPHA_START_DELAY, alphaDuration, LINEAR);

        FloatProp mCroppedSize = new FloatProp(startCrop, endCrop, 0, CROP_DURATION, EXAGGERATED_EASE);

        FloatProp mWindowRadius = new FloatProp(initialWindowRadius, windowRadius, 0, RADIUS_DURATION, EXAGGERATED_EASE);

        @Override
        public void onUpdate(float percent) {
            // Calculate app icon size.
            float iconWidth = bounds.width() * mIconScale.value;
            float iconHeight = bounds.height() * mIconScale.value;
            // Animate the window crop so that it starts off as a square.
            final int windowWidth;
            final int windowHeight;
            if (mDeviceProfile.isVerticalBarLayout()) {
                windowWidth = (int) mCroppedSize.value;
                windowHeight = windowTargetBounds.height();
            } else {
                windowWidth = windowTargetBounds.width();
                windowHeight = (int) mCroppedSize.value;
            }
            crop.set(0, 0, windowWidth, windowHeight);
            // Scale the app window to match the icon size.
            float scaleX = iconWidth / windowWidth;
            float scaleY = iconHeight / windowHeight;
            float scale = Math.min(1f, Math.max(scaleX, scaleY));
            float scaledWindowWidth = windowWidth * scale;
            float scaledWindowHeight = windowHeight * scale;
            float offsetX = (scaledWindowWidth - iconWidth) / 2;
            float offsetY = (scaledWindowHeight - iconHeight) / 2;
            // Calculate the window position
            temp.set(bounds);
            temp.offset(dragLayerBounds[0], dragLayerBounds[1]);
            temp.offset(mDx.value, mDy.value);
            Utilities.scaleRectFAboutCenter(temp, mIconScale.value);
            float transX0 = temp.left - offsetX;
            float transY0 = temp.top - offsetY;
            float croppedHeight = (windowTargetBounds.height() - crop.height()) * scale;
            float croppedWidth = (windowTargetBounds.width() - crop.width()) * scale;
            SurfaceParams[] params = new SurfaceParams[targets.length];
            for (int i = targets.length - 1; i >= 0; i--) {
                RemoteAnimationTargetCompat target = targets[i];
                Rect targetCrop;
                final float alpha;
                final float cornerRadius;
                if (target.mode == MODE_OPENING) {
                    matrix.setScale(scale, scale);
                    matrix.postTranslate(transX0, transY0);
                    targetCrop = crop;
                    alpha = 1f - mIconAlpha.value;
                    cornerRadius = mWindowRadius.value;
                    matrix.mapRect(currentBounds, targetBounds);
                    if (mDeviceProfile.isVerticalBarLayout()) {
                        currentBounds.right -= croppedWidth;
                    } else {
                        currentBounds.bottom -= croppedHeight;
                    }
                    floatingView.update(currentBounds, mIconAlpha.value, percent, 0f, cornerRadius * scale, true);
                } else {
                    matrix.setTranslate(target.position.x, target.position.y);
                    targetCrop = target.sourceContainerBounds;
                    alpha = 1f;
                    cornerRadius = 0;
                }
                params[i] = new SurfaceParams(target.leash, alpha, matrix, targetCrop, RemoteAnimationProvider.getLayer(target, MODE_OPENING), cornerRadius);
            }
            surfaceApplier.scheduleApply(params);
        }
    });
    return appAnimator;
}
Also used : SyncRtSurfaceTransactionApplierCompat(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat) FloatingIconView(com.android.launcher3.views.FloatingIconView) Rect(android.graphics.Rect) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) Drawable(android.graphics.drawable.Drawable) ValueAnimator(android.animation.ValueAnimator) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) RemoteAnimationTargetSet(com.android.quickstep.util.RemoteAnimationTargetSet) RectF(android.graphics.RectF) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Matrix(android.graphics.Matrix) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SurfaceParams(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams)

Example 4 with SyncRtSurfaceTransactionApplierCompat

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

the class QuickstepAppTransitionManagerImpl method getClosingWindowAnimators.

/**
 * Animator that controls the transformations of the windows the targets that are closing.
 */
private Animator getClosingWindowAnimators(RemoteAnimationTargetCompat[] targets) {
    SyncRtSurfaceTransactionApplierCompat surfaceApplier = new SyncRtSurfaceTransactionApplierCompat(mDragLayer);
    Matrix matrix = new Matrix();
    ValueAnimator closingAnimator = ValueAnimator.ofFloat(0, 1);
    int duration = CLOSING_TRANSITION_DURATION_MS;
    float windowCornerRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher.getResources());
    closingAnimator.setDuration(duration);
    closingAnimator.addUpdateListener(new MultiValueUpdateListener() {

        FloatProp mDy = new FloatProp(0, mClosingWindowTransY, 0, duration, DEACCEL_1_7);

        FloatProp mScale = new FloatProp(1f, 1f, 0, duration, DEACCEL_1_7);

        FloatProp mAlpha = new FloatProp(1f, 0f, 25, 125, LINEAR);

        @Override
        public void onUpdate(float percent) {
            SurfaceParams[] params = new SurfaceParams[targets.length];
            for (int i = targets.length - 1; i >= 0; i--) {
                RemoteAnimationTargetCompat target = targets[i];
                final float alpha;
                final float cornerRadius;
                if (target.mode == MODE_CLOSING) {
                    matrix.setScale(mScale.value, mScale.value, target.sourceContainerBounds.centerX(), target.sourceContainerBounds.centerY());
                    matrix.postTranslate(0, mDy.value);
                    matrix.postTranslate(target.position.x, target.position.y);
                    alpha = mAlpha.value;
                    cornerRadius = windowCornerRadius;
                } else {
                    matrix.setTranslate(target.position.x, target.position.y);
                    alpha = 1f;
                    cornerRadius = 0f;
                }
                params[i] = new SurfaceParams(target.leash, alpha, matrix, target.sourceContainerBounds, RemoteAnimationProvider.getLayer(target, MODE_CLOSING), cornerRadius);
            }
            surfaceApplier.scheduleApply(params);
        }
    });
    return closingAnimator;
}
Also used : SyncRtSurfaceTransactionApplierCompat(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Matrix(android.graphics.Matrix) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) ValueAnimator(android.animation.ValueAnimator) SurfaceParams(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams)

Example 5 with SyncRtSurfaceTransactionApplierCompat

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

the class QuickstepAppTransitionManagerImpl method getUnlockWindowAnimator.

/**
 * Animator that controls the transformations of the windows when unlocking the device.
 */
private Animator getUnlockWindowAnimator(RemoteAnimationTargetCompat[] targets) {
    SyncRtSurfaceTransactionApplierCompat surfaceApplier = new SyncRtSurfaceTransactionApplierCompat(mDragLayer);
    ValueAnimator unlockAnimator = ValueAnimator.ofFloat(0, 1);
    unlockAnimator.setDuration(CLOSING_TRANSITION_DURATION_MS);
    float cornerRadius = mDeviceProfile.isMultiWindowMode ? 0 : QuickStepContract.getWindowCornerRadius(mLauncher.getResources());
    unlockAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            SurfaceParams[] params = new SurfaceParams[targets.length];
            for (int i = targets.length - 1; i >= 0; i--) {
                RemoteAnimationTargetCompat target = targets[i];
                params[i] = new SurfaceParams(target.leash, 1f, null, target.sourceContainerBounds, RemoteAnimationProvider.getLayer(target, MODE_OPENING), cornerRadius);
            }
            surfaceApplier.scheduleApply(params);
        }
    });
    return unlockAnimator;
}
Also used : SyncRtSurfaceTransactionApplierCompat(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) ValueAnimator(android.animation.ValueAnimator) SurfaceParams(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams)

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