Skip to content

ADFA-4057 | Add Custom Keyboard template bundle - #144

Merged
jimturner-adfa merged 4 commits into
mainfrom
feature/ADFA-4057-custom-keyboard
Nov 14, 2026
Merged

jimturner-adfa merged 4 commits into
mainfrom
feature/ADFA-4057-custom-keyboard

Conversation

@jimturner-adfa

@jimturner-adfa jimturner-adfa commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

ADFA-4057

Adds templates/Custom-Keyboard, a template that creates an Android keyboard for a language the shipped keyboards do not cover. Kotlin only. Each language is a JSON layout file; adding one needs no code. Ships English (QWERTY) and Hindi (Devanagari).

Review by commit

  1. 7b54453 - verbatim copy of EmptyActivity from core.cgt. Skim.
  2. 45a710b - the keyboard: KeyboardService, KeyboardView, KeyboardLayout, the setup MainActivity, method.xml, layouts, gallery files.

Design choices

  • Written from scratch. FUTO and HeliBoard informed the UX only. HeliBoard is GPL-3.0, which would carry into every generated app, and needs native dictionary libraries (so the NDK). FUTO's licence is not open source. Nothing from Sriboard was inspected or reused.
  • Custom key view, not android.inputmethodservice.KeyboardView (deprecated since API 29). View-based, not Compose: Compose in an InputMethodService needs hand-wired lifecycle owners.
  • Layouts are data. A key commits a string, so conjuncts (क्ष = 3 code points) and nukta forms need no code. Rejected: Pebble parameters for key rows (one text field cannot express a layout) and hard-coded Kotlin keys (every language becomes a code change).
  • Kotlin only. No optional.language, so app/build.gradle.kts drops the ${% if LANGUAGE == 'kotlin' %} wrapper: the strict renderer fails on an undeclared variable.
  • Out of scope: prediction, dictionaries, swipe typing, direct boot (noted in the README).

Testing

Pixel 6 Pro (arm64, API 37), Code on the Go C-d-1014-1359:

  • Installed the .cgt via Add-ons Manager; New Project shows the template with no language chooser. Generated com.example.my_keyboard, built on device (~50 s), installed, ran.
  • Setup flow as a user: "Open keyboard settings" opens the system list, the privacy and direct-boot dialogs appear, "Choose keyboard" opens the picker, the status line moves Not turned on -> Turned on -> Ready.
  • Typing, checked by code point in the field: sentence auto-caps and one-shot shift, caps lock on double-tap, backspace, long-press alternatives (é, ö), symbols, Enter newline in a multi-line field, Search action label and submit in Settings search, नमस्ते, the क्ष conjunct key, nukta via long-press (क़ = U+0915 U+093C), danda.
  • Every key is exposed to TalkBack with a description (via uiautomator; no live TalkBack session).
  • Font scale 1.0 and 2.0, light and dark: keys grow with the font, stay above the navigation bar, the setup screen scrolls and keeps the try-it field above the keyboard.
  • Host: renders and builds debug and release offline; addons check passes.

Fixed during device testing: keys behind the navigation bar on edge-to-edge (Android 15+) keyboards; the try-it field hidden by the keyboard; no capital after Enter; long-press hints covering labels at 2x; popup selection not matching the finger until it moved.

Not tested: a live TalkBack session, API levels below 37.

🤖 Generated with Claude Code

yaturner and others added 2 commits October 19, 2026 09:56
…emplate

Verbatim copy of EmptyActivity from core.cgt, no changes. The next commit
turns it into the keyboard template, so its diff shows only what it adds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Kotlin project template for an Android keyboard in a language the
shipped keyboards do not cover. Written from scratch; FUTO and HeliBoard
informed the UX only (HeliBoard is GPL-3.0 and needs native dictionaries).

- KeyboardService: an InputMethodService that commits text, handles
  one-shot shift and caps lock, symbols, enter actions, sentence
  auto-capitalisation, and code-point-wise delete.
- KeyboardView: custom-drawn keys (the platform KeyboardView is deprecated
  since API 29) with long-press alternatives, backspace repeat, rollover,
  TalkBack via ExploreByTouchHelper, sp-sized labels, and room for the
  navigation bar on edge-to-edge keyboards.
- Layouts are JSON in assets/layouts; a key may output several code
  points. Ships English (QWERTY) and Hindi (Devanagari).
- MainActivity: setup screen to enable and choose the keyboard, and try it.

The template offers no language choice, so the Kotlin block in
app/build.gradle.kts loses its LANGUAGE conditional: the renderer fails
on an undeclared variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jimturner-adfa
jimturner-adfa requested review from a team and removed request for davidschachterADFA and hal-eisen-adfa November 11, 2026 21:40

@hal-eisen-adfa hal-eisen-adfa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few findings from a code read of the keyboard. They have not been reproduced on a device yet.

@jimturner-adfa jimturner-adfa self-assigned this Nov 14, 2026
…ack, help tag

- Hindi symbols row types ASCII digits, with Devanagari in the popup.
  Number and phone fields open on this layer, and their input filters
  accept only ASCII 0-9.
- Returning from symbols keeps caps lock and re-runs auto-capitalize
  instead of forcing shift off.
- Two shift taps in a row lock caps from any state, including ONCE set by
  auto-capitalize, so a sentence start no longer needs three taps.
- KeyboardView points the press at the matching key after a re-render
  (or drops it), so backspace draws pressed and release() never acts on
  a key from the previous layer. Repeat stops if the press is dropped.
- TalkBack: long-press alternatives are custom actions (up to eight per
  key) and the language key has a long-click action for the picker.
- tooltipTag is template.custom.keyboard, not Empty Activity's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jimturner-adfa
jimturner-adfa requested a review from a team November 14, 2026 15:00
@jimturner-adfa
jimturner-adfa merged commit 83c8f60 into main Nov 14, 2026
1 check passed
@jimturner-adfa
jimturner-adfa deleted the feature/ADFA-4057-custom-keyboard branch November 14, 2026 18:47
@jimturner-adfa

Copy link
Copy Markdown
Contributor Author

Device test of 0f930237 on a Pixel 6 Pro. The template was rendered with CoGo's current versions (AGP 9.3.1, Kotlin 2.3.21, Gradle 9.6.1, SDK 36), installed, and selected as the active keyboard. For the numeric case I added an inputType="number" field to my local render only; the PR is unchanged.

Fix Steps Result
Shift after symbols Type Hi. , ?123, ABC, a Hi. A
Double-tap caps lock At a sentence start (shift already ONCE from auto-capitalize), tap shift twice Caps lock after 2 taps
Caps lock across symbols Caps lock on, ab, ?123, 1, ABC, cd AB1CD
Backspace while held Caps off, hold backspace Drawn pressed mid-hold (screenshot), whole field cleared, no repeat after release. Auto-capitalize switched layers during the hold, so this covered the re-render case.
Hindi number field Hindi layout, focus the number field Symbols layer opens with ASCII digits; typed 102
TalkBack actions Throwaway instrumented test reading the key nodes through UiAutomation क lists "Type क़" and "Type क्ष"; running "Type क्ष" typed क्ष. घ has no custom actions. "Switch to EN" has ACTION_LONG_CLICK; a long-press on that key opens the keyboard picker.

The TalkBack check performed the actions through UiAutomation with TalkBack itself off. It shows the actions exist and work, not how TalkBack announces them.

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