From f0d1c44a59a10707baa0cca8dd377302260710c1 Mon Sep 17 00:00:00 2001 From: Winson Date: Tue, 1 Dec 2015 11:04:45 -0800 Subject: [PATCH] Adding notion of stack state to the layout. - This allows us to choose which layout to show, either freeform, stack, or a combination of the two - Fixing crash with null bitmap Change-Id: I659e66d89f7205ccb0c2ba22c57aee95c8d4b3ab --- .../com/android/systemui/recents/RecentsImpl.java | 20 +-- .../android/systemui/recents/model/TaskStack.java | 40 ++++-- .../views/FreeformWorkspaceLayoutAlgorithm.java | 19 ++- .../recents/views/RecentsTransitionHelper.java | 2 +- .../recents/views/TaskStackLayoutAlgorithm.java | 134 ++++++++++++++------- .../systemui/recents/views/TaskStackView.java | 11 +- .../recents/views/TaskStackViewScroller.java | 3 +- 7 files changed, 154 insertions(+), 75 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 0f82cce32b12..d1e8faea65e3 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -200,7 +200,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements mDummyStackView = new TaskStackView(mContext, new TaskStack()); mHeaderBar = (TaskViewHeader) inflater.inflate(R.layout.recents_task_view_header, null, false); - reloadHeaderBarLayout(true /* tryAndBindSearchWidget */); + reloadHeaderBarLayout(true /* tryAndBindSearchWidget */, null /* stack */); // When we start, preload the data associated with the previous recent tasks. // We can use a new plan since the caches will be the same. @@ -216,7 +216,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements public void onBootCompleted() { mBootCompleted = true; - reloadHeaderBarLayout(true /* tryAndBindSearchWidget */); + reloadHeaderBarLayout(true /* tryAndBindSearchWidget */, null /* stack */); } @Override @@ -566,8 +566,9 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements * * @param tryAndBindSearchWidget if set, will attempt to fetch and bind the search widget if one * is not already bound (can be expensive) + * @param stack the stack to initialize the stack layout with */ - private void reloadHeaderBarLayout(boolean tryAndBindSearchWidget) { + private void reloadHeaderBarLayout(boolean tryAndBindSearchWidget, TaskStack stack) { RecentsConfiguration config = Recents.getConfiguration(); SystemServicesProxy ssp = Recents.getSystemServices(); Rect windowRect = ssp.getWindowRect(); @@ -593,7 +594,10 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements TaskStackLayoutAlgorithm algo = mDummyStackView.getStackAlgorithm(); Rect taskStackBounds = new Rect(mTaskStackBounds); algo.setSystemInsets(systemInsets); - algo.initialize(taskStackBounds); + if (stack != null) { + algo.initialize(taskStackBounds, + TaskStackLayoutAlgorithm.StackState.getStackStateForStack(stack)); + } Rect taskViewBounds = algo.getUntransformedTaskViewBounds(); if (!taskViewBounds.equals(mLastTaskViewBounds)) { mLastTaskViewBounds.set(taskViewBounds); @@ -629,7 +633,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements preloadIcon(topTask); // Update the header bar if necessary - reloadHeaderBarLayout(false /* tryAndBindSearchWidget */); + reloadHeaderBarLayout(false /* tryAndBindSearchWidget */, stack); // Update the destination rect mDummyStackView.updateLayoutForStack(stack); @@ -800,9 +804,6 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements boolean isTopTaskHome, boolean animate) { RecentsTaskLoader loader = Recents.getTaskLoader(); - // Update the header bar if necessary - reloadHeaderBarLayout(false /* tryAndBindSearchWidget */); - // In the case where alt-tab is triggered, we never get a preloadRecents() call, so we // should always preload the tasks now. If we are dragging in recents, reload them as // the stacks might have changed. @@ -815,6 +816,9 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements } TaskStack stack = sInstanceLoadPlan.getTaskStack(); + // Update the header bar if necessary + reloadHeaderBarLayout(false /* tryAndBindSearchWidget */, stack); + // Prepare the dummy stack for the transition mDummyStackView.updateLayoutForStack(stack); TaskStackLayoutAlgorithm.VisibilityReport stackVr = diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java index cd0a46f008bc..381ffc97a8cb 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java +++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java @@ -206,15 +206,21 @@ public class TaskStack { /** * The various possible dock states when dragging and dropping a task. */ - public enum DockState implements DropTarget { - NONE(-1, 96, null, null), - LEFT(DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, 192, - new RectF(0, 0, 0.25f, 1), new RectF(0, 0, 0.25f, 1)), - TOP(DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, 192, - new RectF(0, 0, 1, 0.25f), new RectF(0, 0, 1, 0.25f)), - RIGHT(DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT, 192, - new RectF(0.75f, 0, 1, 1), new RectF(0.75f, 0, 1, 1)), - BOTTOM(DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT, 192, + public static class DockState implements DropTarget { + + private static final int DOCK_AREA_ALPHA = 192; + public static final DockState NONE = new DockState(-1, 96, null, null); + public static final DockState LEFT = new DockState( + DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, DOCK_AREA_ALPHA, + new RectF(0, 0, 0.25f, 1), new RectF(0, 0, 0.25f, 1)); + public static final DockState TOP = new DockState( + DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, DOCK_AREA_ALPHA, + new RectF(0, 0, 1, 0.25f), new RectF(0, 0, 1, 0.25f)); + public static final DockState RIGHT = new DockState( + DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT, DOCK_AREA_ALPHA, + new RectF(0.75f, 0, 1, 1), new RectF(0.75f, 0, 1, 1)); + public static final DockState BOTTOM = new DockState( + DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT, DOCK_AREA_ALPHA, new RectF(0, 0.75f, 1, 1), new RectF(0, 0.75f, 1, 1)); @Override @@ -463,6 +469,22 @@ public class TaskStack { } /** + * Returns the number of freeform tasks in the active stack. + */ + public int getStackTaskFreeformCount() { + ArrayList tasks = mStackTaskList.getTasks(); + int freeformCount = 0; + int taskCount = tasks.size(); + for (int i = 0; i < taskCount; i++) { + Task task = tasks.get(i); + if (task.isFreeformTask()) { + freeformCount++; + } + } + return freeformCount; + } + + /** * Returns the task in stack tasks which is the launch target. */ public Task getLaunchTarget() { diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java index a70b66d5a437..6c0d6db507dd 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/FreeformWorkspaceLayoutAlgorithm.java @@ -16,6 +16,7 @@ package com.android.systemui.recents.views; +import android.graphics.Bitmap; import android.graphics.Rect; import android.util.Log; import com.android.systemui.recents.misc.Utilities; @@ -101,12 +102,18 @@ public class FreeformWorkspaceLayoutAlgorithm { int x = taskIndex % mFreeformCellXCount; int y = taskIndex / mFreeformCellXCount; - int bitmapWidth = task.thumbnail.getWidth(); - int bitmapHeight = task.thumbnail.getHeight(); - float thumbnailScale = Math.min((float) mFreeformCellWidth / bitmapWidth, - (float) mFreeformCellHeight / bitmapHeight); - float thumbnailWidth = bitmapWidth * thumbnailScale; - float thumbnailHeight = bitmapHeight * thumbnailScale; + Bitmap thumbnail = task.thumbnail; + float thumbnailScale = 1f; + float thumbnailWidth = mFreeformCellWidth; + float thumbnailHeight = mFreeformCellHeight; + if (thumbnail != null) { + int bitmapWidth = task.thumbnail.getWidth(); + int bitmapHeight = task.thumbnail.getHeight(); + thumbnailScale = Math.min((float) mFreeformCellWidth / bitmapWidth, + (float) mFreeformCellHeight / bitmapHeight); + thumbnailWidth = bitmapWidth * thumbnailScale; + thumbnailHeight = bitmapHeight * thumbnailScale; + } int scaleXOffset = (int) (((1f - thumbnailScale) * thumbnailWidth) / 2); int scaleYOffset = (int) (((1f - thumbnailScale) * thumbnailHeight) / 2); transformOut.scale = thumbnailScale * 0.9f; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java index 736020f19447..a3a9e5a0a952 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java @@ -257,7 +257,7 @@ public class RecentsTransitionHelper { TaskStackLayoutAlgorithm layoutAlgorithm = stackView.getStackAlgorithm(); Rect offscreenTaskRect = new Rect(layoutAlgorithm.mTaskRect); offscreenTaskRect.offsetTo(offscreenTaskRect.left, - layoutAlgorithm.mCurrentStackRect.bottom); + layoutAlgorithm.mStackRect.bottom); // If this is a full screen stack, the transition will be towards the single, full screen // task. We only need the transition spec for this task. diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java index 6af2ada6b7c0..5278aa38826c 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -114,6 +114,71 @@ public class TaskStackLayoutAlgorithm { public static final float STATE_UNFOCUSED = 0f; /** + * The various stack/freeform states. + */ + public static class StackState { + + public static final StackState FREEFORM_ONLY = new StackState(1f); + public static final StackState STACK_ONLY = new StackState(0f); + public static final StackState SPLIT = new StackState(0.5f); + + public final float freeformHeightPct; + + /** + * @param freeformHeightPct the percentage of the stack height (not including paddings) to + * allocate to the freeform workspace + */ + StackState(float freeformHeightPct) { + this.freeformHeightPct = freeformHeightPct; + } + + /** + * Resolves the stack state for the layout given a task stack. + */ + public static StackState getStackStateForStack(TaskStack stack) { + SystemServicesProxy ssp = Recents.getSystemServices(); + boolean hasFreeformWorkspaces = ssp.hasFreeformWorkspaceSupport(); + int taskCount = stack.getStackTaskCount(); + int freeformCount = stack.getStackTaskFreeformCount(); + int stackCount = taskCount - freeformCount; + if (hasFreeformWorkspaces && stackCount > 0 && freeformCount > 0) { + return SPLIT; + } else if (hasFreeformWorkspaces && freeformCount > 0) { + return FREEFORM_ONLY; + } else { + return STACK_ONLY; + } + } + + /** + * Computes the freeform and stack rect for this state. + * + * @param freeformRectOut the freeform rect to be written out + * @param stackRectOut the stack rect, we only write out the top of the stack + * @param taskStackBounds the full rect that the freeform rect can take up + */ + public void computeRects(Rect freeformRectOut, Rect stackRectOut, + Rect taskStackBounds, int widthPadding, int heightPadding, int stackBottomOffset) { + int availableHeight = taskStackBounds.height() - stackBottomOffset; + int ffPaddedHeight = (int) (availableHeight * freeformHeightPct); + int ffHeight = Math.max(0, ffPaddedHeight - (2 * heightPadding)); + freeformRectOut.set(taskStackBounds.left + widthPadding, + taskStackBounds.top + heightPadding, + taskStackBounds.right - widthPadding, + taskStackBounds.top + heightPadding + ffHeight); + stackRectOut.set(taskStackBounds.left + widthPadding, + taskStackBounds.top, + taskStackBounds.right - widthPadding, + taskStackBounds.bottom); + if (ffPaddedHeight > 0) { + stackRectOut.top += ffPaddedHeight; + } else { + stackRectOut.top += heightPadding; + } + } + } + + /** * A Property wrapper around the focusState functionality handled by the * {@link TaskStackLayoutAlgorithm#setFocusState(float)} and * {@link TaskStackLayoutAlgorithm#getFocusState()} methods. @@ -146,20 +211,15 @@ public class TaskStackLayoutAlgorithm { Context mContext; private TaskStackView mStackView; private Interpolator mFastOutSlowInInterpolator; + private StackState mState = StackState.SPLIT; // The task bounds (untransformed) for layout. This rect is anchored at mTaskRoot. public Rect mTaskRect = new Rect(); // The freeform workspace bounds, inset from the top by the search bar, and is a fixed height public Rect mFreeformRect = new Rect(); - // The freeform stack bounds, inset from the top by the search bar and freeform workspace, and - // runs to the bottom of the screen - private Rect mFreeformStackRect = new Rect(); // The stack bounds, inset from the top by the search bar, and runs to // the bottom of the screen - private Rect mStackRect = new Rect(); - // The current stack rect, can either by mFreeformStackRect or mStackRect depending on whether - // there is a freeform workspace - public Rect mCurrentStackRect = new Rect(); + public Rect mStackRect = new Rect(); // This is the current system insets public Rect mSystemInsets = new Rect(); // This is the bounds of the history button above the stack rect @@ -273,41 +333,29 @@ public class TaskStackLayoutAlgorithm { * Computes the stack and task rects. The given task stack bounds is the whole bounds not * including the search bar. */ - public void initialize(Rect taskStackBounds) { + public void initialize(Rect taskStackBounds, StackState state) { SystemServicesProxy ssp = Recents.getSystemServices(); RecentsDebugFlags debugFlags = Recents.getDebugFlags(); RecentsConfiguration config = Recents.getConfiguration(); int widthPadding = (int) (config.taskStackWidthPaddingPct * taskStackBounds.width()); int heightPadding = mContext.getResources().getDimensionPixelSize( R.dimen.recents_stack_top_padding); - Rect lastStackRect = new Rect(mCurrentStackRect); + Rect lastStackRect = new Rect(mStackRect); // The freeform height is the visible height (not including system insets) - padding above // freeform and below stack - gap between the freeform and stack mStackTopOffset = mFocusedPeekHeight + heightPadding; mStackBottomOffset = mSystemInsets.bottom + heightPadding; - int ffHeight = (taskStackBounds.height() - 2 * heightPadding - mStackBottomOffset) / 2; - mFreeformRect.set(taskStackBounds.left + widthPadding, - taskStackBounds.top + heightPadding, - taskStackBounds.right - widthPadding, - taskStackBounds.top + heightPadding + ffHeight); - mFreeformStackRect.set(taskStackBounds.left + widthPadding, - taskStackBounds.top + heightPadding + ffHeight + heightPadding, - taskStackBounds.right - widthPadding, - taskStackBounds.bottom); - mStackRect.set(taskStackBounds.left + widthPadding, - taskStackBounds.top + heightPadding, - taskStackBounds.right - widthPadding, - taskStackBounds.bottom); - mCurrentStackRect = ssp.hasFreeformWorkspaceSupport() ? mFreeformStackRect : mStackRect; - mHistoryButtonRect.set(mCurrentStackRect.left, mCurrentStackRect.top - heightPadding, - mCurrentStackRect.right, mCurrentStackRect.top + mFocusedPeekHeight); + state.computeRects(mFreeformRect, mStackRect, taskStackBounds, widthPadding, heightPadding, + mStackBottomOffset); + mHistoryButtonRect.set(mStackRect.left, mStackRect.top - heightPadding, + mStackRect.right, mStackRect.top + mFocusedPeekHeight); // Anchor the task rect to the top-center of the non-freeform stack rect float aspect = (float) (taskStackBounds.width() - mSystemInsets.left - mSystemInsets.right) / (taskStackBounds.height() - mSystemInsets.bottom); int width = mStackRect.width(); - int minHeight = mCurrentStackRect.height() - mFocusedPeekHeight - mStackBottomOffset; + int minHeight = mStackRect.height() - mFocusedPeekHeight - mStackBottomOffset; int height = debugFlags.isFullscreenThumbnailsEnabled() ? (int) Math.min(width / aspect, minHeight) : width; @@ -315,7 +363,7 @@ public class TaskStackLayoutAlgorithm { mStackRect.left + width, mStackRect.top + height); // Short circuit here if the stack rects haven't changed so we don't do all the work below - if (lastStackRect.equals(mCurrentStackRect)) { + if (lastStackRect.equals(mStackRect)) { return; } @@ -328,9 +376,7 @@ public class TaskStackLayoutAlgorithm { if (DEBUG) { Log.d(TAG, "initialize"); Log.d(TAG, "\tmFreeformRect: " + mFreeformRect); - Log.d(TAG, "\tmFreeformStackRect: " + mFreeformStackRect); Log.d(TAG, "\tmStackRect: " + mStackRect); - Log.d(TAG, "\tmCurrentStackRect: " + mCurrentStackRect); Log.d(TAG, "\tmTaskRect: " + mTaskRect); Log.d(TAG, "\tmSystemInsets: " + mSystemInsets); } @@ -386,7 +432,7 @@ public class TaskStackLayoutAlgorithm { mMinScrollP = mMaxScrollP = 0; } else { float bottomOffsetPct = (float) (mStackBottomOffset + mTaskRect.height()) / - mCurrentStackRect.height(); + mStackRect.height(); float normX = mUnfocusedCurveInterpolator.getX(bottomOffsetPct); mMinScrollP = 0; mMaxScrollP = Math.max(mMinScrollP, @@ -408,7 +454,7 @@ public class TaskStackLayoutAlgorithm { mInitialScrollP = Math.max(mMinScrollP, mNumStackTasks - 2); } } else { - float offsetPct = (float) (mTaskRect.height() / 2) / mCurrentStackRect.height(); + float offsetPct = (float) (mTaskRect.height() / 2) / mStackRect.height(); float normX = mUnfocusedCurveInterpolator.getX(offsetPct); mInitialScrollP = (mNumStackTasks - 1) - mUnfocusedRange.getAbsoluteX(normX); } @@ -428,7 +474,7 @@ public class TaskStackLayoutAlgorithm { public void updateFocusStateOnScroll(int yMovement) { Utilities.cancelAnimationWithoutCallbacks(mFocusStateAnimator); if (mFocusState > STATE_UNFOCUSED) { - float delta = (float) yMovement / (UNFOCUS_MULTIPLIER * mCurrentStackRect.height()); + float delta = (float) yMovement / (UNFOCUS_MULTIPLIER * mStackRect.height()); mFocusState -= Math.min(mFocusState, Math.abs(delta)); } } @@ -558,7 +604,7 @@ public class TaskStackLayoutAlgorithm { float p = mUnfocusedRange.getNormalizedX(taskProgress); float yp = mUnfocusedCurveInterpolator.getInterpolation(p); float unfocusedP = p; - int unFocusedY = (int) (Math.max(0f, (1f - yp)) * mCurrentStackRect.height()); + int unFocusedY = (int) (Math.max(0f, (1f - yp)) * mStackRect.height()); boolean unfocusedVisible = mUnfocusedRange.isInRange(taskProgress); int focusedY = 0; boolean focusedVisible = true; @@ -566,7 +612,7 @@ public class TaskStackLayoutAlgorithm { mFocusedRange.offset(stackScroll); p = mFocusedRange.getNormalizedX(taskProgress); yp = mFocusedCurveInterpolator.getInterpolation(p); - focusedY = (int) (Math.max(0f, (1f - yp)) * mCurrentStackRect.height()); + focusedY = (int) (Math.max(0f, (1f - yp)) * mStackRect.height()); focusedVisible = mFocusedRange.isInRange(taskProgress); } @@ -583,8 +629,8 @@ public class TaskStackLayoutAlgorithm { // When there is exactly one task, then decouple the task from the stack and just move // in screen space p = (mMinScrollP - stackScroll) / mNumStackTasks; - int centerYOffset = (mCurrentStackRect.top - mTaskRect.top) + - (mCurrentStackRect.height() - mTaskRect.height()) / 2; + int centerYOffset = (mStackRect.top - mTaskRect.top) + + (mStackRect.height() - mTaskRect.height()) / 2; y = centerYOffset + getYForDeltaP(p, 0); z = mMaxTranslationZ; relP = 1f; @@ -592,7 +638,7 @@ public class TaskStackLayoutAlgorithm { } else { // Otherwise, update the task to the stack layout y = unFocusedY + (int) (mFocusState * (focusedY - unFocusedY)); - y += (mCurrentStackRect.top - mTaskRect.top); + y += (mStackRect.top - mTaskRect.top); z = Math.max(mMinTranslationZ, Math.min(mMaxTranslationZ, mMinTranslationZ + (p * (mMaxTranslationZ - mMinTranslationZ)))); relP = unfocusedP; @@ -600,7 +646,7 @@ public class TaskStackLayoutAlgorithm { // Fill out the transform transformOut.scale = 1f; - transformOut.translationX = (mCurrentStackRect.width() - mTaskRect.width()) / 2; + transformOut.translationX = (mStackRect.width() - mTaskRect.width()) / 2; transformOut.translationY = y; transformOut.translationZ = z; transformOut.rect.set(mTaskRect); @@ -633,7 +679,7 @@ public class TaskStackLayoutAlgorithm { * screen along the arc-length proportionally (1/arclength). */ public float getDeltaPForY(int downY, int y) { - float deltaP = (float) (y - downY) / mCurrentStackRect.height() * + float deltaP = (float) (y - downY) / mStackRect.height() * mUnfocusedCurveInterpolator.getArcLength(); return -deltaP; } @@ -643,7 +689,7 @@ public class TaskStackLayoutAlgorithm { * of the curve, map back to the screen y. */ public int getYForDeltaP(float downScrollP, float p) { - int y = (int) ((p - downScrollP) * mCurrentStackRect.height() * + int y = (int) ((p - downScrollP) * mStackRect.height() * (1f / mUnfocusedCurveInterpolator.getArcLength())); return -y; } @@ -658,12 +704,12 @@ public class TaskStackLayoutAlgorithm { // Initialize the focused curve. This curve is a piecewise curve composed of several // quadradic beziers that goes from (0,1) through (0.5, peek height offset), // (0.667, next task offset), (0.833, bottom task offset), and (1,0). - float peekHeightPct = (float) mFocusedPeekHeight / mCurrentStackRect.height(); + float peekHeightPct = (float) mFocusedPeekHeight / mStackRect.height(); Path p = new Path(); p.moveTo(0f, 1f); p.lineTo(0.5f, 1f - peekHeightPct); - p.lineTo(0.66666667f, (float) (taskBarHeight * 3) / mCurrentStackRect.height()); - p.lineTo(0.83333333f, (float) (taskBarHeight / 2) / mCurrentStackRect.height()); + p.lineTo(0.66666667f, (float) (taskBarHeight * 3) / mStackRect.height()); + p.lineTo(0.83333333f, (float) (taskBarHeight / 2) / mStackRect.height()); p.lineTo(1f, 0f); return p; } @@ -680,7 +726,7 @@ public class TaskStackLayoutAlgorithm { // there is a tangent at (0.5, peek height offset). float cpoint1X = 0.4f; float cpoint1Y = 1f; - float peekHeightPct = (float) mFocusedPeekHeight / mCurrentStackRect.height(); + float peekHeightPct = (float) mFocusedPeekHeight / mStackRect.height(); float slope = ((1f - peekHeightPct) - cpoint1Y) / (0.5f - cpoint1X); float b = 1f - slope * cpoint1X; float cpoint2X = 0.75f; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java index 0395e9992abf..5f289c074365 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -156,7 +156,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal private DropTarget mStackDropTarget = new DropTarget() { @Override public boolean acceptsDrop(int x, int y, int width, int height) { - return mLayoutAlgorithm.mCurrentStackRect.contains(x, y); + return mLayoutAlgorithm.mStackRect.contains(x, y); } }; @@ -401,7 +401,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal if (boundTranslationsToRect) { transform.translationY = Math.min(transform.translationY, - mLayoutAlgorithm.mCurrentStackRect.bottom); + mLayoutAlgorithm.mStackRect.bottom); } frontTransform = transform; } @@ -880,7 +880,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal /** Computes the stack and task rects */ public void computeRects(Rect taskStackBounds) { // Compute the rects in the stack algorithm - mLayoutAlgorithm.initialize(taskStackBounds); + mLayoutAlgorithm.initialize(taskStackBounds, + TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack)); // Update the scroll bounds updateLayout(false); @@ -993,7 +994,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal /** Handler for the first layout. */ void onFirstLayout() { - int offscreenY = mLayoutAlgorithm.mCurrentStackRect.bottom; + int offscreenY = mLayoutAlgorithm.mStackRect.bottom; // Find the launch target task Task launchTargetTask = mStack.getLaunchTarget(); @@ -1102,7 +1103,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal mStackScroller.stopScroller(); mStackScroller.stopBoundScrollAnimation(); // Animate all the task views out of view - ctx.offscreenTranslationY = mLayoutAlgorithm.mCurrentStackRect.bottom; + ctx.offscreenTranslationY = mLayoutAlgorithm.mStackRect.bottom; List taskViews = getTaskViews(); int taskViewCount = taskViews.size(); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java index 90b73fe2757d..4095d2ed21c3 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewScroller.java @@ -19,7 +19,6 @@ package com.android.systemui.recents.views; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; import android.content.Context; import android.util.Log; import android.view.animation.AnimationUtils; @@ -189,7 +188,7 @@ public class TaskStackViewScroller { // TODO: Remove @Deprecated int progressToScrollRange(float p) { - return (int) (p * mLayoutAlgorithm.mCurrentStackRect.height()); + return (int) (p * mLayoutAlgorithm.mStackRect.height()); } /** Called from the view draw, computes the next scroll. */ -- 2.11.0