Reverting ag/1288123
am: 08deff0a67
Change-Id: I13bdc80c790dc1563f6839a98d6dbfce283a2baa
This commit is contained in:
@@ -275,10 +275,16 @@ public class TaskStack {
|
|||||||
new RectF(0, 0.5f, 1, 1));
|
new RectF(0, 0.5f, 1, 1));
|
||||||
|
|
||||||
@Override
|
@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,
|
||||||
return isCurrentTarget
|
boolean isCurrentTarget) {
|
||||||
? areaContainsPoint(expandedTouchDockArea, width, height, x, y)
|
if (isCurrentTarget) {
|
||||||
: areaContainsPoint(touchArea, width, height, x, y);
|
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
|
// Represents the view state of this dock state
|
||||||
@@ -423,6 +429,7 @@ public class TaskStack {
|
|||||||
private final RectF touchArea;
|
private final RectF touchArea;
|
||||||
private final RectF dockArea;
|
private final RectF dockArea;
|
||||||
private final RectF expandedTouchDockArea;
|
private final RectF expandedTouchDockArea;
|
||||||
|
private static final Rect mTmpRect = new Rect();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param createMode used to pass to ActivityManager to dock the task
|
* @param createMode used to pass to ActivityManager to dock the task
|
||||||
@@ -451,24 +458,12 @@ public class TaskStack {
|
|||||||
viewState.update(context);
|
viewState.update(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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}.
|
* Returns the docked task bounds with the given {@param width} and {@param height}.
|
||||||
*/
|
*/
|
||||||
public Rect getPreDockedBounds(int width, int height) {
|
public Rect getPreDockedBounds(int width, int height, Rect insets) {
|
||||||
return new Rect((int) (dockArea.left * width), (int) (dockArea.top * height),
|
getMappedRect(dockArea, width, height, mTmpRect);
|
||||||
(int) (dockArea.right * width), (int) (dockArea.bottom * height));
|
return updateBoundsWithSystemInsets(mTmpRect, insets);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -511,10 +506,34 @@ public class TaskStack {
|
|||||||
int top = dockArea.bottom < 1f
|
int top = dockArea.bottom < 1f
|
||||||
? 0
|
? 0
|
||||||
: insets.top;
|
: insets.top;
|
||||||
layoutAlgorithm.getTaskStackBounds(displayRect, windowRectOut, top, insets.left,
|
// For now, ignore the left insets since we always dock on the left and show Recents
|
||||||
insets.right, taskStackBounds);
|
// on the right
|
||||||
|
layoutAlgorithm.getTaskStackBounds(displayRect, windowRectOut, top, 0, insets.right,
|
||||||
|
taskStackBounds);
|
||||||
return 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
|
// A comparator that sorts tasks by their freeform state
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.systemui.recents.views;
|
package com.android.systemui.recents.views;
|
||||||
|
|
||||||
|
import android.graphics.Rect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a drop target for a drag gesture.
|
* Represents a drop target for a drag gesture.
|
||||||
*/
|
*/
|
||||||
@@ -25,5 +27,5 @@ public interface DropTarget {
|
|||||||
* Returns whether this target can accept this drop. The x,y are relative to the top level
|
* 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.
|
* 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class RecentsView extends FrameLayout {
|
|||||||
private boolean mLastTaskLaunchedWasFreeform;
|
private boolean mLastTaskLaunchedWasFreeform;
|
||||||
|
|
||||||
@ViewDebug.ExportedProperty(category="recents")
|
@ViewDebug.ExportedProperty(category="recents")
|
||||||
private Rect mSystemInsets = new Rect();
|
Rect mSystemInsets = new Rect();
|
||||||
private int mDividerSize;
|
private int mDividerSize;
|
||||||
|
|
||||||
private Drawable mBackgroundScrim = new ColorDrawable(
|
private Drawable mBackgroundScrim = new ColorDrawable(
|
||||||
@@ -222,13 +222,6 @@ public class RecentsView extends FrameLayout {
|
|||||||
return mBackgroundScrim;
|
return mBackgroundScrim;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
* Returns whether the last task launched was in the freeform stack or not.
|
||||||
*/
|
*/
|
||||||
@@ -746,9 +739,10 @@ public class RecentsView extends FrameLayout {
|
|||||||
? overrideHintAlpha
|
? overrideHintAlpha
|
||||||
: viewState.hintTextAlpha;
|
: viewState.hintTextAlpha;
|
||||||
Rect bounds = isDefaultDockState
|
Rect bounds = isDefaultDockState
|
||||||
? dockState.getPreDockedBounds(getMeasuredWidth(), getMeasuredHeight())
|
? dockState.getPreDockedBounds(getMeasuredWidth(), getMeasuredHeight(),
|
||||||
|
mSystemInsets)
|
||||||
: dockState.getDockedBounds(getMeasuredWidth(), getMeasuredHeight(),
|
: dockState.getDockedBounds(getMeasuredWidth(), getMeasuredHeight(),
|
||||||
mDividerSize, mSystemInsets, getResources());
|
mDividerSize, mSystemInsets, getResources());
|
||||||
if (viewState.dockAreaOverlay.getCallback() != this) {
|
if (viewState.dockAreaOverlay.getCallback() != this) {
|
||||||
viewState.dockAreaOverlay.setCallback(this);
|
viewState.dockAreaOverlay.setCallback(this);
|
||||||
viewState.dockAreaOverlay.setBounds(bounds);
|
viewState.dockAreaOverlay.setBounds(bounds);
|
||||||
|
|||||||
@@ -45,14 +45,10 @@ import java.util.ArrayList;
|
|||||||
* Represents the dock regions for each orientation.
|
* Represents the dock regions for each orientation.
|
||||||
*/
|
*/
|
||||||
class DockRegion {
|
class DockRegion {
|
||||||
// The phone landscape dock states correspond to the opposite end of the screen that the nav bar
|
public static TaskStack.DockState[] PHONE_LANDSCAPE = {
|
||||||
// appears
|
// We only allow docking to the left in landscape for now on small devices
|
||||||
public static TaskStack.DockState[] PHONE_LANDSCAPE_LEFT = {
|
|
||||||
TaskStack.DockState.LEFT
|
TaskStack.DockState.LEFT
|
||||||
};
|
};
|
||||||
public static TaskStack.DockState[] PHONE_LANDSCAPE_RIGHT = {
|
|
||||||
TaskStack.DockState.RIGHT
|
|
||||||
};
|
|
||||||
public static TaskStack.DockState[] PHONE_PORTRAIT = {
|
public static TaskStack.DockState[] PHONE_PORTRAIT = {
|
||||||
// We only allow docking to the top for now on small devices
|
// We only allow docking to the top for now on small devices
|
||||||
TaskStack.DockState.TOP
|
TaskStack.DockState.TOP
|
||||||
@@ -120,13 +116,7 @@ public class RecentsViewTouchHandler {
|
|||||||
if (config.isLargeScreen) {
|
if (config.isLargeScreen) {
|
||||||
return isLandscape ? DockRegion.TABLET_LANDSCAPE : DockRegion.TABLET_PORTRAIT;
|
return isLandscape ? DockRegion.TABLET_LANDSCAPE : DockRegion.TABLET_PORTRAIT;
|
||||||
} else {
|
} else {
|
||||||
if (isLandscape) {
|
return isLandscape ? DockRegion.PHONE_LANDSCAPE : DockRegion.PHONE_PORTRAIT;
|
||||||
return mRv.isNavBarOnRight()
|
|
||||||
? DockRegion.PHONE_LANDSCAPE_LEFT
|
|
||||||
: DockRegion.PHONE_LANDSCAPE_RIGHT;
|
|
||||||
} else {
|
|
||||||
return DockRegion.PHONE_PORTRAIT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +227,7 @@ public class RecentsViewTouchHandler {
|
|||||||
// Give priority to the current drop target to retain the touch handling
|
// Give priority to the current drop target to retain the touch handling
|
||||||
if (mLastDropTarget != null) {
|
if (mLastDropTarget != null) {
|
||||||
if (mLastDropTarget.acceptsDrop((int) evX, (int) evY, width, height,
|
if (mLastDropTarget.acceptsDrop((int) evX, (int) evY, width, height,
|
||||||
true /* isCurrentTarget */)) {
|
mRv.mSystemInsets, true /* isCurrentTarget */)) {
|
||||||
currentDropTarget = mLastDropTarget;
|
currentDropTarget = mLastDropTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,7 +236,7 @@ public class RecentsViewTouchHandler {
|
|||||||
if (currentDropTarget == null) {
|
if (currentDropTarget == null) {
|
||||||
for (DropTarget target : mDropTargets) {
|
for (DropTarget target : mDropTargets) {
|
||||||
if (target.acceptsDrop((int) evX, (int) evY, width, height,
|
if (target.acceptsDrop((int) evX, (int) evY, width, height,
|
||||||
false /* isCurrentTarget */)) {
|
mRv.mSystemInsets, false /* isCurrentTarget */)) {
|
||||||
currentDropTarget = target;
|
currentDropTarget = target;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,7 +218,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
|
|||||||
// The drop targets for a task drag
|
// The drop targets for a task drag
|
||||||
private DropTarget mFreeformWorkspaceDropTarget = new DropTarget() {
|
private DropTarget mFreeformWorkspaceDropTarget = new DropTarget() {
|
||||||
@Override
|
@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
|
// This drop target has a fixed bounds and should be checked last, so just fall through
|
||||||
// if it is the current target
|
// if it is the current target
|
||||||
if (!isCurrentTarget) {
|
if (!isCurrentTarget) {
|
||||||
@@ -230,7 +231,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
|
|||||||
|
|
||||||
private DropTarget mStackDropTarget = new DropTarget() {
|
private DropTarget mStackDropTarget = new DropTarget() {
|
||||||
@Override
|
@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
|
// This drop target has a fixed bounds and should be checked last, so just fall through
|
||||||
// if it is the current target
|
// if it is the current target
|
||||||
if (!isCurrentTarget) {
|
if (!isCurrentTarget) {
|
||||||
|
|||||||
Reference in New Issue
Block a user