summaryrefslogtreecommitdiff
path: root/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
diff options
context:
space:
mode:
Diffstat (limited to 'com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java')
-rw-r--r--com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java199
1 files changed, 34 insertions, 165 deletions
diff --git a/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
index eaa32eef..acb058ce 100644
--- a/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
+++ b/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
@@ -24,7 +24,6 @@ import android.graphics.Path;
import android.graphics.Rect;
import android.util.ArraySet;
import android.util.Log;
-import android.util.MutableFloat;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.ViewDebug;
@@ -36,9 +35,9 @@ import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.misc.FreePathInterpolator;
import com.android.systemui.recents.misc.SystemServicesProxy;
-import com.android.systemui.recents.misc.Utilities;
-import com.android.systemui.recents.model.Task;
-import com.android.systemui.recents.model.TaskStack;
+import com.android.systemui.shared.recents.utilities.Utilities;
+import com.android.systemui.shared.recents.model.Task;
+import com.android.systemui.shared.recents.model.TaskStack;
import com.android.systemui.recents.views.lowram.TaskStackLowRamLayoutAlgorithm;
import com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm;
@@ -147,75 +146,6 @@ public class TaskStackLayoutAlgorithm {
}
/**
- * The various stack/freeform states.
- */
- public static class StackState {
-
- public static final StackState FREEFORM_ONLY = new StackState(1f, 255);
- public static final StackState STACK_ONLY = new StackState(0f, 0);
- public static final StackState SPLIT = new StackState(0.5f, 255);
-
- public final float freeformHeightPct;
- public final int freeformBackgroundAlpha;
-
- /**
- * @param freeformHeightPct the percentage of the stack height (not including paddings) to
- * allocate to the freeform workspace
- * @param freeformBackgroundAlpha the background alpha for the freeform workspace
- */
- private StackState(float freeformHeightPct, int freeformBackgroundAlpha) {
- this.freeformHeightPct = freeformHeightPct;
- this.freeformBackgroundAlpha = freeformBackgroundAlpha;
- }
-
- /**
- * 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 freeformCount = stack.getFreeformTaskCount();
- int stackCount = stack.getStackTaskCount();
- 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 topMargin, int freeformGap, int stackBottomOffset) {
- // The freeform height is the visible height (not including system insets) - padding
- // above freeform and below stack - gap between the freeform and stack
- int availableHeight = taskStackBounds.height() - topMargin - stackBottomOffset;
- int ffPaddedHeight = (int) (availableHeight * freeformHeightPct);
- int ffHeight = Math.max(0, ffPaddedHeight - freeformGap);
- freeformRectOut.set(taskStackBounds.left,
- taskStackBounds.top + topMargin,
- taskStackBounds.right,
- taskStackBounds.top + topMargin + ffHeight);
- stackRectOut.set(taskStackBounds.left,
- taskStackBounds.top,
- taskStackBounds.right,
- taskStackBounds.bottom);
- if (ffPaddedHeight > 0) {
- stackRectOut.top += ffPaddedHeight;
- } else {
- stackRectOut.top += topMargin;
- }
- }
- }
-
- /**
* @return True if we should use the grid layout.
*/
boolean useGridLayout() {
@@ -234,15 +164,11 @@ public class TaskStackLayoutAlgorithm {
}
Context mContext;
- private StackState mState = StackState.SPLIT;
private TaskStackLayoutAlgorithmCallbacks mCb;
// The task bounds (untransformed) for layout. This rect is anchored at mTaskRoot.
@ViewDebug.ExportedProperty(category="recents")
public Rect mTaskRect = new Rect();
- // The freeform workspace bounds, inset by the top system insets and is a fixed height
- @ViewDebug.ExportedProperty(category="recents")
- public Rect mFreeformRect = new Rect();
// The stack bounds, inset from the top system insets, and runs to the bottom of the screen
@ViewDebug.ExportedProperty(category="recents")
public Rect mStackRect = new Rect();
@@ -268,10 +194,6 @@ public class TaskStackLayoutAlgorithm {
private int mBaseBottomMargin;
private int mMinMargin;
- // The gap between the freeform and stack layouts
- @ViewDebug.ExportedProperty(category="recents")
- private int mFreeformStackGap;
-
// The initial offset that the focused task is from the top
@ViewDebug.ExportedProperty(category="recents")
private int mInitialTopOffset;
@@ -331,8 +253,6 @@ public class TaskStackLayoutAlgorithm {
// The last computed task counts
@ViewDebug.ExportedProperty(category="recents")
int mNumStackTasks;
- @ViewDebug.ExportedProperty(category="recents")
- int mNumFreeformTasks;
// The min/max z translations
@ViewDebug.ExportedProperty(category="recents")
@@ -344,8 +264,6 @@ public class TaskStackLayoutAlgorithm {
private SparseIntArray mTaskIndexMap = new SparseIntArray();
private SparseArray<Float> mTaskIndexOverrideMap = new SparseArray<>();
- // The freeform workspace layout
- FreeformWorkspaceLayoutAlgorithm mFreeformLayoutAlgorithm;
TaskGridLayoutAlgorithm mTaskGridLayoutAlgorithm;
TaskStackLowRamLayoutAlgorithm mTaskStackLowRamLayoutAlgorithm;
@@ -356,7 +274,6 @@ public class TaskStackLayoutAlgorithm {
public TaskStackLayoutAlgorithm(Context context, TaskStackLayoutAlgorithmCallbacks cb) {
mContext = context;
mCb = cb;
- mFreeformLayoutAlgorithm = new FreeformWorkspaceLayoutAlgorithm(context);
mTaskGridLayoutAlgorithm = new TaskGridLayoutAlgorithm(context);
mTaskStackLowRamLayoutAlgorithm = new TaskStackLowRamLayoutAlgorithm(context);
reloadOnConfigurationChange(context);
@@ -393,7 +310,6 @@ public class TaskStackLayoutAlgorithm {
R.dimen.recents_layout_initial_bottom_offset_tablet,
R.dimen.recents_layout_initial_bottom_offset_tablet,
R.dimen.recents_layout_initial_bottom_offset_tablet);
- mFreeformLayoutAlgorithm.reloadOnConfigurationChange(context);
mTaskGridLayoutAlgorithm.reloadOnConfigurationChange(context);
mTaskStackLowRamLayoutAlgorithm.reloadOnConfigurationChange(context);
mMinMargin = res.getDimensionPixelSize(R.dimen.recents_layout_min_margin);
@@ -408,8 +324,6 @@ public class TaskStackLayoutAlgorithm {
R.dimen.recents_layout_side_margin_tablet_xlarge,
R.dimen.recents_layout_side_margin_tablet);
mBaseBottomMargin = res.getDimensionPixelSize(R.dimen.recents_layout_bottom_margin);
- mFreeformStackGap =
- res.getDimensionPixelSize(R.dimen.recents_freeform_layout_bottom_margin);
mTitleBarHeight = getDimensionForDevice(mContext,
R.dimen.recents_task_view_header_height,
R.dimen.recents_task_view_header_height,
@@ -462,8 +376,7 @@ public class TaskStackLayoutAlgorithm {
* Computes the stack and task rects. The given task stack bounds already has the top/right
* insets and left/right padding already applied.
*/
- public void initialize(Rect displayRect, Rect windowRect, Rect taskStackBounds,
- StackState state) {
+ public void initialize(Rect displayRect, Rect windowRect, Rect taskStackBounds) {
Rect lastStackRect = new Rect(mStackRect);
int topMargin = getScaleForExtent(windowRect, displayRect, mBaseTopMargin, mMinMargin, HEIGHT);
@@ -474,10 +387,9 @@ public class TaskStackLayoutAlgorithm {
mInitialBottomOffset = mBaseInitialBottomOffset;
// Compute the stack bounds
- mState = state;
mStackBottomOffset = mSystemInsets.bottom + bottomMargin;
- state.computeRects(mFreeformRect, mStackRect, taskStackBounds, topMargin,
- mFreeformStackGap, mStackBottomOffset);
+ mStackRect.set(taskStackBounds);
+ mStackRect.top += topMargin;
// The stack action button will take the full un-padded header space above the stack
mStackActionButtonRect.set(mStackRect.left, mStackRect.top - topMargin,
@@ -530,26 +442,20 @@ public class TaskStackLayoutAlgorithm {
if (tasks.isEmpty()) {
mFrontMostTaskP = 0;
mMinScrollP = mMaxScrollP = mInitialScrollP = 0;
- mNumStackTasks = mNumFreeformTasks = 0;
+ mNumStackTasks = 0;
return;
}
- // Filter the set of freeform and stack tasks
- ArrayList<Task> freeformTasks = new ArrayList<>();
+ // Filter the set of stack tasks
ArrayList<Task> stackTasks = new ArrayList<>();
for (int i = 0; i < tasks.size(); i++) {
Task task = tasks.get(i);
if (ignoreTasksSet.contains(task.key)) {
continue;
}
- if (task.isFreeformTask()) {
- freeformTasks.add(task);
- } else {
- stackTasks.add(task);
- }
+ stackTasks.add(task);
}
mNumStackTasks = stackTasks.size();
- mNumFreeformTasks = freeformTasks.size();
// Put each of the tasks in the progress map at a fixed index (does not need to actually
// map to a scroll position, just by index)
@@ -559,11 +465,6 @@ public class TaskStackLayoutAlgorithm {
mTaskIndexMap.put(task.key.id, i);
}
- // Update the freeform tasks
- if (!freeformTasks.isEmpty()) {
- mFreeformLayoutAlgorithm.update(freeformTasks, this);
- }
-
// Calculate the min/max/initial scroll
Task launchTask = stack.getLaunchTarget();
int launchTaskIndex = launchTask != null
@@ -582,7 +483,7 @@ public class TaskStackLayoutAlgorithm {
} else {
mInitialScrollP = Utilities.clamp(launchTaskIndex - 1, mMinScrollP, mMaxScrollP);
}
- } else if (!ssp.hasFreeformWorkspaceSupport() && mNumStackTasks == 1) {
+ } else if (mNumStackTasks == 1) {
// If there is one stack task, ignore the min/max/initial scroll positions
mMinScrollP = 0;
mMaxScrollP = 0;
@@ -603,9 +504,7 @@ public class TaskStackLayoutAlgorithm {
boolean scrollToFront = launchState.launchedFromHome || launchState.launchedFromPipApp
|| launchState.launchedWithNextPipApp || launchState.launchedViaDockGesture;
- if (launchState.launchedFromBlacklistedApp) {
- mInitialScrollP = mMaxScrollP;
- } else if (launchState.launchedWithAltTab) {
+ if (launchState.launchedWithAltTab) {
mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
} else if (Recents.getConfiguration().isLowRamDevice) {
mInitialScrollP = mTaskStackLowRamLayoutAlgorithm.getInitialScrollP(mNumStackTasks,
@@ -633,7 +532,6 @@ public class TaskStackLayoutAlgorithm {
boolean scrollToFront = launchState.launchedFromHome ||
launchState.launchedFromPipApp ||
launchState.launchedWithNextPipApp ||
- launchState.launchedFromBlacklistedApp ||
launchState.launchedViaDockGesture;
if (getInitialFocusState() == STATE_UNFOCUSED && mNumStackTasks > 1) {
if (ignoreScrollToFront || (!launchState.launchedWithAltTab && !scrollToFront)) {
@@ -767,7 +665,7 @@ public class TaskStackLayoutAlgorithm {
public int getInitialFocusState() {
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
RecentsDebugFlags debugFlags = Recents.getDebugFlags();
- if (debugFlags.isPagingEnabled() || launchState.launchedWithAltTab) {
+ if (launchState.launchedWithAltTab) {
return STATE_FOCUSED;
} else {
return STATE_UNFOCUSED;
@@ -794,13 +692,6 @@ public class TaskStackLayoutAlgorithm {
}
/**
- * Returns the current stack state.
- */
- public StackState getStackState() {
- return mState;
- }
-
- /**
* Returns whether this stack layout has been initialized.
*/
public boolean isInitialized() {
@@ -825,62 +716,44 @@ public class TaskStackLayoutAlgorithm {
return new VisibilityReport(1, 1);
}
- // Quick return when there are no stack tasks
- if (mNumStackTasks == 0) {
- return new VisibilityReport(mNumFreeformTasks > 0 ? Math.max(mNumFreeformTasks, 1) : 0,
- mNumFreeformTasks > 0 ? Math.max(mNumFreeformTasks, 1) : 0);
- }
-
// Otherwise, walk backwards in the stack and count the number of tasks and visible
- // thumbnails and add that to the total freeform task count
+ // thumbnails and add that to the total task count
TaskViewTransform tmpTransform = new TaskViewTransform();
Range currentRange = getInitialFocusState() > 0f ? mFocusedRange : mUnfocusedRange;
currentRange.offset(mInitialScrollP);
int taskBarHeight = mContext.getResources().getDimensionPixelSize(
R.dimen.recents_task_view_header_height);
- int numVisibleTasks = mNumFreeformTasks > 0 ? Math.max(mNumFreeformTasks, 1) : 0;
- int numVisibleThumbnails = mNumFreeformTasks > 0 ? Math.max(mNumFreeformTasks, 0) : 0;
+ int numVisibleTasks = 0;
+ int numVisibleThumbnails = 0;
float prevScreenY = Integer.MAX_VALUE;
for (int i = tasks.size() - 1; i >= 0; i--) {
Task task = tasks.get(i);
- // Skip freeform
- if (task.isFreeformTask()) {
- continue;
- }
-
// Skip invisible
float taskProgress = getStackScrollForTask(task);
if (!currentRange.isInRange(taskProgress)) {
continue;
}
- boolean isFrontMostTaskInGroup = task.group == null || task.group.isFrontMostTask(task);
- if (isFrontMostTaskInGroup) {
- getStackTransform(taskProgress, taskProgress, mInitialScrollP, mFocusState,
- tmpTransform, null, false /* ignoreSingleTaskCase */,
- false /* forceUpdate */);
- float screenY = tmpTransform.rect.top;
- boolean hasVisibleThumbnail = (prevScreenY - screenY) > taskBarHeight;
- if (hasVisibleThumbnail) {
- numVisibleThumbnails++;
- numVisibleTasks++;
- prevScreenY = screenY;
- } else {
- // Once we hit the next front most task that does not have a visible thumbnail,
- // walk through remaining visible set
- for (int j = i; j >= 0; j--) {
- taskProgress = getStackScrollForTask(tasks.get(j));
- if (!currentRange.isInRange(taskProgress)) {
- break;
- }
- numVisibleTasks++;
+ getStackTransform(taskProgress, taskProgress, mInitialScrollP, mFocusState,
+ tmpTransform, null, false /* ignoreSingleTaskCase */, false /* forceUpdate */);
+ float screenY = tmpTransform.rect.top;
+ boolean hasVisibleThumbnail = (prevScreenY - screenY) > taskBarHeight;
+ if (hasVisibleThumbnail) {
+ numVisibleThumbnails++;
+ numVisibleTasks++;
+ prevScreenY = screenY;
+ } else {
+ // Once we hit the next front most task that does not have a visible thumbnail,
+ // walk through remaining visible set
+ for (int j = i; j >= 0; j--) {
+ taskProgress = getStackScrollForTask(tasks.get(j));
+ if (!currentRange.isInRange(taskProgress)) {
+ break;
}
- break;
+ numVisibleTasks++;
}
- } else {
- // Affiliated task, no thumbnail
- numVisibleTasks++;
+ break;
}
}
return new VisibilityReport(numVisibleTasks, numVisibleThumbnails);
@@ -906,10 +779,7 @@ public class TaskStackLayoutAlgorithm {
public TaskViewTransform getStackTransform(Task task, float stackScroll, int focusState,
TaskViewTransform transformOut, TaskViewTransform frontTransform, boolean forceUpdate,
boolean ignoreTaskOverrides) {
- if (mFreeformLayoutAlgorithm.isTransformAvailable(task, this)) {
- mFreeformLayoutAlgorithm.getTransform(task, transformOut, this);
- return transformOut;
- } else if (useGridLayout()) {
+ if (useGridLayout()) {
int taskIndex = mTaskIndexMap.get(task.key.id);
int taskCount = mTaskIndexMap.size();
mTaskGridLayoutAlgorithm.getTransform(taskIndex, taskCount, transformOut, this);
@@ -1024,7 +894,7 @@ public class TaskStackLayoutAlgorithm {
float z;
float dimAlpha;
float viewOutlineAlpha;
- if (!ssp.hasFreeformWorkspaceSupport() && mNumStackTasks == 1 && !ignoreSingleTaskCase) {
+ if (mNumStackTasks == 1 && !ignoreSingleTaskCase) {
// When there is exactly one task, then decouple the task from the stack and just move
// in screen space
float tmpP = (mMinScrollP - stackScroll) / mNumStackTasks;
@@ -1378,7 +1248,6 @@ public class TaskStackLayoutAlgorithm {
writer.print("insets="); writer.print(Utilities.dumpRect(mSystemInsets));
writer.print(" stack="); writer.print(Utilities.dumpRect(mStackRect));
writer.print(" task="); writer.print(Utilities.dumpRect(mTaskRect));
- writer.print(" freeform="); writer.print(Utilities.dumpRect(mFreeformRect));
writer.print(" actionButton="); writer.print(Utilities.dumpRect(mStackActionButtonRect));
writer.println();