new RectF(0, 0.5f, 1, 1));
@Override
- public boolean acceptsDrop(int x, int y, int width, int height, boolean isCurrentTarget) {
- return isCurrentTarget
- ? areaContainsPoint(expandedTouchDockArea, width, height, x, y)
- : areaContainsPoint(touchArea, width, height, x, y);
+ public boolean acceptsDrop(int x, int y, int width, int height, Rect insets,
+ boolean isCurrentTarget) {
+ if (isCurrentTarget) {
+ getMappedRect(expandedTouchDockArea, width, height, mTmpRect);
+ return mTmpRect.contains(x, y);
+ } else {
+ getMappedRect(touchArea, width, height, mTmpRect);
+ updateBoundsWithSystemInsets(mTmpRect, insets);
+ return mTmpRect.contains(x, y);
+ }
}
// Represents the view state of this dock state
private final RectF touchArea;
private final RectF dockArea;
private final RectF expandedTouchDockArea;
+ private static final Rect mTmpRect = new Rect();
/**
* @param createMode used to pass to ActivityManager to dock the task
}
/**
- * Returns whether {@param x} and {@param y} are contained in the area scaled to the
- * given {@param width} and {@param height}.
- */
- public boolean areaContainsPoint(RectF area, int width, int height, float x, float y) {
- int left = (int) (area.left * width);
- int top = (int) (area.top * height);
- int right = (int) (area.right * width);
- int bottom = (int) (area.bottom * height);
- return x >= left && y >= top && x <= right && y <= bottom;
- }
-
- /**
* Returns the docked task bounds with the given {@param width} and {@param height}.
*/
- public Rect getPreDockedBounds(int width, int height) {
- return new Rect((int) (dockArea.left * width), (int) (dockArea.top * height),
- (int) (dockArea.right * width), (int) (dockArea.bottom * height));
+ public Rect getPreDockedBounds(int width, int height, Rect insets) {
+ getMappedRect(dockArea, width, height, mTmpRect);
+ return updateBoundsWithSystemInsets(mTmpRect, insets);
}
/**
int top = dockArea.bottom < 1f
? 0
: insets.top;
- layoutAlgorithm.getTaskStackBounds(displayRect, windowRectOut, top, insets.left,
- insets.right, taskStackBounds);
+ // For now, ignore the left insets since we always dock on the left and show Recents
+ // on the right
+ layoutAlgorithm.getTaskStackBounds(displayRect, windowRectOut, top, 0, insets.right,
+ taskStackBounds);
return taskStackBounds;
}
+
+ /**
+ * Returns the expanded bounds in certain dock sides such that the bounds account for the
+ * system insets (namely the vertical nav bar). This call modifies and returns the given
+ * {@param bounds}.
+ */
+ private Rect updateBoundsWithSystemInsets(Rect bounds, Rect insets) {
+ if (dockSide == DOCKED_LEFT) {
+ bounds.right += insets.left;
+ } else if (dockSide == DOCKED_RIGHT) {
+ bounds.left -= insets.right;
+ }
+ return bounds;
+ }
+
+ /**
+ * Returns the mapped rect to the given dimensions.
+ */
+ private void getMappedRect(RectF bounds, int width, int height, Rect out) {
+ out.set((int) (bounds.left * width), (int) (bounds.top * height),
+ (int) (bounds.right * width), (int) (bounds.bottom * height));
+ }
}
// A comparator that sorts tasks by their freeform state
package com.android.systemui.recents.views;
+import android.graphics.Rect;
+
/**
* Represents a drop target for a drag gesture.
*/
* Returns whether this target can accept this drop. The x,y are relative to the top level
* RecentsView, and the width/height are of the RecentsView.
*/
- boolean acceptsDrop(int x, int y, int width, int height, boolean isCurrentTarget);
+ boolean acceptsDrop(int x, int y, int width, int height, Rect insets, boolean isCurrentTarget);
}
private boolean mLastTaskLaunchedWasFreeform;
@ViewDebug.ExportedProperty(category="recents")
- private Rect mSystemInsets = new Rect();
+ Rect mSystemInsets = new Rect();
private int mDividerSize;
private Drawable mBackgroundScrim = new ColorDrawable(
}
/**
- * Returns whether the nav bar is on the right.
- */
- public boolean isNavBarOnRight() {
- return mSystemInsets.right > 0;
- }
-
- /**
* Returns whether the last task launched was in the freeform stack or not.
*/
public boolean isLastTaskLaunchedFreeform() {
? overrideHintAlpha
: viewState.hintTextAlpha;
Rect bounds = isDefaultDockState
- ? dockState.getPreDockedBounds(getMeasuredWidth(), getMeasuredHeight())
+ ? dockState.getPreDockedBounds(getMeasuredWidth(), getMeasuredHeight(),
+ mSystemInsets)
: dockState.getDockedBounds(getMeasuredWidth(), getMeasuredHeight(),
- mDividerSize, mSystemInsets, getResources());
+ mDividerSize, mSystemInsets, getResources());
if (viewState.dockAreaOverlay.getCallback() != this) {
viewState.dockAreaOverlay.setCallback(this);
viewState.dockAreaOverlay.setBounds(bounds);
* Represents the dock regions for each orientation.
*/
class DockRegion {
- // The phone landscape dock states correspond to the opposite end of the screen that the nav bar
- // appears
- public static TaskStack.DockState[] PHONE_LANDSCAPE_LEFT = {
+ public static TaskStack.DockState[] PHONE_LANDSCAPE = {
+ // We only allow docking to the left in landscape for now on small devices
TaskStack.DockState.LEFT
};
- public static TaskStack.DockState[] PHONE_LANDSCAPE_RIGHT = {
- TaskStack.DockState.RIGHT
- };
public static TaskStack.DockState[] PHONE_PORTRAIT = {
// We only allow docking to the top for now on small devices
TaskStack.DockState.TOP
if (config.isLargeScreen) {
return isLandscape ? DockRegion.TABLET_LANDSCAPE : DockRegion.TABLET_PORTRAIT;
} else {
- if (isLandscape) {
- return mRv.isNavBarOnRight()
- ? DockRegion.PHONE_LANDSCAPE_LEFT
- : DockRegion.PHONE_LANDSCAPE_RIGHT;
- } else {
- return DockRegion.PHONE_PORTRAIT;
- }
+ return isLandscape ? DockRegion.PHONE_LANDSCAPE : DockRegion.PHONE_PORTRAIT;
}
}
// Give priority to the current drop target to retain the touch handling
if (mLastDropTarget != null) {
if (mLastDropTarget.acceptsDrop((int) evX, (int) evY, width, height,
- true /* isCurrentTarget */)) {
+ mRv.mSystemInsets, true /* isCurrentTarget */)) {
currentDropTarget = mLastDropTarget;
}
}
if (currentDropTarget == null) {
for (DropTarget target : mDropTargets) {
if (target.acceptsDrop((int) evX, (int) evY, width, height,
- false /* isCurrentTarget */)) {
+ mRv.mSystemInsets, false /* isCurrentTarget */)) {
currentDropTarget = target;
break;
}
// The drop targets for a task drag
private DropTarget mFreeformWorkspaceDropTarget = new DropTarget() {
@Override
- public boolean acceptsDrop(int x, int y, int width, int height, boolean isCurrentTarget) {
+ public boolean acceptsDrop(int x, int y, int width, int height, Rect insets,
+ boolean isCurrentTarget) {
// This drop target has a fixed bounds and should be checked last, so just fall through
// if it is the current target
if (!isCurrentTarget) {
private DropTarget mStackDropTarget = new DropTarget() {
@Override
- public boolean acceptsDrop(int x, int y, int width, int height, boolean isCurrentTarget) {
+ public boolean acceptsDrop(int x, int y, int width, int height, Rect insets,
+ boolean isCurrentTarget) {
// This drop target has a fixed bounds and should be checked last, so just fall through
// if it is the current target
if (!isCurrentTarget) {