Resources res = mContext.getResources();
reloadResources();
mDummyStackView.reloadOnConfigurationChange();
+ mDummyStackView.getStackAlgorithm().getGridState().setHasDockedTasks(
+ Recents.getSystemServices().hasDockedTask());
}
/**
if (task.isFreeformTask()) {
mTmpTransform = stackLayout.getStackTransformScreenCoordinates(task,
stackScroller.getStackScroll(), mTmpTransform, null,
- windowOverrideRect, false /* useGridLayout */);
+ windowOverrideRect);
Bitmap thumbnail = drawThumbnailTransitionBitmap(task, mTmpTransform,
mThumbTransitionBitmapCache);
Rect toTaskRect = new Rect();
stackView.updateToInitialState();
boolean isInSplitScreen = Recents.getSystemServices().hasDockedTask();
stackView.getStackAlgorithm().getStackTransformScreenCoordinates(launchTask,
- stackView.getScroller().getStackScroll(), mTmpTransform, null, windowOverrideRect,
- Recents.getConfiguration().isGridEnabled && !isInSplitScreen);
+ stackView.getScroller().getStackScroll(), mTmpTransform, null, windowOverrideRect);
return mTmpTransform;
}
if (RecentsDebugFlags.Static.EnableStackActionButton) {
// Measure the stack action button within the constraints of the space above the stack
- Rect buttonBounds = mTaskStackView.mLayoutAlgorithm.getStackActionButtonRect(
- mTaskStackView.useGridLayout());
+ Rect buttonBounds = mTaskStackView.mLayoutAlgorithm.getStackActionButtonRect();
measureChild(mStackActionButton,
MeasureSpec.makeMeasureSpec(buttonBounds.width(), MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(buttonBounds.height(), MeasureSpec.AT_MOST));
* @return the bounds of the stack action button.
*/
private Rect getStackActionButtonBoundsFromStackLayout() {
- Rect actionButtonRect = new Rect(mTaskStackView.mLayoutAlgorithm.getStackActionButtonRect(
- mTaskStackView.useGridLayout()));
+ Rect actionButtonRect = new Rect(mTaskStackView.mLayoutAlgorithm.getStackActionButtonRect());
int left = isLayoutRtl()
? actionButtonRect.left - mStackActionButton.getPaddingLeft()
: actionButtonRect.right + mStackActionButton.getPaddingRight()
// Get the current transform for the task, which will be used to position it offscreen
stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform,
- null, mStackView.useGridLayout());
+ null);
if (hideTask) {
tv.setVisibility(View.INVISIBLE);
// Get the current transform for the task, which will be updated to the final transform
// to animate to depending on how recents was invoked
stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform,
- null, mStackView.useGridLayout());
+ null);
if (launchState.launchedFromApp && !launchState.launchedViaDockGesture) {
if (task.isLaunchTarget) {
}
}
+ /**
+ * The state telling the algorithm whether to use grid layout or not.
+ */
+ public static class GridState {
+ private boolean mDraggingOverDockedState;
+ private boolean mHasDockedTask;
+
+ private GridState() {
+ mDraggingOverDockedState = false;
+ mHasDockedTask = false;
+ }
+
+ /**
+ * Check whether we should use the grid layout.
+ * We use the grid layout for Recents iff all the following is true:
+ * 1. Grid-mode is enabled.
+ * 2. The activity is not in split screen mode (there's no docked task).
+ * 3. The user is not dragging a task view over the dock state.
+ * @return True if we should use the grid layout.
+ */
+ boolean useGridLayout() {
+ return Recents.getConfiguration().isGridEnabled &&
+ !mDraggingOverDockedState &&
+ !mHasDockedTask;
+ }
+
+ public void setDragging(boolean draggingOverDockedState) {
+ mDraggingOverDockedState = draggingOverDockedState;
+ }
+
+ public void setHasDockedTasks(boolean hasDockedTask) {
+ mHasDockedTask = hasDockedTask;
+ }
+ }
+
// A report of the visibility state of the stack
public class VisibilityReport {
public int numVisibleTasks;
Context mContext;
private StackState mState = StackState.SPLIT;
+ private GridState mGridState = new GridState();
private TaskStackLayoutAlgorithmCallbacks mCb;
// The task bounds (untransformed) for layout. This rect is anchored at mTaskRoot.
}
}
- public Rect getStackActionButtonRect(boolean useGridLayout) {
- return useGridLayout
+ public Rect getStackActionButtonRect() {
+ return mGridState.useGridLayout()
? mTaskGridLayoutAlgorithm.getStackActionButtonRect() : mStackActionButtonRect;
}
}
/**
+ * Returns the current grid layout state.
+ */
+ public GridState getGridState() {
+ return mGridState;
+ }
+
+ /**
* Returns whether this stack layout has been initialized.
*/
public boolean isInitialized() {
* is what the view is measured and laid out with.
*/
public TaskViewTransform getStackTransform(Task task, float stackScroll,
- TaskViewTransform transformOut, TaskViewTransform frontTransform,
- boolean useGridLayout) {
+ TaskViewTransform transformOut, TaskViewTransform frontTransform) {
return getStackTransform(task, stackScroll, mFocusState, transformOut, frontTransform,
- false /* forceUpdate */, false /* ignoreTaskOverrides */, useGridLayout);
+ false /* forceUpdate */, false /* ignoreTaskOverrides */);
}
public TaskViewTransform getStackTransform(Task task, float stackScroll,
TaskViewTransform transformOut, TaskViewTransform frontTransform,
- boolean ignoreTaskOverrides, boolean useGridLayout) {
+ boolean ignoreTaskOverrides) {
return getStackTransform(task, stackScroll, mFocusState, transformOut, frontTransform,
- false /* forceUpdate */, ignoreTaskOverrides, useGridLayout);
+ false /* forceUpdate */, ignoreTaskOverrides);
}
public TaskViewTransform getStackTransform(Task task, float stackScroll, int focusState,
TaskViewTransform transformOut, TaskViewTransform frontTransform, boolean forceUpdate,
- boolean ignoreTaskOverrides, boolean useGridLayout) {
+ boolean ignoreTaskOverrides) {
if (mFreeformLayoutAlgorithm.isTransformAvailable(task, this)) {
mFreeformLayoutAlgorithm.getTransform(task, transformOut, this);
return transformOut;
- } else if (useGridLayout) {
+ } else if (mGridState.useGridLayout()) {
int taskIndex = mTaskIndexMap.get(task.key.id);
int taskCount = mTaskIndexMap.size();
mTaskGridLayoutAlgorithm.getTransform(taskIndex, taskCount, transformOut, this);
*/
public TaskViewTransform getStackTransformScreenCoordinates(Task task, float stackScroll,
TaskViewTransform transformOut, TaskViewTransform frontTransform,
- Rect windowOverrideRect, boolean useGridLayout) {
+ Rect windowOverrideRect) {
TaskViewTransform transform = getStackTransform(task, stackScroll, mFocusState,
transformOut, frontTransform, true /* forceUpdate */,
- false /* ignoreTaskOverrides */, useGridLayout);
+ false /* ignoreTaskOverrides */);
return transformToScreenCoordinates(transform, windowOverrideRect);
}
private int mTaskCornerRadiusPx;
private int mDividerSize;
private int mStartTimerIndicatorDuration;
- private boolean mDraggingOverDockState;
@ViewDebug.ExportedProperty(category="recents")
private boolean mTaskViewsClipDirty = true;
// Calculate the current and (if necessary) the target transform for the task
transform = mLayoutAlgorithm.getStackTransform(task, curStackScroll,
- taskTransforms.get(i), frontTransform, ignoreTaskOverrides, useGridLayout());
+ taskTransforms.get(i), frontTransform, ignoreTaskOverrides);
if (useTargetStackScroll && !transform.visible) {
// If we have a target stack scroll and the task is not currently visible, then we
// just update the transform at the new scroll
// TODO: Optimize this
transformAtTarget = mLayoutAlgorithm.getStackTransform(task, targetStackScroll,
- new TaskViewTransform(), frontTransformAtTarget, useGridLayout());
+ new TaskViewTransform(), frontTransformAtTarget);
if (transformAtTarget.visible) {
transform.copyFrom(transformAtTarget);
}
} else {
mLayoutAlgorithm.getStackTransform(task, mStackScroller.getStackScroll(),
focusState, transform, null, true /* forceUpdate */,
- false /* ignoreTaskOverrides */, useGridLayout());
+ false /* ignoreTaskOverrides */);
}
transform.visible = true;
}
Task task = tasks.get(i);
TaskViewTransform transform = transformsOut.get(i);
mLayoutAlgorithm.getStackTransform(task, stackScroll, focusState, transform, null,
- true /* forceUpdate */, ignoreTaskOverrides, useGridLayout());
+ true /* forceUpdate */, ignoreTaskOverrides);
transform.visible = true;
}
}
// Enlarge the dragged view slightly
float finalScale = event.taskView.getScaleX() * DRAG_SCALE_FACTOR;
mLayoutAlgorithm.getStackTransform(event.task, getScroller().getStackScroll(),
- mTmpTransform, null, useGridLayout());
+ mTmpTransform, null);
mTmpTransform.scale = finalScale;
mTmpTransform.translationZ = mLayoutAlgorithm.mMaxTranslationZ + 1;
mTmpTransform.dimAlpha = 0f;
Interpolators.FAST_OUT_SLOW_IN);
boolean ignoreTaskOverrides = false;
if (event.dropTarget instanceof TaskStack.DockState) {
- mDraggingOverDockState = true;
+ mLayoutAlgorithm.getGridState().setDragging(true);
// Calculate the new task stack bounds that matches the window size that Recents will
// have after the drop
final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget;
updateLayoutAlgorithm(true /* boundScroll */);
ignoreTaskOverrides = true;
} else {
- mDraggingOverDockState = false;
+ mLayoutAlgorithm.getGridState().setDragging(false);
// Restore the pre-drag task stack bounds, but ensure that we don't layout the dragging
// task view, so add it back to the ignore set after updating the layout
removeIgnoreTask(event.task);
}
public final void onBusEvent(final DragEndEvent event) {
- mDraggingOverDockState = false;
+ mLayoutAlgorithm.getGridState().setDragging(false);
// We don't handle drops on the dock regions
if (event.dropTarget instanceof TaskStack.DockState) {
// However, we do need to reset the overrides, since the last state of this task stack
public void reloadOnConfigurationChange() {
mStableLayoutAlgorithm.reloadOnConfigurationChange(getContext());
mLayoutAlgorithm.reloadOnConfigurationChange(getContext());
+
+ boolean hasDockedTask = Recents.getSystemServices().hasDockedTask();
+ mStableLayoutAlgorithm.getGridState().setHasDockedTasks(hasDockedTask);
+ mLayoutAlgorithm.getGridState().setHasDockedTasks(hasDockedTask);
}
/**
/**
* Check whether we should use the grid layout.
- * We use the grid layout for Recents iff all the following is true:
- * 1. Grid-mode is enabled.
- * 2. The activity is not in split screen mode (there's no docked task).
- * 3. The user is not dragging a task view over the dock state.
- * @return True if we should use the grid layout.
*/
public boolean useGridLayout() {
- return Recents.getConfiguration().isGridEnabled
- && !Recents.getSystemServices().hasDockedTask()
- && !mDraggingOverDockState;
+ return mLayoutAlgorithm.getGridState().useGridLayout();
}
/**