Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d983386c authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Reverting ag/1288123" into nyc-mr1-dev

parents 8bcd5bc5 08deff0a
Loading
Loading
Loading
Loading
+40 −21
Original line number Diff line number Diff line
@@ -275,10 +275,16 @@ public class TaskStack {
                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
@@ -423,6 +429,7 @@ public class TaskStack {
        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
@@ -451,24 +458,12 @@ public class TaskStack {
            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}.
         */
        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);
        }

        /**
@@ -511,10 +506,34 @@ public class TaskStack {
            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
+3 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.recents.views;

import android.graphics.Rect;

/**
 * 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
     * 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);
}
+4 −10
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public class RecentsView extends FrameLayout {
    private boolean mLastTaskLaunchedWasFreeform;

    @ViewDebug.ExportedProperty(category="recents")
    private Rect mSystemInsets = new Rect();
    Rect mSystemInsets = new Rect();
    private int mDividerSize;

    private Drawable mBackgroundScrim = new ColorDrawable(
@@ -222,13 +222,6 @@ public class RecentsView extends FrameLayout {
        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.
     */
@@ -746,7 +739,8 @@ public class RecentsView extends FrameLayout {
                        ? overrideHintAlpha
                        : viewState.hintTextAlpha;
                Rect bounds = isDefaultDockState
                        ? dockState.getPreDockedBounds(getMeasuredWidth(), getMeasuredHeight())
                        ? dockState.getPreDockedBounds(getMeasuredWidth(), getMeasuredHeight(),
                                mSystemInsets)
                        : dockState.getDockedBounds(getMeasuredWidth(), getMeasuredHeight(),
                                mDividerSize, mSystemInsets, getResources());
                if (viewState.dockAreaOverlay.getCallback() != this) {
+5 −15
Original line number Diff line number Diff line
@@ -45,14 +45,10 @@ import java.util.ArrayList;
 * 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
@@ -120,13 +116,7 @@ public class RecentsViewTouchHandler {
        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;
        }
    }

@@ -237,7 +227,7 @@ public class RecentsViewTouchHandler {
                        // 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;
                            }
                        }
@@ -246,7 +236,7 @@ public class RecentsViewTouchHandler {
                        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;
                                }
+4 −2
Original line number Diff line number Diff line
@@ -218,7 +218,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    // 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) {
@@ -230,7 +231,8 @@ 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, 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) {