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

Unverified Commit ea5bbf9f authored by Cosmin Tanislav's avatar Cosmin Tanislav Committed by Michael Bestas
Browse files

SystemUI: screenshot: remove duplicate clamping on move action

On MotionEvent.ACTION_DOWN, a range of of motion is calculated and
stored. On MotionEvent.ACTION_MOVE, the new position of the crop
boundary is clamped by the original range of motion, and also
clamped again by a new range of motion inside setBoundaryPosition().

The original range of motion is pointless and only used in this case,
remove it.

Change-Id: Ib4f35bf5317f5b5879606680beee3e077f829d10
parent 463caa09
Loading
Loading
Loading
Loading
+1 −5
Original line number Original line Diff line number Diff line
@@ -78,8 +78,6 @@ public class CropView extends View {
    private float mMovementStartValue;
    private float mMovementStartValue;
    private float mStartingY;  // y coordinate of ACTION_DOWN
    private float mStartingY;  // y coordinate of ACTION_DOWN
    private float mStartingX;
    private float mStartingX;
    // The allowable values for the current boundary being dragged
    private Range<Float> mMotionRange;


    // Value [0,1] indicating progress in animateEntrance()
    // Value [0,1] indicating progress in animateEntrance()
    private float mEntranceInterpolation = 1f;
    private float mEntranceInterpolation = 1f;
@@ -172,7 +170,6 @@ public class CropView extends View {
                    mStartingX = event.getX();
                    mStartingX = event.getX();
                    mMovementStartValue = getBoundaryPosition(mCurrentDraggingBoundary);
                    mMovementStartValue = getBoundaryPosition(mCurrentDraggingBoundary);
                    updateListener(MotionEvent.ACTION_DOWN, event.getX());
                    updateListener(MotionEvent.ACTION_DOWN, event.getX());
                    mMotionRange = getAllowedValues(mCurrentDraggingBoundary);
                }
                }
                return true;
                return true;
            case MotionEvent.ACTION_MOVE:
            case MotionEvent.ACTION_MOVE:
@@ -185,8 +182,7 @@ public class CropView extends View {
                                : event.getX(pointerIndex) - mStartingX;
                                : event.getX(pointerIndex) - mStartingX;
                        float delta = pixelDistanceToFraction((int) deltaPx,
                        float delta = pixelDistanceToFraction((int) deltaPx,
                                mCurrentDraggingBoundary);
                                mCurrentDraggingBoundary);
                        setBoundaryPosition(mCurrentDraggingBoundary,
                        setBoundaryPosition(mCurrentDraggingBoundary, mMovementStartValue + delta);
                                mMotionRange.clamp(mMovementStartValue + delta));
                        updateListener(MotionEvent.ACTION_MOVE, event.getX(pointerIndex));
                        updateListener(MotionEvent.ACTION_MOVE, event.getX(pointerIndex));
                        invalidate();
                        invalidate();
                    }
                    }