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

Commit d7b2cb12 authored by Winson Chung's avatar Winson Chung
Browse files

Continuing refactor of TaskStackView.

- Extracting stack and filtering logic.

Change-Id: Id794cb2e36238baa49e614bc436bf07de6680804
parent 566cbf20
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -510,7 +510,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        } else {
            // If there is no thumbnail transition, but is launching from home into recents, then
            // use a quick home transition and do the animation from home
            if (hasRecentTasks && Constants.DebugFlags.App.EnableHomeTransition) {
            if (hasRecentTasks) {
                ActivityOptions opts = getHomeTransitionActivityOptions();
                startAlternateRecentsActivity(opts, EXTRA_FROM_HOME);
            } else {
+0 −15
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ public class Constants {
        public static final boolean Verbose = false;

        public static class App {
            // Enables the home->Recents transition
            public static final boolean EnableHomeTransition = true;
            // Enables the screenshot app->Recents transition
            public static final boolean EnableScreenshotAppTransition = false;
            // Enables the filtering of tasks according to their grouping
@@ -96,10 +94,6 @@ public class Constants {
            public static String Key_DebugModeEnabled = "debugModeEnabled";
            public static String DebugModeVersion = "A";
        }
        public static class Window {
            // The dark background dim is set behind the empty recents view
            public static final float DarkBackgroundDim = 0.5f;
        }

        public static class RecentsTaskLoader {
            // XXX: This should be calculated on the first load
@@ -109,15 +103,6 @@ public class Constants {
        public static class TaskStackView {
            public static final int TaskStackOverscrollRange = 150;
            public static final int FilterStartDelay = 25;

            // The overlap height relative to the task height
            public static final float StackOverlapPct = 0.65f;
            // The height of the peek space relative to the stack height
            public static final float StackPeekHeightPct = 0.1f;
            // The min scale of the last card in the peek area
            public static final float StackPeekMinScale = 0.8f;
            // The number of cards we see in the peek space
            public static final int StackPeekNumCards = 3;
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -85,6 +85,10 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
            mUseCustomFinishTransition = withTransition;
        }

        /**
         * Creates a finish runnable that starts the specified intent, using the given
         * ActivityOptions.
         */
        public FinishRecentsRunnable(Intent launchIntent, ActivityOptions opts) {
            mLaunchIntent = launchIntent;
            mLaunchOpts = opts;
@@ -618,6 +622,11 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        AlternateRecentsComponent.notifyVisibilityChanged(false);
    }

    @Override
    public void onLastTaskRemoved() {
        mFinishLaunchHomeRunnable.run();
    }

    /**** RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks Implementation ****/

    @Override
+5 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.TaskStackView;
import com.android.systemui.recents.views.TaskStackViewLayoutAlgorithm;
import com.android.systemui.recents.views.TaskViewTransform;

import java.lang.ref.WeakReference;
@@ -70,6 +71,7 @@ class SystemUIMessageHandler extends Handler {
                // Create a dummy task stack & compute the rect for the thumbnail to animate to
                TaskStack stack = new TaskStack(context);
                TaskStackView tsv = new TaskStackView(context, stack);
                TaskStackViewLayoutAlgorithm algo = tsv.getStackAlgorithm();
                Bundle replyData = new Bundle();
                TaskViewTransform transform;

@@ -85,7 +87,7 @@ class SystemUIMessageHandler extends Handler {
                tsv.computeRects(taskStackBounds.width(), taskStackBounds.height() -
                        systemInsets.top - systemInsets.bottom, 0, 0);
                tsv.setStackScrollToInitialState();
                transform = tsv.getStackTransform(0, tsv.getStackScroll());
                transform = algo.getStackTransform(0, tsv.getStackScroll());
                transform.rect.offset(taskStackBounds.left, taskStackBounds.top);
                replyData.putParcelable(AlternateRecentsComponent.KEY_SINGLE_TASK_STACK_RECT,
                        new Rect(transform.rect));
@@ -95,7 +97,7 @@ class SystemUIMessageHandler extends Handler {
                tsv.computeRects(taskStackBounds.width(), taskStackBounds.height() -
                        systemInsets.top - systemInsets.bottom, 0, 0);
                tsv.setStackScrollToInitialState();
                transform = tsv.getStackTransform(1, tsv.getStackScroll());
                transform = algo.getStackTransform(1, tsv.getStackScroll());
                transform.rect.offset(taskStackBounds.left, taskStackBounds.top);
                replyData.putParcelable(AlternateRecentsComponent.KEY_TWO_TASK_STACK_RECT,
                        new Rect(transform.rect));
@@ -105,7 +107,7 @@ class SystemUIMessageHandler extends Handler {
                tsv.computeRects(taskStackBounds.width(), taskStackBounds.height() -
                        systemInsets.top - systemInsets.bottom, 0, 0);
                tsv.setStackScrollToInitialState();
                transform = tsv.getStackTransform(2, tsv.getStackScroll());
                transform = algo.getStackTransform(2, tsv.getStackScroll());
                transform.rect.offset(taskStackBounds.left, taskStackBounds.top);
                replyData.putParcelable(AlternateRecentsComponent.KEY_MULTIPLE_TASK_STACK_RECT,
                        new Rect(transform.rect));
+7 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
@@ -172,10 +173,12 @@ public class FullscreenTransitionOverlayView extends FrameLayout {
        }

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

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