Skip to content

Fix controls: prevent duplicate bindings#20749

Merged
mikehardy merged 1 commit intoankidroid:mainfrom
manocormen:fix-controls-duplicate-bindings
Apr 19, 2026
Merged

Fix controls: prevent duplicate bindings#20749
mikehardy merged 1 commit intoankidroid:mainfrom
manocormen:fix-controls-duplicate-bindings

Conversation

@manocormen
Copy link
Copy Markdown
Contributor

@manocormen manocormen commented Apr 15, 2026

Purpose / Description

This PR fixes the following bug: In Controls, it is currently possible to end up with conflicting bindings.

For instance, if you

  1. assign "swipe down" to both "Toggle red -> Q" and "Toggle orange -> A"
  2. assign "swipe down" to "Toggle green -> BOTH"

you end up with "swipe down" assigned to both "Toggle orange -> A" and "Toggle green -> BOTH", i.e. duplicate bindings. This happens because we're only removing a single conflicting binding.

Fixes

Approach

When we add a new binding, instead of removing a single conflicting binding, we now retrieve for and remove all conflicting bindings. I did this by introducing a couple of helpers: getPreferencesAssignedTo() and removeDuplicateBindings().

After the fix, the steps above don't produce duplicates anymore:

Screen_recording_20260415_143803.mp4

How Has This Been Tested?

I manually tried various combinations of gesture/key assignments on my physical device.

I ran:

./gradlew jacocoUnitTestReport                      
./gradlew lintRelease ktlintCheck

Checklist

  • 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 NA

@manocormen manocormen marked this pull request as ready for review April 15, 2026 13:11
@david-allison david-allison requested a review from BrayanDSO April 15, 2026 13:17
Copy link
Copy Markdown
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.

Really solid, thank you!!

Comment thread AnkiDroid/src/main/java/com/ichi2/preferences/ReviewerControlPreference.kt Outdated
@manocormen manocormen force-pushed the fix-controls-duplicate-bindings branch from 3e22644 to 5d6a28f Compare April 15, 2026 13:22
@david-allison david-allison added the Needs Second Approval Has one approval, one more approval to merge label Apr 15, 2026
@david-allison david-allison added this to the 2.24 release milestone Apr 15, 2026
Copy link
Copy Markdown
Member

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

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

LGTM - thank you!

@mikehardy mikehardy added this pull request to the merge queue Apr 19, 2026
@mikehardy mikehardy 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 Apr 19, 2026
Merged via the queue into ankidroid:main with commit 4a2ccb4 Apr 19, 2026
15 checks passed
@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 Apr 19, 2026
@manocormen manocormen deleted the fix-controls-duplicate-bindings branch April 19, 2026 14:39
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.

3 participants