Repository navigation
Text input on Android: the soft keyboard, working keys, and dark mode.
Soft keyboard
Android apps had no on-screen keyboard. Text could only be typed on a hardware keyboard, so on a phone a text field could not be used at all.
- The keyboard appears when a text field or text editor gets focus, and hides when focus leaves it.
- A one-line field shows a Done key, which submits and puts the keyboard away. A text editor shows a newline key instead.
- Back hides the keyboard without leaving the app. Tapping the field again brings it back.
- Suggestions, autocorrect, swipe typing and voice input all work.
NucleantSurfaceViewkeeps a copy of what the keyboard has typed since the last tap, so the keyboard can read back the word it is replacing. Each edit reaches the Swift side as ordinary key presses.
The window says which keyboard it needs through AndroidSurfaceHost.textInputKind (.none, .singleLine or .multiLine), also available as PlatformWindow.textInputKind. NucleantActivity reads it after every frame through nucleantTextInputKind(). The UI layer has to set it: NucleantUI does so from NucleantUI/NucleantUI#43.
Keys
Android key codes are now translated into the macOS virtual key codes the UI layer reads on every platform, as Windows and the browser already were. Before, Backspace reached text fields as Android's KEYCODE_DEL (67) instead of 0x33 and did nothing. Enter, the arrows, Home/End, Page Up/Down, forward delete, Tab, Escape, letters, digits, the keypad and the F-keys were wrong the same way. This works with the existing NucleantUI release.
Dark mode
The Activity now sends Android's dark-mode setting before the app starts and again whenever it changes. This needs no Activity restart, since uiMode is already in the generated manifest's configChanges. Read it from AndroidSurfaceHost.isNightMode, and set AndroidSurfaceHost.onAppearanceChanged to be told when it changes. NucleantUI/NucleantUI#43 uses this so apps follow the system scheme live.
Compatibility
- Additive only: nothing existing changed signature or behaviour.
NucleantActivityandNucleantSurfaceVieware compiled from this package, so an app whoseMainActivity extends NucleantActivitygets the new Java with no changes of its own.- NucleantUI depends on this package
upToNextMinor(from: "0.1.0"), so it resolves to 0.1.1 on its own. A project with 0.1.0 already pinned inPackage.resolvedkeeps it until it updates.
Known limitation
Nothing keeps a focused field clear of the keyboard yet. A field low on the screen can end up behind it.
Pull request: #13
Full Changelog: 0.1.0...0.1.1