Bug fix - Gesture navigation overriding Slider#20419
Bug fix - Gesture navigation overriding Slider#20419BrayanDSO merged 1 commit intoankidroid:mainfrom
Conversation
|
|
||
| binding.slider.apply { | ||
| valueTo = cardsCount.toFloat() | ||
| doOnLayout { |
There was a problem hiding this comment.
Set the gesture exclusion area once the slider has its final size
There was a problem hiding this comment.
Prefer code comments, rather than GitHub comments
If it's useful for reviewers, it'll be useful for future maintainers in the codebase
| doOnLayout { | ||
| updateSliderGestureExclusion(this) | ||
| } | ||
| addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> |
There was a problem hiding this comment.
Update the exclusion area again if the slider layout changes later
There was a problem hiding this comment.
This is excellent, thank you!!!
I was concerned that this would block gestures while the indicator was away from the edges.
vertical phone ✅
If the indicator is not touching an edge, no matter how close to the edge a user taps, the toggle moves to the extremity, so navigation gestures should not occur
horizontal phone ✅
Swiping on the notch performs a navigation gesture
|
Looks great. Thanks |
Purpose / Description
Dragging the Previewer slider from the screen edges can trigger Android’s back gesture instead of moving the slide .
Fixes
Approach
I initially tried requestDisallowInterceptTouchEvent() while dragging the slider, but that did not fully solve the issue because the system back gesture could still win before the slider started tracking the touch.
The final fix uses
ViewCompat.setSystemGestureExclusionRects()on the slider bounds, and refreshes that rect after layout changes. That prevents edge back gestures from taking over when the user starts dragging from either end of the slider.How Has This Been Tested?
Tested the changes manually -
Screen_recording_20260308_230542.mp4
Screen_recording_20260308_224742.mp4
Checklist
Please, go through these checks before submitting the PR.