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

Commit aa7f7a4c authored by Winson Chung's avatar Winson Chung Committed by Android Git Automerger
Browse files

am 80f35657: Merge "Ensuring that the second card is maximally visible when...

am 80f35657: Merge "Ensuring that the second card is maximally visible when you go into recents." into lmp-preview-dev

* commit '80f3565796122213b3da8f2e80acddc4a059ffbb':
  Ensuring that the second card is maximally visible when you go into recents.
parents 8e1be1ea 069707ed
Loading
Loading
Loading
Loading
+20 −8
Original line number Diff line number Diff line
@@ -63,12 +63,15 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
                Bundle replyData = msg.getData().getParcelable(KEY_CONFIGURATION_DATA);
                mSingleCountFirstTaskRect = replyData.getParcelable(KEY_SINGLE_TASK_STACK_RECT);
                mSingleCountFirstTaskRect.offset(0, (int) statusBarHeight);
                mTwoCountFirstTaskRect = replyData.getParcelable(KEY_TWO_TASK_STACK_RECT);
                mTwoCountFirstTaskRect.offset(0, (int) statusBarHeight);
                mMultipleCountFirstTaskRect = replyData.getParcelable(KEY_MULTIPLE_TASK_STACK_RECT);
                mMultipleCountFirstTaskRect.offset(0, (int) statusBarHeight);
                if (Console.Enabled) {
                    Console.log(Constants.Log.App.RecentsComponent,
                            "[RecentsComponent|RecentsMessageHandler|handleMessage]",
                            "singleTaskRect: " + mSingleCountFirstTaskRect +
                            " twoTaskRect: " + mTwoCountFirstTaskRect +
                            " multipleTaskRect: " + mMultipleCountFirstTaskRect);
                }

@@ -132,6 +135,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
    final public static String KEY_WINDOW_RECT = "recents.windowRect";
    final public static String KEY_SYSTEM_INSETS = "recents.systemInsets";
    final public static String KEY_SINGLE_TASK_STACK_RECT = "recents.singleCountTaskRect";
    final public static String KEY_TWO_TASK_STACK_RECT = "recents.twoCountTaskRect";
    final public static String KEY_MULTIPLE_TASK_STACK_RECT = "recents.multipleCountTaskRect";


@@ -157,6 +161,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
    boolean mTriggeredFromAltTab;

    Rect mSingleCountFirstTaskRect = new Rect();
    Rect mTwoCountFirstTaskRect = new Rect();
    Rect mMultipleCountFirstTaskRect = new Rect();
    long mLastToggleTime;

@@ -263,8 +268,10 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
    /** Returns whether we have valid task rects to animate to. */
    boolean hasValidTaskRects() {
        return mSingleCountFirstTaskRect != null && mSingleCountFirstTaskRect.width() > 0 &&
                mSingleCountFirstTaskRect.height() > 0 && mMultipleCountFirstTaskRect != null &&
                mMultipleCountFirstTaskRect.width() > 0 && mMultipleCountFirstTaskRect.height() > 0;
                mSingleCountFirstTaskRect.height() > 0 && mTwoCountFirstTaskRect != null &&
                mTwoCountFirstTaskRect.width() > 0 && mTwoCountFirstTaskRect.height() > 0 &&
                mMultipleCountFirstTaskRect != null && mMultipleCountFirstTaskRect.width() > 0 &&
                mMultipleCountFirstTaskRect.height() > 0;
    }

    /** Updates each of the task animation rects. */
@@ -305,8 +312,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        return null;
    }

    /** Returns whether there is are multiple recents tasks */
    boolean hasMultipleRecentsTask(List<ActivityManager.RecentTaskInfo> tasks) {
    /** Returns the proper rect to use for the animation, given the number of tasks. */
    Rect getAnimationTaskRect(List<ActivityManager.RecentTaskInfo> tasks) {
        // NOTE: Currently there's no method to get the number of non-home tasks, so we have to
        // compute this ourselves
        SystemServicesProxy ssp = mSystemServicesProxy;
@@ -320,7 +327,13 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
                continue;
            }
        }
        return (tasks.size() > 1);
        if (tasks.size() <= 1) {
            return mSingleCountFirstTaskRect;
        } else if (tasks.size() <= 2) {
            return mTwoCountFirstTaskRect;
        } else {
            return mMultipleCountFirstTaskRect;
        }
    }

    /** Converts from the device rotation to the degree */
@@ -474,9 +487,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        // which can differ depending on the number of items in the list.
        SystemServicesProxy ssp = mSystemServicesProxy;
        List<ActivityManager.RecentTaskInfo> recentTasks =
                ssp.getRecentTasks(2, UserHandle.CURRENT.getIdentifier());
        Rect taskRect = hasMultipleRecentsTask(recentTasks) ? mMultipleCountFirstTaskRect :
                mSingleCountFirstTaskRect;
                ssp.getRecentTasks(3, UserHandle.CURRENT.getIdentifier());
        Rect taskRect = getAnimationTaskRect(recentTasks);
        boolean useThumbnailTransition = !isTopTaskHome &&
                hasValidTaskRects();

+2 −2
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ public class Constants {
            public static final int FilterStartDelay = 25;

            // The padding will be applied to the smallest dimension, and then applied to all sides
            public static final float StackPaddingPct = 0.1f;
            public static final float StackPaddingPct = 0.085f;
            // 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
+13 −4
Original line number Diff line number Diff line
@@ -83,20 +83,29 @@ class SystemUIMessageHandler extends Handler {
                stack.addTask(new Task());
                tsv.computeRects(taskStackBounds.width(), taskStackBounds.height() -
                        systemInsets.top - systemInsets.bottom, 0, 0);
                tsv.boundScroll();
                tsv.setStackScrollToInitialState();
                transform = tsv.getStackTransform(0, tsv.getStackScroll());
                transform.rect.offset(taskStackBounds.left, taskStackBounds.top);
                replyData.putParcelable(AlternateRecentsComponent.KEY_SINGLE_TASK_STACK_RECT,
                        new Rect(transform.rect));

                // Also calculate the target task rect when there are multiple tasks.
                // Also calculate the target task rect when there are two tasks.
                stack.addTask(new Task());
                tsv.computeRects(taskStackBounds.width(), taskStackBounds.height() -
                        systemInsets.top - systemInsets.bottom, 0, 0);
                tsv.setStackScrollRaw(Integer.MAX_VALUE);
                tsv.boundScroll();
                tsv.setStackScrollToInitialState();
                transform = tsv.getStackTransform(1, tsv.getStackScroll());
                transform.rect.offset(taskStackBounds.left, taskStackBounds.top);
                replyData.putParcelable(AlternateRecentsComponent.KEY_TWO_TASK_STACK_RECT,
                        new Rect(transform.rect));

                // Also calculate the target task rect when there are two tasks.
                stack.addTask(new Task());
                tsv.computeRects(taskStackBounds.width(), taskStackBounds.height() -
                        systemInsets.top - systemInsets.bottom, 0, 0);
                tsv.setStackScrollToInitialState();
                transform = tsv.getStackTransform(2, tsv.getStackScroll());
                transform.rect.offset(taskStackBounds.left, taskStackBounds.top);
                replyData.putParcelable(AlternateRecentsComponent.KEY_MULTIPLE_TASK_STACK_RECT,
                        new Rect(transform.rect));

+11 −2
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        }

        // Set the alphas
        transform.dismissAlpha = Math.max(-1f, Math.min(0f, t)) + 1f;
        transform.dismissAlpha = Math.max(-1f, Math.min(0f, t + 1)) + 1f;

        // Update the rect and visibility
        transform.rect.set(mTaskRect);
@@ -300,6 +300,15 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    public void setStackScrollRaw(int value) {
        mStackScroll = value;
    }
    /** Sets the current stack scroll to the initial state when you first enter recents */
    public void setStackScrollToInitialState() {
        if (mStack.getTaskCount() > 2) {
            int initialScroll = mMaxScroll - mTaskRect.height() / 2;
            setStackScroll(initialScroll);
        } else {
            setStackScroll(mMaxScroll);
        }
    }

    /**
     * Returns the scroll to such that the task transform at that index will have t=0. (If the scroll
@@ -700,7 +709,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        // If this is the first layout, then scroll to the front of the stack and synchronize the
        // stack views immediately
        if (mAwaitingFirstLayout) {
            setStackScroll(mMaxScroll);
            setStackScrollToInitialState();
            requestSynchronizeStackViewsWithModel();
            synchronizeStackViewsWithModel();
        }