-
-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#423 Fixed accidentally swiping back on newer Android devices when tr… #425
Conversation
…hen trying to resize the crop window
@@ -193,6 +196,9 @@ | |||
/** Used to set back LayerType after changing to software. */ | |||
private var mOriginalLayerType: Int? = null | |||
|
|||
/** The maximum vertical gesture exclusion allowed by Android (200dp) in px. **/ | |||
private val maxVerticalGestureExclusion = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200f, Resources.getSystem().displayMetrics) |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style.
/** | ||
* Newer Android phones let you go back by swiping from the left or right edge of the screen inwards. | ||
* When the crop window is near the edge it's easy to accidentally swipe back when trying to resize it. | ||
* This can be prevented by setting systemGestureExclusionRects. However Android lets you only exclude max 200dp in total vertically. |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style.
* Newer Android phones let you go back by swiping from the left or right edge of the screen inwards. | ||
* When the crop window is near the edge it's easy to accidentally swipe back when trying to resize it. | ||
* This can be prevented by setting systemGestureExclusionRects. However Android lets you only exclude max 200dp in total vertically. | ||
* Therefore a top, middle and bottom strip are used so at least the corners and the vertical middle of the crop window are covered. |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style.
|
||
rectMiddle.left = rectTop.left | ||
rectMiddle.right = rectTop.right | ||
rectMiddle.top = ((cropWindowRect.top + cropWindowRect.bottom)/2.0f - (maxVerticalGestureExclusion * 0.2f)).toInt() |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style.
@@ -193,6 +196,9 @@ | |||
/** Used to set back LayerType after changing to software. */ | |||
private var mOriginalLayerType: Int? = null | |||
|
|||
/** The maximum vertical gesture exclusion allowed by Android (200dp) in px. **/ | |||
private val maxVerticalGestureExclusion = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200f, Resources.getSystem().displayMetrics) |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.
|
||
rectMiddle.left = rectTop.left | ||
rectMiddle.right = rectTop.right | ||
rectMiddle.top = ((cropWindowRect.top + cropWindowRect.bottom)/2.0f - (maxVerticalGestureExclusion * 0.2f)).toInt() |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.
I fixed the spaces and pushed it, do I need to do something here to trigger a check? |
rectTop.left = (cropWindowRect.left - mTouchRadius).toInt() | ||
rectTop.right = (cropWindowRect.right + mTouchRadius).toInt() | ||
rectTop.top = (cropWindowRect.top - mTouchRadius).toInt() | ||
rectTop.bottom = (rectTop.top + (maxVerticalGestureExclusion * 0.3f)).toInt() |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.
rectMiddle.left = rectTop.left | ||
rectMiddle.right = rectTop.right | ||
rectMiddle.top = ((cropWindowRect.top + cropWindowRect.bottom)/2.0f - (maxVerticalGestureExclusion * 0.2f)).toInt() | ||
rectMiddle.bottom = (rectMiddle.top + (maxVerticalGestureExclusion * 0.4f)).toInt() |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.
rectBottom.left = rectTop.left | ||
rectBottom.right = rectTop.right | ||
rectBottom.bottom = (cropWindowRect.bottom + mTouchRadius).toInt() | ||
rectBottom.top = (rectBottom.bottom - (maxVerticalGestureExclusion * 0.3f)).toInt() |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers.
I need to trigger, is a github protection on public repositories because of people changing the CI to mine cryptocoins |
@Janneman84 look good from my side, some lint issues. Check the contributing guide to run the lint tool and fix =D |
More two points
|
Oops forgot the one space, fixed it now. However this thing is not an option. It's a fix to an issue that always works. I can't think of any practical reason why you would not want it to do what it does. Therefore it's not an option and therefore needs not to be added to the feature list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work, thanks for it
Nicely done @Janneman84 ! |
Fixed accidentally swiping back on newer Android devices when trying to resize the crop window.
Some newer phones with Android 10 or newer allow you to remove the three navigation buttons and use a gesture bar instead. You're supposed to go back by swiping the left or right edge of the screen inwards. When the crop window is near the edge and you try to resize it you often accidentally swipe back instead.
This was fixed by setting
systemGestureExclusionRects
. Since Android allows only a max of 200dp to be excluded vertically this is divided among the corners and middle of the crop window (so 3 zones).To reproduce:
Check list for the Code Reviewer: