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

Commit cd3c0b27 authored by Annie Lin's avatar Annie Lin
Browse files

Use screen-based coordinates for AE interactive divider.

Without this, the velocity tracker may calculate unexpected velocity directions (example: http://shortn/_yDEnW9lAgp). Also snap to min/maxPosition when above the MIN_FLING_VELOCITY threshold to be consistent with the system split screen: http://shortn/_nbar2leR9v.

Flag: None - subfeature of unreleased feature
Bug: 343235405
Test: atest DividerPresenterTest
Change-Id: I6f063dcd8dfd63665d6b19679aa1240d5a6c7c88
parent cedec07d
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -514,7 +514,12 @@ class DividerPresenter implements View.OnTouchListener {
                        mProperties.mDividerAttributes, mProperties.mIsVerticalSplit,
                        calculateMinPosition(), calculateMaxPosition());
                mRenderer.setDividerPosition(mDividerPosition);
                switch (event.getAction()) {

                // Convert to use screen-based coordinates to prevent lost track of motion events
                // while moving divider bar and calculating dragging velocity.
                event.setLocation(event.getRawX(), event.getRawY());
                final int action = event.getAction() & MotionEvent.ACTION_MASK;
                switch (action) {
                    case MotionEvent.ACTION_DOWN:
                        onStartDragging(event);
                        break;
@@ -713,9 +718,9 @@ class DividerPresenter implements View.OnTouchListener {
            return snap(dividerPosition, possiblePositions);
        }
        if (velocity < 0) {
            return 0;
            return minPosition;
        } else {
            return fullyExpandedPosition;
            return maxPosition;
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -720,7 +720,7 @@ public class DividerPresenterTest {

        // Divider position is greater than minPosition and the velocity is enough for fling
        assertEquals(
                0, // Closed position
                30, // minPosition
                DividerPresenter.dividerPositionWithDraggingToFullscreenAllowed(
                        50 /* dividerPosition */,
                        30 /* minPosition */,
@@ -731,7 +731,7 @@ public class DividerPresenterTest {

        // Divider position is less than maxPosition and the velocity is enough for fling
        assertEquals(
                1200, // Fully expanded position
                900, // maxPosition
                DividerPresenter.dividerPositionWithDraggingToFullscreenAllowed(
                        800 /* dividerPosition */,
                        30 /* minPosition */,