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

Commit 6057c915 authored by Winson Chung's avatar Winson Chung
Browse files

Refactoring a few things with the full screen overlay and enter animation.

- Fixing issue with configuration change triggering enter animation
- Using a proper target task rect when animating into a group

Change-Id: I856d29a663f5e8c000ca22fd1025c09f65032893
parent 0a4a89f6
Loading
Loading
Loading
Loading
+11 −7
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Handler;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserHandle;
import android.view.View;
import android.view.View;
import com.android.systemui.R;
import com.android.systemui.R;
@@ -166,6 +167,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta


    public void onConfigurationChanged(Configuration newConfig) {
    public void onConfigurationChanged(Configuration newConfig) {
        mConfig = RecentsConfiguration.reinitialize(mContext);
        mConfig = RecentsConfiguration.reinitialize(mContext);
        mConfig.updateOnConfigurationChange();
        mWindowRect = mSystemServicesProxy.getWindowRect();
        mWindowRect = mSystemServicesProxy.getWindowRect();
        mConfig.getTaskStackBounds(mWindowRect.width(), mWindowRect.height(), mTaskStackBounds);
        mConfig.getTaskStackBounds(mWindowRect.width(), mWindowRect.height(), mTaskStackBounds);
        sLastScreenshot = null;
        sLastScreenshot = null;
@@ -271,11 +273,12 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
     * screenshot, then we will use that for the transition.
     * screenshot, then we will use that for the transition.
     */
     */
    ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo topTask) {
    ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo topTask) {

        if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
            // Recycle the last screenshot
            // Recycle the last screenshot
            consumeLastScreenshot();
            consumeLastScreenshot();


            // Take the full screenshot
            // Take the full screenshot
        if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
            sLastScreenshot = mSystemServicesProxy.takeAppScreenshot();
            sLastScreenshot = mSystemServicesProxy.takeAppScreenshot();
            if (sLastScreenshot != null) {
            if (sLastScreenshot != null) {
                return ActivityOptions.makeCustomAnimation(mContext,
                return ActivityOptions.makeCustomAnimation(mContext,
@@ -287,21 +290,22 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        // If the screenshot fails, then load the first task thumbnail and use that
        // If the screenshot fails, then load the first task thumbnail and use that
        Bitmap firstThumbnail = mSystemServicesProxy.getTaskThumbnail(topTask.id);
        Bitmap firstThumbnail = mSystemServicesProxy.getTaskThumbnail(topTask.id);
        if (firstThumbnail != null) {
        if (firstThumbnail != null) {
            Rect taskRect = getThumbnailTransitionRect(topTask.id);
            // Update the destination rect
            Rect toTaskRect = getThumbnailTransitionRect(topTask.id);


            // Create the new thumbnail for the animation down
            // Create the new thumbnail for the animation down
            // XXX: We should find a way to optimize this so we don't need to create a new bitmap
            // XXX: We should find a way to optimize this so we don't need to create a new bitmap
            Bitmap thumbnail = Bitmap.createBitmap(taskRect.width(), taskRect.height(),
            Bitmap thumbnail = Bitmap.createBitmap(toTaskRect.width(), toTaskRect.height(),
                    Bitmap.Config.ARGB_8888);
                    Bitmap.Config.ARGB_8888);
            int size = Math.min(firstThumbnail.getWidth(), firstThumbnail.getHeight());
            int size = Math.min(firstThumbnail.getWidth(), firstThumbnail.getHeight());
            Canvas c = new Canvas(thumbnail);
            Canvas c = new Canvas(thumbnail);
            c.drawBitmap(firstThumbnail, new Rect(0, 0, size, size),
            c.drawBitmap(firstThumbnail, new Rect(0, 0, size, size),
                    new Rect(0, 0, taskRect.width(), taskRect.height()), null);
                    new Rect(0, 0, toTaskRect.width(), toTaskRect.height()), null);
            c.setBitmap(null);
            c.setBitmap(null);
            // Recycle the old thumbnail
            // Recycle the old thumbnail
            firstThumbnail.recycle();
            firstThumbnail.recycle();
            return ActivityOptions.makeThumbnailScaleDownAnimation(mStatusBarView,
            return ActivityOptions.makeThumbnailScaleDownAnimation(mStatusBarView,
                    thumbnail, taskRect.left, taskRect.top, this);
                    thumbnail, toTaskRect.left, toTaskRect.top, this);
        }
        }


        // If both the screenshot and thumbnail fails, then just fall back to the default transition
        // If both the screenshot and thumbnail fails, then just fall back to the default transition
+15 −15
Original line number Original line Diff line number Diff line
@@ -206,6 +206,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        mConfig.launchedWithAltTab = launchIntent.getBooleanExtra(
        mConfig.launchedWithAltTab = launchIntent.getBooleanExtra(
                AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false);
                AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false);
        mConfig.launchedWithNoRecentTasks = !root.hasTasks();
        mConfig.launchedWithNoRecentTasks = !root.hasTasks();
        mConfig.launchedToTaskId = launchIntent.getIntExtra(
                AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_TASK_ID, -1);


        // Add the default no-recents layout
        // Add the default no-recents layout
        if (mEmptyView == null) {
        if (mEmptyView == null) {
@@ -372,11 +374,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        // Update the recent tasks
        // Update the recent tasks
        updateRecentsTasks(getIntent());
        updateRecentsTasks(getIntent());


        // Update if we are getting a configuration change
        if (savedInstanceState != null) {
            onConfigurationChange();
        }

        // Register the broadcast receiver to handle messages when the screen is turned off
        // Register the broadcast receiver to handle messages when the screen is turned off
        IntentFilter filter = new IntentFilter();
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_SCREEN_OFF);
@@ -402,6 +399,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
            mFullScreenOverlayView.setCallbacks(this);
            mFullScreenOverlayView.setCallbacks(this);
            mFullScreenOverlayView.prepareAnimateOnEnterRecents(AlternateRecentsComponent.getLastScreenshot());
            mFullScreenOverlayView.prepareAnimateOnEnterRecents(AlternateRecentsComponent.getLastScreenshot());
        }
        }

        // Update if we are getting a configuration change
        if (savedInstanceState != null) {
            mConfig.updateOnConfigurationChange();
            onConfigurationChange();
        }
    }
    }


    void onConfigurationChange() {
    void onConfigurationChange() {
@@ -416,6 +419,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
    @Override
    @Override
    protected void onNewIntent(Intent intent) {
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        super.onNewIntent(intent);
        setIntent(intent);


        if (Console.Enabled) {
        if (Console.Enabled) {
            Console.logDivider(Constants.Log.App.SystemUIHandshake);
            Console.logDivider(Constants.Log.App.SystemUIHandshake);
@@ -615,19 +619,15 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
    /**** FullscreenTransitionOverlayView.FullScreenTransitionViewCallbacks Implementation ****/
    /**** FullscreenTransitionOverlayView.FullScreenTransitionViewCallbacks Implementation ****/


    @Override
    @Override
    public void onEnterAnimationComplete(boolean canceled) {
    public void onEnterAnimationComplete() {
        if (!canceled) {
        // Reset the full screenshot transition view
        // Reset the full screenshot transition view
        if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
        if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
            mFullScreenOverlayView.reset();
            mFullScreenOverlayView.reset();
            }


            // XXX: We should clean up the screenshot in this case as well, but it needs to happen
            //      after to animate up
        }
            // Recycle the full screen screenshot
            // Recycle the full screen screenshot
            AlternateRecentsComponent.consumeLastScreenshot();
            AlternateRecentsComponent.consumeLastScreenshot();
        }
        }
    }


    /**** RecentsView.RecentsViewCallbacks Implementation ****/
    /**** RecentsView.RecentsViewCallbacks Implementation ****/


+2 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,7 @@ public class RecentsConfiguration {
    public boolean launchedFromAppWithThumbnail;
    public boolean launchedFromAppWithThumbnail;
    public boolean launchedFromAppWithScreenshot;
    public boolean launchedFromAppWithScreenshot;
    public boolean launchedFromHome;
    public boolean launchedFromHome;
    public int launchedToTaskId;


    /** Dev options */
    /** Dev options */
    public boolean developerOptionsEnabled;
    public boolean developerOptionsEnabled;
@@ -255,6 +256,7 @@ public class RecentsConfiguration {
        launchedFromAppWithThumbnail = false;
        launchedFromAppWithThumbnail = false;
        launchedFromAppWithScreenshot = false;
        launchedFromAppWithScreenshot = false;
        launchedFromHome = false;
        launchedFromHome = false;
        launchedToTaskId = -1;
    }
    }


    /** Returns whether the search bar app widget exists. */
    /** Returns whether the search bar app widget exists. */
+84 −39
Original line number Original line Diff line number Diff line
@@ -23,16 +23,20 @@ import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.View;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.recents.misc.Console;
import com.android.systemui.recents.Constants;
import com.android.systemui.recents.Constants;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.misc.Console;




/**
/**
@@ -43,7 +47,7 @@ public class FullscreenTransitionOverlayView extends FrameLayout {


    /** The FullscreenTransitionOverlayView callbacks */
    /** The FullscreenTransitionOverlayView callbacks */
    public interface FullScreenTransitionViewCallbacks {
    public interface FullScreenTransitionViewCallbacks {
        void onEnterAnimationComplete(boolean canceled);
        void onEnterAnimationComplete();
    }
    }


    RecentsConfiguration mConfig;
    RecentsConfiguration mConfig;
@@ -53,6 +57,11 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
    ImageView mScreenshotView;
    ImageView mScreenshotView;
    Rect mClipRect = new Rect();
    Rect mClipRect = new Rect();
    Paint mLayerPaint = new Paint();
    Paint mLayerPaint = new Paint();
    PorterDuffColorFilter mDimColorFilter = new PorterDuffColorFilter(0, PorterDuff.Mode.MULTIPLY);

    int mDim;
    int mMaxDim;
    AccelerateInterpolator mDimInterpolator = new AccelerateInterpolator();


    boolean mIsAnimating;
    boolean mIsAnimating;
    AnimatorSet mEnterAnimation;
    AnimatorSet mEnterAnimation;
@@ -73,8 +82,10 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
                                           int defStyleRes) {
                                           int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        super(context, attrs, defStyleAttr, defStyleRes);
        mConfig = RecentsConfiguration.getInstance();
        mConfig = RecentsConfiguration.getInstance();
        mMaxDim = mConfig.taskStackMaxDim;
        setClipTop(getClipTop());
        setClipTop(getClipTop());
        setClipBottom(getClipBottom());
        setClipBottom(getClipBottom());
        setDim(getDim());
        setWillNotDraw(false);
        setWillNotDraw(false);
    }
    }


@@ -91,7 +102,7 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
    /** Sets the top clip */
    /** Sets the top clip */
    public void setClipTop(int clip) {
    public void setClipTop(int clip) {
        mClipRect.top = clip;
        mClipRect.top = clip;
        postInvalidateOnAnimation();
        setClipBounds(mClipRect);
    }
    }


    /** Gets the top clip */
    /** Gets the top clip */
@@ -102,7 +113,7 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
    /** Sets the bottom clip */
    /** Sets the bottom clip */
    public void setClipBottom(int clip) {
    public void setClipBottom(int clip) {
        mClipRect.bottom = clip;
        mClipRect.bottom = clip;
        postInvalidateOnAnimation();
        setClipBounds(mClipRect);
    }
    }


    /** Gets the top clip */
    /** Gets the top clip */
@@ -110,20 +121,28 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
        return mClipRect.bottom;
        return mClipRect.bottom;
    }
    }


    /** Returns the current dim. */
    public void setDim(int dim) {
        mDim = dim;
        /*
        int inverse = 255 - mDim;
        mDimColorFilter.setColor(Color.argb(0xFF, inverse, inverse, inverse));
        mLayerPaint.setColorFilter(mDimColorFilter);
        setLayerType(LAYER_TYPE_HARDWARE, mLayerPaint);
        */
    }

    /** Returns the current dim. */
    public int getDim() {
        return mDim;
    }

    @Override
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        mClipRect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
        mClipRect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
    }
    }


    @Override
    public void draw(Canvas canvas) {
        int restoreCount = canvas.save(Canvas.CLIP_SAVE_FLAG | Canvas.CLIP_TO_LAYER_SAVE_FLAG);
        canvas.clipRect(mClipRect);
        super.draw(canvas);
        canvas.restoreToCount(restoreCount);
    }

    @Override
    @Override
    public boolean hasOverlappingRendering() {
    public boolean hasOverlappingRendering() {
        return false;
        return false;
@@ -140,6 +159,7 @@ public class FullscreenTransitionOverlayView extends FrameLayout {


        setClipTop(0);
        setClipTop(0);
        setClipBottom(getMeasuredHeight());
        setClipBottom(getMeasuredHeight());
        setDim(0);
        setTranslationY(0f);
        setTranslationY(0f);
        setScaleX(1f);
        setScaleX(1f);
        setScaleY(1f);
        setScaleY(1f);
@@ -153,7 +173,7 @@ public class FullscreenTransitionOverlayView extends FrameLayout {


    /** Resets the transition view */
    /** Resets the transition view */
    public void reset() {
    public void reset() {
        setVisibility(View.INVISIBLE);
        setVisibility(View.GONE);
        mScreenshotView.setImageDrawable(null);
        mScreenshotView.setImageDrawable(null);
    }
    }


@@ -172,12 +192,20 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
        }
        }


        // Calculate the bottom clip
        // Calculate the bottom clip
        Rect taskRect = ctx.taskRect;
        Rect targetTaskRect = ctx.targetTaskTransform.rect;
        float scale = (float) taskRect.width() / getMeasuredWidth();
        float scale = (float) targetTaskRect.width() / getMeasuredWidth();
        float scaleYOffset = ((1f - scale) * getMeasuredHeight()) / 2;
        float scaleYOffset = ((1f - scale) * getMeasuredHeight()) / 2;
        float scaledTopInset = (int) (scale * mConfig.systemInsets.top);
        float scaledTopInset = (int) (scale * mConfig.systemInsets.top);
        int translationY = (int) -scaleYOffset + (int) (mConfig.systemInsets.top - scaledTopInset) + taskRect.top;
        int translationY = (int) -scaleYOffset + (int) (mConfig.systemInsets.top - scaledTopInset)
        int clipBottom = mConfig.systemInsets.top + (int) (taskRect.height() / scale);
                + targetTaskRect.top;
        int clipBottom = mConfig.systemInsets.top + (int) (targetTaskRect.height() / scale);

        // Calculate the dim
        float minScale = TaskStackViewLayoutAlgorithm.StackPeekMinScale;
        float scaleRange = 1f - minScale;
        float dim = (1f - ctx.targetTaskTransform.scale) / scaleRange;
        dim = mDimInterpolator.getInterpolation(Math.min(dim, 1f));
        int toDim = Math.max(0, Math.min(mMaxDim, (int) (dim * 255)));


        // Enable the HW Layers on the screenshot view
        // Enable the HW Layers on the screenshot view
        mScreenshotView.setLayerType(View.LAYER_TYPE_HARDWARE, mLayerPaint);
        mScreenshotView.setLayerType(View.LAYER_TYPE_HARDWARE, mLayerPaint);
@@ -187,14 +215,17 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
        mEnterAnimation.addListener(new AnimatorListenerAdapter() {
        mEnterAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            @Override
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                // Notify any callbacks
                post(new Runnable() {
                mCb.onEnterAnimationComplete(false);
                    @Override
                // Run the given post-anim runnable
                    public void run() {
                postAnimRunnable.run();
                        // Mark that we are no longer animating
                        // Mark that we are no longer animating
                        mIsAnimating = false;
                        mIsAnimating = false;
                        // Disable the HW Layers on this view
                        // Disable the HW Layers on this view
                        setLayerType(View.LAYER_TYPE_NONE, mLayerPaint);
                        setLayerType(View.LAYER_TYPE_NONE, mLayerPaint);
                        // Notify any callbacks
                        mCb.onEnterAnimationComplete();
                        // Run the given post-anim runnable
                        postAnimRunnable.run();


                        if (Console.Enabled) {
                        if (Console.Enabled) {
                            Console.logTraceTime(Constants.Log.App.TimeRecentsScreenshotTransition,
                            Console.logTraceTime(Constants.Log.App.TimeRecentsScreenshotTransition,
@@ -202,16 +233,21 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
                        }
                        }
                    }
                    }
                });
                });
            }
        });
        // XXX: Translation y should be negative initially to simulate moving from the top of the screen?
        mEnterAnimation.setStartDelay(0);
        mEnterAnimation.setStartDelay(0);
        mEnterAnimation.setDuration(475);
        mEnterAnimation.setDuration(475);
        mEnterAnimation.setInterpolator(mConfig.fastOutSlowInInterpolator);
        mEnterAnimation.setInterpolator(mConfig.fastOutSlowInInterpolator);
        mEnterAnimation.playTogether(
        mEnterAnimation.playTogether(
                ObjectAnimator.ofInt(this, "clipTop", mConfig.systemInsets.top),
                // ObjectAnimator.ofInt(this, "clipTop", mConfig.systemInsets.top),
                ObjectAnimator.ofInt(this, "clipBottom", clipBottom),
                ObjectAnimator.ofInt(this, "clipBottom", clipBottom),
                ObjectAnimator.ofInt(this, "dim", toDim),
                ObjectAnimator.ofFloat(this, "translationY", translationY),
                ObjectAnimator.ofFloat(this, "translationY", translationY),
                ObjectAnimator.ofFloat(this, "scaleX", scale),
                ObjectAnimator.ofFloat(this, "scaleX", scale),
                ObjectAnimator.ofFloat(this, "scaleY", scale)
                ObjectAnimator.ofFloat(this, "scaleY", scale)
        );
        );
        setClipTop(mConfig.systemInsets.top);
        mEnterAnimation.start();
        mEnterAnimation.start();


        mIsAnimating = true;
        mIsAnimating = true;
