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

Commit cbe44523 authored by Andrii Kulian's avatar Andrii Kulian Committed by android-build-merger
Browse files

Merge "Revert "Refine divider behavior"" into nyc-dev

am: cddd32fc

* commit 'cddd32fc':
  Revert "Refine divider behavior"
parents 74357cd9 cddd32fc
Loading
Loading
Loading
Loading
+0 −63
Original line number Original line Diff line number Diff line
@@ -82,18 +82,6 @@ public class DividerView extends FrameLayout implements OnTouchListener,


    private static final int TASK_POSITION_SAME = Integer.MAX_VALUE;
    private static final int TASK_POSITION_SAME = Integer.MAX_VALUE;


    /**
     * Fraction of the divider position between two snap targets to switch to the full-screen
     * target.
     */
    private static final float SWITCH_FULLSCREEN_FRACTION = 0.12f;

    /**
     * Fraction of the divider position between two snap targets to switch to the larger target
     * for the bottom/right app layout.
     */
    private static final float BOTTOM_RIGHT_SWITCH_BIGGER_FRACTION = 0.2f;

    /**
    /**
     * How much the background gets scaled when we are in the minimized dock state.
     * How much the background gets scaled when we are in the minimized dock state.
     */
     */
@@ -653,12 +641,6 @@ public class DividerView extends FrameLayout implements OnTouchListener,
                    restrictDismissingTaskPosition(taskPosition, mDockSide, taskSnapTarget);
                    restrictDismissingTaskPosition(taskPosition, mDockSide, taskSnapTarget);
            int taskPositionOther =
            int taskPositionOther =
                    restrictDismissingTaskPosition(taskPosition, dockSideInverted, taskSnapTarget);
                    restrictDismissingTaskPosition(taskPosition, dockSideInverted, taskSnapTarget);

            taskPositionDocked = minimizeHoles(position, taskPositionDocked, mDockSide,
                    taskSnapTarget);
            taskPositionOther = minimizeHoles(position, taskPositionOther, dockSideInverted,
                    taskSnapTarget);

            calculateBoundsForPosition(taskPositionDocked, mDockSide, mDockedTaskRect);
            calculateBoundsForPosition(taskPositionDocked, mDockSide, mDockedTaskRect);
            calculateBoundsForPosition(taskPositionOther, dockSideInverted, mOtherTaskRect);
            calculateBoundsForPosition(taskPositionOther, dockSideInverted, mOtherTaskRect);
            mDisplayRect.set(0, 0, mDisplayWidth, mDisplayHeight);
            mDisplayRect.set(0, 0, mDisplayWidth, mDisplayHeight);
@@ -723,51 +705,6 @@ public class DividerView extends FrameLayout implements OnTouchListener,
        }
        }
    }
    }


    /**
     * Given the current split position and the task position calculated by dragging, this
     * method calculates a "better" task position in a sense so holes get smaller while dragging.
     *
     * @return the new task position
     */
    private int minimizeHoles(int position, int taskPosition, int dockSide,
            SnapTarget taskSnapTarget) {
        if (dockSideTopLeft(dockSide)) {
            if (position > taskPosition) {
                SnapTarget nextTarget = mSnapAlgorithm.getNextTarget(taskSnapTarget);

                // If the next target is the dismiss end target, switch earlier to make the hole
                // smaller.
                if (nextTarget != taskSnapTarget
                        && nextTarget == mSnapAlgorithm.getDismissEndTarget()) {
                    float t = (float) (position - taskPosition)
                            / (nextTarget.position - taskPosition);
                    if (t > SWITCH_FULLSCREEN_FRACTION) {
                        return nextTarget.position;
                    }
                }
            }
        } else if (dockSideBottomRight(dockSide)) {
            if (position < taskPosition) {
                SnapTarget previousTarget = mSnapAlgorithm.getPreviousTarget(taskSnapTarget);
                if (previousTarget != taskSnapTarget) {
                    float t = (float) (taskPosition - position)
                            / (taskPosition - previousTarget.position);

                    // In general, switch a bit earlier (at 20% instead of 50%), but if we are
                    // dismissing the top, switch really early.
                    float threshold = previousTarget == mSnapAlgorithm.getDismissStartTarget()
                            ? SWITCH_FULLSCREEN_FRACTION
                            : BOTTOM_RIGHT_SWITCH_BIGGER_FRACTION;
                    if (t > threshold) {
                        return previousTarget.position;
                    }

                }
            }
        }
        return taskPosition;
    }

    /**
    /**
     * When the snap target is dismissing one side, make sure that the dismissing side doesn't get
     * When the snap target is dismissing one side, make sure that the dismissing side doesn't get
     * 0 size.
     * 0 size.