Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ad66efa8 authored by Winson's avatar Winson Committed by Winson Chung
Browse files

Removing HW layers for task view transitions.

Change-Id: I00377e12d779519bd0fc102480d37382b3ac4ea6
parent b94443d8
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -87,15 +87,6 @@ public class Utilities {
                    (1f - overlayAlpha) * Color.blue(overlayColor)));
    }

    /**
     * Cancels an animation.
     */
    public static void cancelAnimation(Animator animator) {
        if (animator != null) {
            animator.cancel();
        }
    }

    /**
     * Cancels an animation ensuring that if it has listeners, onCancel and onEnd
     * are not called.
+9 −14
Original line number Diff line number Diff line
@@ -204,6 +204,11 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
        mThumbnailView.onTaskViewSizeChanged(w, h);
    }

    @Override
    public boolean hasOverlappingRendering() {
        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
@@ -244,12 +249,11 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
    void updateViewPropertiesToTaskTransform(TaskViewTransform toTransform,
            TaskViewAnimation toAnimation, ValueAnimator.AnimatorUpdateListener updateCallback) {
        RecentsConfiguration config = Recents.getConfiguration();
        Utilities.cancelAnimation(mTransformAnimation);
        Utilities.cancelAnimationWithoutCallbacks(mTransformAnimation);

        // Compose the animations for the transform
        mTmpAnimators.clear();
        boolean requiresHwLayers = toTransform.applyToTaskView(this, mTmpAnimators, toAnimation,
                !config.fakeShadows);
        toTransform.applyToTaskView(this, mTmpAnimators, toAnimation, !config.fakeShadows);
        if (toAnimation.isImmediate()) {
            setTaskProgress(toTransform.p);
            if (toAnimation.listener != null) {
@@ -266,22 +270,13 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,

            // Create the animator
            mTransformAnimation = toAnimation.createAnimator(mTmpAnimators);
            if (requiresHwLayers) {
                setLayerType(View.LAYER_TYPE_HARDWARE, null);
                mTransformAnimation.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        setLayerType(View.LAYER_TYPE_NONE, null);
                    }
                });
            }
            mTransformAnimation.start();
        }
    }

    /** Resets this view's properties */
    void resetViewProperties() {
        Utilities.cancelAnimation(mTransformAnimation);
        Utilities.cancelAnimationWithoutCallbacks(mTransformAnimation);
        setDim(0);
        setVisibility(View.VISIBLE);
        getViewBounds().reset();
@@ -297,7 +292,7 @@ public class TaskView extends FrameLayout implements Task.TaskCallbacks,
     * Cancels any current transform animations.
     */
    public void cancelTransformAnimation() {
        Utilities.cancelAnimation(mTransformAnimation);
        Utilities.cancelAnimationWithoutCallbacks(mTransformAnimation);
    }

    /** Enables/disables handling touch on this task view. */
+2 −7
Original line number Diff line number Diff line
@@ -125,15 +125,12 @@ public class TaskViewTransform {

    /**
     * Applies this transform to a view.
     *
     * @return whether hardware layers are required for this animation.
     */
    public boolean applyToTaskView(TaskView v, ArrayList<Animator> animators,
    public void applyToTaskView(TaskView v, ArrayList<Animator> animators,
            TaskViewAnimation taskAnimation, boolean allowShadows) {
        // Return early if not visible
        boolean requiresHwLayers = false;
        if (!visible) {
            return requiresHwLayers;
            return;
        }

        if (taskAnimation.isImmediate()) {
@@ -163,7 +160,6 @@ public class TaskViewTransform {
            }
            if (hasAlphaChangedFrom(v.getAlpha())) {
                animators.add(ObjectAnimator.ofFloat(v, View.ALPHA, v.getAlpha(), alpha));
                requiresHwLayers = true;
            }
            if (hasRectChangedFrom(v)) {
                animators.add(ObjectAnimator.ofPropertyValuesHolder(v,
@@ -173,7 +169,6 @@ public class TaskViewTransform {
                        PropertyValuesHolder.ofInt(BOTTOM, v.getBottom(), (int) rect.bottom)));
            }
        }
        return requiresHwLayers;
    }

    /** Reset the transform on a view. */