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

Unverified Commit 4da1725c 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 53868842
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
import com.android.internal.graphics.ColorUtils;
import com.android.systemui.Flags;
import com.android.systemui.res.R;
import com.android.systemui.screenshot.scroll.CropView.SavedState;

import java.util.List;

@@ -79,8 +80,6 @@ public class CropView extends View {
    private float mMovementStartValue;
    private float mStartingY;  // y coordinate of ACTION_DOWN
    private float mStartingX;
    // The allowable values for the current boundary being dragged
    private Range<Float> mMotionRange;

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