Skip to content

Bug fix - Gesture navigation overriding Slider#20419

Merged
BrayanDSO merged 1 commit intoankidroid:mainfrom
lonewolf2208:bug-fix-gesture-navigation
Mar 14, 2026
Merged

Bug fix - Gesture navigation overriding Slider#20419
BrayanDSO merged 1 commit intoankidroid:mainfrom
lonewolf2208:bug-fix-gesture-navigation

Conversation

@lonewolf2208
Copy link
Contributor

@lonewolf2208 lonewolf2208 commented Mar 8, 2026

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 -

After Before
Screen_recording_20260308_230542.mp4
Screen_recording_20260308_224742.mp4

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner


binding.slider.apply {
valueTo = cardsCount.toFloat()
doOnLayout {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the gesture exclusion area once the slider has its final size

Copy link
Member

@david-allison david-allison Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 { _, _, _, _, _, _, _, _, _ ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the exclusion area again if the slider layout changes later

@lonewolf2208 lonewolf2208 marked this pull request as ready for review March 8, 2026 18:19
Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@david-allison david-allison added the Needs Second Approval Has one approval, one more approval to merge label Mar 8, 2026
@BrayanDSO BrayanDSO added this pull request to the merge queue Mar 14, 2026
@BrayanDSO
Copy link
Member

Looks great. Thanks

@BrayanDSO BrayanDSO added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Mar 14, 2026
Merged via the queue into ankidroid:main with commit 333e662 Mar 14, 2026
19 checks passed
@github-actions github-actions bot added this to the 2.24 release milestone Mar 14, 2026
@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Mar 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Previewer: Gesture navigation overrides interacting with the Slider

3 participants