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

Commit f46da69a authored by Ruben Brunk's avatar Ruben Brunk
Browse files

Increased touch tolerance in cropping.

Bug: 7342281

Change-Id: Ice2ba5f07074b1518e4064bbda489aae7ba17b22
parent a4122499
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -189,6 +189,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
        mImageRotate = (ImageRotate) findViewById(R.id.imageRotate);
        mImageRotate = (ImageRotate) findViewById(R.id.imageRotate);
        mImageFlip = (ImageFlip) findViewById(R.id.imageFlip);
        mImageFlip = (ImageFlip) findViewById(R.id.imageFlip);


        ImageCrop.setTouchTolerance((int) getPixelsFromDip(25));
        mImageViews.add(mImageShow);
        mImageViews.add(mImageShow);
        mImageViews.add(mImageCurves);
        mImageViews.add(mImageCurves);
        mImageViews.add(mImageBorders);
        mImageViews.add(mImageBorders);
+9 −5
Original line number Original line Diff line number Diff line
@@ -45,7 +45,7 @@ public class ImageCrop extends ImageGeometry {
    private static final int BOTTOM_LEFT = MOVE_BOTTOM | MOVE_LEFT;
    private static final int BOTTOM_LEFT = MOVE_BOTTOM | MOVE_LEFT;


    private static final float MIN_CROP_WIDTH_HEIGHT = 0.1f;
    private static final float MIN_CROP_WIDTH_HEIGHT = 0.1f;
    private static final int TOUCH_TOLERANCE = 30;
    private static int mTouchTolerance = 45;


    private boolean mFirstDraw = true;
    private boolean mFirstDraw = true;
    private float mAspectWidth = 1;
    private float mAspectWidth = 1;
@@ -97,6 +97,10 @@ public class ImageCrop extends ImageGeometry {
        mAspectHeight = temp;
        mAspectHeight = temp;
    }
    }


    public static void setTouchTolerance(int tolerance){
        mTouchTolerance = tolerance;
    }

    private boolean switchCropBounds(int moving_corner, RectF dst) {
    private boolean switchCropBounds(int moving_corner, RectF dst) {
        RectF crop = getCropBoundsDisplayed();
        RectF crop = getCropBoundsDisplayed();
        float dx1 = 0;
        float dx1 = 0;
@@ -357,20 +361,20 @@ public class ImageCrop extends ImageGeometry {
        // Check left or right.
        // Check left or right.
        float left = Math.abs(x - cropped.left);
        float left = Math.abs(x - cropped.left);
        float right = Math.abs(x - cropped.right);
        float right = Math.abs(x - cropped.right);
        if ((left <= TOUCH_TOLERANCE) && (left < right)) {
        if ((left <= mTouchTolerance) && (left < right)) {
            movingEdges |= MOVE_LEFT;
            movingEdges |= MOVE_LEFT;
        }
        }
        else if (right <= TOUCH_TOLERANCE) {
        else if (right <= mTouchTolerance) {
            movingEdges |= MOVE_RIGHT;
            movingEdges |= MOVE_RIGHT;
        }
        }


        // Check top or bottom.
        // Check top or bottom.
        float top = Math.abs(y - cropped.top);
        float top = Math.abs(y - cropped.top);
        float bottom = Math.abs(y - cropped.bottom);
        float bottom = Math.abs(y - cropped.bottom);
        if ((top <= TOUCH_TOLERANCE) & (top < bottom)) {
        if ((top <= mTouchTolerance) & (top < bottom)) {
            movingEdges |= MOVE_TOP;
            movingEdges |= MOVE_TOP;
        }
        }
        else if (bottom <= TOUCH_TOLERANCE) {
        else if (bottom <= mTouchTolerance) {
            movingEdges |= MOVE_BOTTOM;
            movingEdges |= MOVE_BOTTOM;
        }
        }
        // Check inside block.
        // Check inside block.