@@ -226,19 +262,27 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
                mEnterAnimation.cancel();
                mEnterAnimation.cancel();
            }
            }


            // Enable the HW Layers on the screenshot view
            mScreenshotView.setLayerType(View.LAYER_TYPE_HARDWARE, mLayerPaint);

            // Compose the animation
            // Compose the animation
            mEnterAnimation = new AnimatorSet();
            mEnterAnimation = new AnimatorSet();
            mEnterAnimation.addListener(new AnimatorListenerAdapter() {
            mEnterAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                @Override
                public void onAnimationEnd(Animator animation) {
                public void onAnimationEnd(Animator animation) {
                    // Notify any callbacks
                    post(new Runnable() {
                    mCb.onEnterAnimationComplete(true);
                        @Override
                    // Run the given post-anim runnable
                        public void run() {
                    postAnimRunnable.run();
                            // Mark that we are no longer animating
                            // Mark that we are no longer animating
                            mIsAnimating = false;
                            mIsAnimating = false;
                            // Disable the HW Layers on the screenshot view
                            // Disable the HW Layers on the screenshot view
                            mScreenshotView.setLayerType(View.LAYER_TYPE_NONE, mLayerPaint);
                            mScreenshotView.setLayerType(View.LAYER_TYPE_NONE, mLayerPaint);
                            // Notify any callbacks
                            mCb.onEnterAnimationComplete();
                            // Run the given post-anim runnable
                            postAnimRunnable.run();
                        }
                    });
                }
                }
            });
            });
            mEnterAnimation.setDuration(475);
            mEnterAnimation.setDuration(475);
