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

Commit bf72b68c authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Fix overlay is expanded in split-screen" into main

parents c547cad6 bbc04599
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -658,27 +658,28 @@ class SplitPresenter extends JetpackTaskFragmentOrganizer {
    }

    /**
     * Returns the expanded bounds if the {@code bounds} violate minimum dimension or are not fully
     * covered by the task bounds. Otherwise, returns {@code bounds}.
     * Returns the expanded bounds if the {@code relBounds} violate minimum dimension or are not
     * fully covered by the task bounds. Otherwise, returns {@code relBounds}.
     */
    @NonNull
    static Rect sanitizeBounds(@NonNull Rect bounds, @Nullable Size minDimension,
    static Rect sanitizeBounds(@NonNull Rect relBounds, @Nullable Size minDimension,
                        @NonNull TaskFragmentContainer container) {
        if (bounds.isEmpty()) {
        if (relBounds.isEmpty()) {
            // Don't need to check if the bounds follows the task bounds.
            return bounds;
            return relBounds;
        }
        if (boundsSmallerThanMinDimensions(bounds, minDimension)) {
        if (boundsSmallerThanMinDimensions(relBounds, minDimension)) {
            // Expand the bounds if the bounds are smaller than minimum dimensions.
            return new Rect();
        }
        final TaskContainer taskContainer = container.getTaskContainer();
        final Rect taskBounds = taskContainer.getBounds();
        if (!taskBounds.contains(bounds)) {
        final Rect relTaskBounds = new Rect(taskContainer.getBounds());
        relTaskBounds.offsetTo(0, 0);
        if (!relTaskBounds.contains(relBounds)) {
            // Expand the bounds if the bounds exceed the task bounds.
            return new Rect();
        }
        return bounds;
        return relBounds;
    }

    @Override
+16 −0
Original line number Diff line number Diff line
@@ -408,6 +408,22 @@ public class OverlayPresentationTest {
                .isEmpty()).isTrue();
    }

    @Test
    public void testSanitizeBounds_taskInSplitScreen() {
        final TaskFragmentContainer overlayContainer =
                createTestOverlayContainer(TASK_ID, "test1");
        TaskContainer taskContainer = overlayContainer.getTaskContainer();
        spyOn(taskContainer);
        doReturn(new Rect(TASK_BOUNDS.left + TASK_BOUNDS.width() / 2, TASK_BOUNDS.top,
                TASK_BOUNDS.right, TASK_BOUNDS.bottom)).when(taskContainer).getBounds();
        final Rect taskBounds = taskContainer.getBounds();
        final Rect bounds = new Rect(taskBounds.width() / 2, 0, taskBounds.width(),
                taskBounds.height());

        assertThat(sanitizeBounds(bounds, null, overlayContainer)
                .isEmpty()).isFalse();
    }

    @Test
    public void testCreateOrUpdateOverlayTaskFragmentIfNeeded_createOverlay() {
        final Rect bounds = new Rect(0, 0, 100, 100);