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

Commit 5a9551b0 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Refactor and reduce overrides of `getMovementBounds()`

Fixes: 415107549
Test: atest and presubmits
Flag: EXEMPT minor refactoring
Change-Id: Ia4340f7e537baa62dcbd506b9107464a9700ed29
parent d3ec03ee
Loading
Loading
Loading
Loading
+2 −19
Original line number Diff line number Diff line
@@ -365,30 +365,12 @@ public class PipBoundsAlgorithm implements PipDisplayLayoutState.DisplayIdListen
                mPipDisplayLayoutState.getDisplayLayout() /* displayLayout */);
    }

    /**
     * @return the movement bounds for the given stackBounds and the current state of the
     *         controller.
     */
    public Rect getMovementBounds(Rect stackBounds, boolean adjustForIme) {
        return getMovementBounds(stackBounds, adjustForIme,
                mPipDisplayLayoutState.getDisplayLayout() /* displayLayout */);
    }

    /**
     * @return the movement bounds for the given stackBounds on a given displayLayout and the
     *         current state of the controller.
     */
    public Rect getMovementBounds(Rect stackBounds, DisplayLayout displayLayout) {
        return getMovementBounds(stackBounds, true /* adjustForIme */, displayLayout);
    }

    /**
     * @return the movement bounds for the given stackBounds on a given displayLayout and the
     *         current state of the controller.
     */
    public Rect getMovementBounds(Rect stackBounds, boolean adjustForIme,
            DisplayLayout displayLayout) {
        // TODO(b/415107549): Refactor and reduce the number of `getMovementBounds()` overrides
        final Rect movementBounds = new Rect();
        getInsetBounds(movementBounds, displayLayout);

@@ -507,7 +489,8 @@ public class PipBoundsAlgorithm implements PipDisplayLayoutState.DisplayIdListen
     */
    public void snapToMovementBoundsEdge(Rect bounds, DisplayLayout displayLayout) {
        // Get the movement bounds of the display
        final Rect movementBounds = getMovementBounds(bounds, displayLayout);
        final Rect movementBounds = getMovementBounds(bounds, true /* adjustForIme */,
                displayLayout);
        final int leftEdge = bounds.left;

        final int fromLeft = Math.abs(leftEdge - movementBounds.left);
+4 −2
Original line number Diff line number Diff line
@@ -848,7 +848,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb
            // Calculate the PiP bounds in the new orientation based on same fraction along the
            // rotated movement bounds.
            final Rect postChangeMovementBounds = mPipBoundsAlgorithm.getMovementBounds(
                    postChangeBounds, false /* adjustForIme */);
                    postChangeBounds, false /* adjustForIme */,
                    mPipDisplayLayoutState.getDisplayLayout());
            pipSnapAlgorithm.applySnapFraction(postChangeBounds, postChangeMovementBounds,
                    snapFraction, mPipBoundsState.getStashedState(),
                    mPipBoundsState.getStashOffset(),
@@ -1201,7 +1202,8 @@ public class PipController implements PipTransitionController.PipTransitionCallb
        // Calculate the stack bounds in the new orientation based on same fraction along the
        // rotated movement bounds.
        final Rect postChangeMovementBounds = mPipBoundsAlgorithm.getMovementBounds(
                postChangeStackBounds, false /* adjustForIme */);
                postChangeStackBounds, false /* adjustForIme */,
                mPipDisplayLayoutState.getDisplayLayout());
        pipSnapAlgorithm.applySnapFraction(postChangeStackBounds, postChangeMovementBounds,
                snapFraction, mPipBoundsState.getStashedState(), mPipBoundsState.getStashOffset(),
                mPipDisplayLayoutState.getDisplayBounds(),