Skip to content

fix(ime): iOS 2.1 typing fixes behind a debug switch (held letter, two thumbs, Return vs apostrophe) - #448

Merged
Pivii merged 1 commit into
developfrom
fix/443-ios-2-1-typing
Dec 1, 2026
Merged

Pivii merged 1 commit into
developfrom
fix/443-ios-2-1-typing

Conversation

@Pivii

@Pivii Pivii commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #443

Touches letter-key touch handling: Pierre must test it on the Pixel before merge (steps below). Everything is behind a debug switch, off by default: with it off, the keyboard runs develop's code paths unchanged.

What this was for

iOS 2.1 shipped three typing fixes (getdictus/dictus-ios#1097, #1098, #1099). #443 asks for a check of each one on Android, and a fix only where Android has the same defect. Android has a defect on all three points, though not always the one iOS had:

iOS 2.1 point Android on develop This PR (switch on)
#1097, a held letter released without picking an accent typed nothing Released in place, the letter is typed (onPressAtDown, #422/#426). But once the strip is open, any drift of 8 dp picks an accent by x alone, and the French e strip (é è ê ë ę ė ē) is centred on the key. So a held e released a little lower types ë While the finger stays on its own key, level with it or lower, no accent is picked and the letter is typed. Sliding up onto the strip or along the key row still picks one
#1098, two thumbs gave « ee » for « er » No « ee » (each key runs its own gesture, nothing moves a pending key). But a key still held after another finger's lift typed it restarts at the next finger's landing, because ACTION_POINTER_DOWN reaches every held key as a Press. An overlapping roll on e r t types errt A letter key's gesture starts only when its own finger lands (changedToDown), as the space bar's already does. e r t rolled types ert
#1099, Return took taps aimed at the apostrophe after an elision Same geometry as iOS: the AZERTY ' (units 7.5 to 8.5 of row 3) sits over the left end of Return (8.0 to 10.0), the 4 dp gap is split at its middle (#400), and there is no context rule iOS's ApostropheReturnBorder, ported: a tap in the top 0.25 row pitch of Return's touch area, under the apostrophe's column, types the apostrophe when the word before the cursor is c d j l m n s t qu or ends in qu

To test by hand (Pierre, Pixel 4)

Build of this PR's head, debug build. Turn the switch on, then show the keyboard again (the script stops the app):

python3 -I tools/keyboard-bench/dictus_prefs.py --serial <serial> set --bool debug_ios_typing_fixes true

Type in any text field with the Dictus keyboard (French AZERTY).

  1. Held letter, small drift. Hold e until the accents show, roll your thumb a little downward, lift. Expected: e. Switch off, same gesture: ë (develop's behaviour).
  2. Held letter, picking. Hold e, slide up onto é and lift: é. Hold e, slide left along the key row and lift: the accent under the finger (è or é).
  3. Two thumbs. Type fast with two thumbs, letting each thumb land before the other lifts: « une très belle terre », « er », « re », « te ». Expected: no doubled letter and none lost. Switch off, the same rolls should show doubled letters (errt).
  4. Return vs apostrophe. Type c, then tap low on the apostrophe, close to Return: c' and no new line. Same after l, qu, jusqu.
  5. Return still works. Type bonjour, tap the top-left of Return: a new line. Type c, tap the middle of Return: a new line.
  6. Plain typing. A minute of normal one-thumb typing: same as before.

Turn the switch off afterwards with ... set --bool debug_ios_typing_fixes false.

The switch

PreferenceKeys.DEBUG_IOS_TYPING_FIXES (debug_ios_typing_fixes), the same pattern as debug_spatial_autocorrect (#385): it is read in debuggable builds only, no settings screen shows it, and it is off when unset. DictusImeService provides it to the keys as LocalIosTypingFixes (the two letter-key fixes) and LocalApostropheReturnTaps (the border; null when off). With the switch off, KeyButton takes develop's branches: the first change of the Press for the down position, no own-key test, no redirect.

Changes

  • ime/ui/ApostropheReturnBorder.kt (new): ApostropheReturnBorder, the pure rule ported from DictusCore/ApostropheReturnBorder.swift (same reach, same word list, the text read only inside the band). ApostropheReturnTaps is where the adaptive key registers its touch area while it shows '; Return asks it on each tap. After a vowel the adaptive key shows an accent, unregisters, and Return stays Return, as on iOS.
  • ime/ui/KeyButton.kt, the letter/other-key gesture: the own-finger landing check, the own-key test in the accent tracking, and the Return redirect at tap time (the touch-down point, as iOS's first point).
  • ime/DictusImeService.kt: the switch, and the 8 characters before the cursor for the border.
  • core/.../PreferenceKeys.kt: the key.
  • Verify map: typing.accents (held letter) and the switch gotcha in typing.autocorrect.md, and the border plus the two thumbs under keyboard.layout in keyboard.languages.md. No new ID. iOS #1098 added none, and no screen changes.

Tests

New (Robolectric unless noted, French AZERTY, the whole KeyboardScreen):

  • HeldLetterReleaseTest (6): held past the strip and released in place, 0.3 row lower or two rows lower → e. Switch off, 0.3 row lower → ë. Sliding up onto the strip → ë, along the row → è.
  • TwoThumbRollTest (6): e r t overlapping → ert (off: errt); « une tres belle terre » rolled; the second thumb lifting first → er; the first thumb trembling while the second is down → ert; one finger « bonjour ».
  • ApostropheReturnBorderTest (9, plain JVM): iOS's tests on Android's grid (Pixel 4, 393 dp, rows of 53 dp). Pierre's two iOS taps (TJ TAP Integrate native trie behind the IME suggestion contract #69, feat(trie): add hardened n-gram contract #74) land on Return's touch area under the apostrophe's column, and type ' after c, C, Oui, c but Return after bonjour, `` (empty), c , `c'`, `x`. Return's centre and the point below the band stay Return, so does the zone under ⌫, and the apostrophe's centre stays the apostrophe. The word list and the « no text read outside the band » check are covered, and no word of the bench corpus turns a Return into an apostrophe.
  • ApostropheReturnTapUiTest (4): a real tap 2 px under Return's top, under the apostrophe, gives ' after c and Return after bonjour. Return's middle gives Return, and so does the same tap with the switch off.

No word broken: before and after on the same corpus

TwoThumbCorpusTest types the keyboard bench's 40 sentences (tools/keyboard-bench/corpus/{fr,en}.txt, accents dropped: the letter page has no key for them) through the real keyboard, switch off and then on, two ways: one tap after another, as the bench replays them, and as an overlapping roll.

lang way words wrong words, switch off (develop) wrong words, switch on
fr taps 152 0 0
fr roll 152 152 0
en taps 157 0 0
en roll 157 153 0

Taps: identical texts with the switch off and on. Roll: develop doubles almost every letter (jee ssuuiiss eenn rreettaarrdd…), and the switch types every sentence as meant.

Why unit tests and not a run of the emulator bench (tools/keyboard-bench/run.sh): its replay injects one touch at a time (down, up 40 ms later, about 170 ms between taps) and contains no Return. None of the three changes can act on it. Switch on, a press that starts with its own finger behaves as before, an accent is never opened (no press lasts 400 ms), and the border needs a Return tap. The corpus test above replays the same sentences through the real Compose hit test, and also covers the overlapping case the bench cannot inject.

Local

./gradlew :core:testDebugUnitTest :ime:testDebugUnitTest :app:testDebugUnitTest lint assembleDebug: exit code 0 (core 289, ime 863, app 711 tests, 0 failures; lint and assembleDebug green).

Decision left open: iOS's cancel zone (#1097)

iOS 2.1, as Apple's keyboard does, types nothing when a held letter is released at least half a key below the key. Android has never had a way to cancel a held letter, and this PR does not add one: with the switch on, a release two rows down still types the letter. Recommendation: do not port it. On Android it would be a new way to lose a letter, for a thumb that drifts down, which is the complaint #1097 answered. If you want parity with iOS, it is a few lines in the same tracking loop.

Risks

  • Core typing, two thumbs. Switch on, a key whose letter another finger's lift already typed now ignores the next landings until its finger lifts. That is the doubling this removes. When the letters commit is unchanged: on any finger's lift, in press order, as on develop.
  • Held letter. Switch on, the accent right above the key can only be picked by sliding up into the strip, no longer by a slight drift on the key. That drift was the ë defect.
  • Border. After c d j l m n s t qu…, a Return deliberately aimed at the top-left corner of the key types ': the top 13 dp of Return's touch area (2 dp of gap, 11 dp of key), under the apostrophe's column only. The reach (0.25 row pitch) is iOS's, chosen there from two taps, not from a distribution.
  • The redirected tap plays Return's click sound, not a letter's (the sound plays at touch-down, before the decision).

Found on the way, not changed

  • Holding a letter with its accents open while another finger taps a key closes the strip at that finger's lift and types the held letter (or the highlighted accent). Same cause as the early commit noted in fix(ime): a key's preview and pressed state always end with its gesture #422 (Release is the whole POINTER_UP event). That is develop's behaviour, and outside this brief.
  • Android's strip has no option for the held letter (iOS's and Apple's do). That is visual parity, not part of these fixes.

Evidence

Test reports and the corpus table are local, on Titus's machine: /home/pierre/Dev/dictus-proofs/443/.

🤖 Generated with Claude Code

Behind debug_ios_typing_fixes, off by default and read in debuggable
builds only:
- a letter key's gesture starts only when its own finger lands, so an
  overlapping roll no longer types a letter twice (errt for e r t);
- a held letter whose accents opened is typed while the finger stays
  on its own key (a drift no longer types the accent above it);
- a Return tap under the apostrophe's column, in the top quarter row
  pitch, types the apostrophe after a French elision (iOS #1099).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8677a08a-5236-4702-beff-2a12661d2db0
Commits

Reviewing files that changed from the base of the PR and between 3419568 and 1b4fe31.

Files selected for processing: 11

  • .claude/skills/verify-dictus-android/features/keyboard.languages.md
  • .claude/skills/verify-dictus-android/features/typing.autocorrect.md
  • core/src/main/java/dev/pivisolutions/dictus/core/preferences/PreferenceKeys.kt
  • ime/src/main/java/dev/pivisolutions/dictus/ime/DictusImeService.kt
  • ime/src/main/java/dev/pivisolutions/dictus/ime/ui/ApostropheReturnBorder.kt
  • ime/src/main/java/dev/pivisolutions/dictus/ime/ui/KeyButton.kt
  • ime/src/test/java/dev/pivisolutions/dictus/ime/ui/ApostropheReturnBorderTest.kt
  • ime/src/test/java/dev/pivisolutions/dictus/ime/ui/ApostropheReturnTapUiTest.kt
  • ime/src/test/java/dev/pivisolutions/dictus/ime/ui/HeldLetterReleaseTest.kt
  • ime/src/test/java/dev/pivisolutions/dictus/ime/ui/TwoThumbCorpusTest.kt
  • ime/src/test/java/dev/pivisolutions/dictus/ime/ui/TwoThumbRollTest.kt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Pivii
Pivii merged commit 63a8348 into develop Dec 1, 2026
4 checks passed
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.

Keyboard: typing fixes from iOS 2.1 to check on Android (held letter, two thumbs, Return vs apostrophe)

1 participant