@@ -246,6 +290,7 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
            mEnterAnimation.playTogether(
            mEnterAnimation.playTogether(
                    ObjectAnimator.ofInt(this, "clipTop", 0),
                    ObjectAnimator.ofInt(this, "clipTop", 0),
                    ObjectAnimator.ofInt(this, "clipBottom", getMeasuredHeight()),
                    ObjectAnimator.ofInt(this, "clipBottom", getMeasuredHeight()),
                    ObjectAnimator.ofInt(this, "dim", 0),
                    ObjectAnimator.ofFloat(this, "translationY", 0f),
                    ObjectAnimator.ofFloat(this, "translationY", 0f),
                    ObjectAnimator.ofFloat(this, "scaleX", 1f),
                    ObjectAnimator.ofFloat(this, "scaleX", 1f),
                    ObjectAnimator.ofFloat(this, "scaleY", 1f)
                    ObjectAnimator.ofFloat(this, "scaleY", 1f)
+36 −12
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region;
import android.os.SystemClock;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View;
@@ -813,24 +814,47 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        }
        }


        if (mStack.getTaskCount() > 0) {
        if (mStack.getTaskCount() > 0) {
            // Animate all the task views into view
            TaskViewTransform transform = new TaskViewTransform();
            TaskStack.GroupTaskIndex groupTaskIndex = new TaskStack.GroupTaskIndex();
            TaskStack.GroupTaskIndex groupTaskIndex = new TaskStack.GroupTaskIndex();
            mStack.getGroupIndexForTask(mStack.getFrontMostTask(), groupTaskIndex);

            mStackAlgorithm.getStackTransform(groupTaskIndex.groupIndex, groupTaskIndex.taskIndex,
            if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
                    getInitialStackScroll(), transform);
                // Find the target task with the specified id
            ctx.taskRect = transform.rect;
                ArrayList<Task> tasks = mStack.getTasks();
            ctx.stackRectSansPeek = mStackAlgorithm.mStackRectSansPeek;
                Task targetTask = null;
                int targetTaskId = mConfig.launchedToTaskId;
                if (targetTaskId != -1) {
                    int taskCount = tasks.size();
                    for (int i = 0; i < taskCount; i++) {
                        Task t = tasks.get(i);
                        if (t.key.id == targetTaskId) {
                            targetTask = t;
                            break;
                        }
                    }
                }

                // Find the group and task index of the target task
                if (targetTask != null) {
                    mStack.getGroupIndexForTask(targetTask, groupTaskIndex);
                    ctx.targetTaskTransform = new TaskViewTransform();
                    mStackAlgorithm.getStackTransform(groupTaskIndex.groupIndex,
                            groupTaskIndex.taskIndex, getStackScroll(), ctx.targetTaskTransform);
                    Rect taskStackBounds = new Rect();
                    mConfig.getTaskStackBounds(getMeasuredWidth(), getMeasuredHeight(), taskStackBounds);
                    ctx.targetTaskTransform.rect.offset(taskStackBounds.left, taskStackBounds.top);
                }
            }

            // Animate all the task views into view
            int childCount = getChildCount();
            int childCount = getChildCount();
            for (int i = childCount - 1; i >= 0; i--) {
            for (int i = childCount - 1; i >= 0; i--) {
                TaskView tv = (TaskView) getChildAt(i);
                TaskView tv = (TaskView) getChildAt(i);
                ctx.stackViewIndex = i;
                ctx.currentTaskTransform = new TaskViewTransform();
                ctx.stackViewCount = childCount;
                ctx.currentStackViewIndex = i;
                ctx.isFrontMost = (i == (getChildCount() - 1));
                ctx.currentStackViewCount = childCount;
                ctx.transform = new TaskViewTransform();
                ctx.isCurrentTaskFrontMost = (i == (getChildCount() - 1));
                mStack.getGroupIndexForTask(tv.getTask(), groupTaskIndex);
                mStack.getGroupIndexForTask(tv.getTask(), groupTaskIndex);
                mStackAlgorithm.getStackTransform(groupTaskIndex.groupIndex, groupTaskIndex.taskIndex,
                mStackAlgorithm.getStackTransform(groupTaskIndex.groupIndex, groupTaskIndex.taskIndex,
                        getStackScroll(), ctx.transform);
                        getStackScroll(), ctx.currentTaskTransform);
                tv.startEnterRecentsAnimation(ctx);
                tv.startEnterRecentsAnimation(ctx);
            }
            }


Loading