How julow/unexpected-keyboard works
Project type and purpose
• This is a single-module, full-stack Android application (an IME keyboard) called “Unexpected Keyboard.”
• Purpose: a lightweight, privacy-conscious virtual keyboard for Android that supports corner-swipe input to access extended characters, plus clipboard history features.
• Deployment: packaged via Gradle, distributed on F-Droid and Google Play with Fastlane scripts.
File structure
• Top level:
– AndroidManifest.xml, res/ (layouts, drawables, values, xml menus), assets/
– srcs/juloo.keyboard2/… Java UI & service code implementing Activities, Services, Views, InputMethod logic
– srcs/compose & srcs/layouts: Python/JSON/XML and Java scripts to generate keyboard layouts and compose files
– build.gradle.kts, gradle/…, shell.nix: build configuration and reproducible environment
– fastlane/metadata: deployment metadata
– check_layout.py, gen_layouts.py, gen_emoji.py: validation and code-generation pipelines
– test/: unit tests for core logic
README for additional insights
• Confirms core feature: swipe to corners for alternate symbols
• No external network calls or analytics (purely local)
• Originally designed for Termux, now general-purpose
Main components
a. Android App UI Layer
– LauncherActivity, SettingsActivity (Activity components)
– Keyboard2View & custom Views (ClipboardHistoryView, EmojiGridView)
b. Input Method / Core Logic
– Keyboard2 (InputMethodService subclass)
– KeyEventHandler, ComposeKey, Modmap – processes touch & swipe events, maps to characters
c. Data & Persistence
– SharedPreferences via DirectBootAwarePreferences
– Custom layouts / extra keys definitions loaded from res/xml & generated XML files
– ClipboardHistoryService & storage for clipboard entries
d. Build & Deployment Pipeline
– Code-gen scripts (gen_layouts.py, compile.py in srcs/compose, SvgToVector.java) produce XML/Java artifacts
– Gradle / Kotlin DSL builds .apk
– Fastlane tasks upload to F-Droid / Google Play
e. Testing
– Unit tests (ModmapTest, KeyValueParserTest) run via Gradle test tasks
Relationships & interactions
• User touch → Android framework → InputMethodService (Keyboard2)
• Keyboard2 delegates to KeyEventHandler / ComposeKeyData → character output
• Swipe gestures trigger alternate key lookup in KeyboardData (populated from generated layouts)
• Clipboard actions routed through ClipboardHistoryService ⇄ persistent storage
• Settings UI reads/writes config via SharedPreferences
• Build pipeline: code-gen scripts → resource generation → Gradle compile → apk → Fastlane publish
Architectural patterns & design principles
• Separation of concerns:
– UI (Activities/Views) vs. InputMethod core vs. Data storage
• Code generation for maintainability: layout definitions centralized in JSON/XML, transformed by scripts
• Modular resource layering: res/xml for keyboard rows, res/layout for dialogs & panes
• Testable core logic separated from Android framework for unit testing