GNU General Public License v3.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

LeanType:轻量级键盘解决方案的技术探析

LeanType 是一个开源键盘项目,它脱胎于 HeliBoard,增添了不少额外的功能与自定义选项。在这个项目中,团队解决了一些本质上的痛点,并且通过一些独特的技术设计,使其成为了在同类产品中独步天下的佼佼者。

项目背景与痛点

在现代移动设备上,键盘作为一个与用户交互最频繁的入口,不仅仅是文字录入工具,更是用户体验的重要环节。大量现成的键盘解决方案功能单一,难以满足日益增长的个性化需求。LeanType 则扮演了一个创新者的角色,它不仅继承了 HeliBoard 的优良特性,还在其上增加了大量的自定义选项,使得开发者可以根据自己的需求定制独一无二的键盘体验。

该项目之所以重要,是因为它打破了传统键盘设计的桎梏,提供了一个灵活、可扩展的框架,让个人开发者也有可能构建出具有特色的键盘布局和功能。在这种背景下,LeanType 成为了实现差异化竞争的重要途径。

核心技术揭秘

技术架构与设计模式

LeanType 的核心在于其轻量级并且模块化的架构,这使之成为了一个能够迅速响应不同需求的高效解决方案。

模块化设计模式

通过对项目进行模块化处理,LeanType 将不同的功能模块拆分成独立的组件,每个组件都能独立承担各自的职责,并且可以通过简单的配置实现功能的动态加载和卸载。这样的设计不仅提升了代码的可维护性,也让开发者可以根据需求选择开启或关闭特定的功能模块。

graph TD U[用户输入] --> P[预处理] P -->|"输入有效"| K[按键事件分发] K --> C[字符处理] C --> D[显示处理] K -->|"输入无效"| E[错误处理]

上图所示为 LeanType 的输入处理流程,从用户输入开始,输入数据在经过预处理后,被送往按键事件分发模块进行处理,并最终到达显示模块,完成整个数据流的操作。这种层级分明的架构使得功能扩展变得极其简单。

定制化功能

LeanType 的一大亮点是其灵活的自定义选项。不仅支持自定义键盘布局,还支持多语言输入、手势识别等多种高级功能。与竞品不同的是,LeanType 庆幸能通过简单的配置文件实现上述功能,用户无需更改底层代码,大大降低了技术门槛。

功能亮点与差异

LeanType 相比 HeliBoard,性能优化和自定义配置上的增强是其最大的亮点。用户可以自由调整键盘大小、按键间距、文字大小等参数,并且支持丰富的主题与皮肤,使得界面更加美观。

  • 丰富的自定义选项:LeanType 提供了大量的自定义选项,充分满足用户的个性化需求。
  • 手势操作:整合了丰富的手势识别功能,如长按、拖动等,提升了输入效率。

应用场景与落地建议

在生产环境中使用时,务必注意兼容性和大规模使用的性能问题。LeanType 适合用于那些希望提供高度定制化键盘体验的应用场景,如多语言输入需求较高的跨平台应用。

综合评价

LeanType 正是解决众多开发者和用户个性化需求的重要钥匙,它结合了灵活性与扩展性,搭建了一个高效且易于二次开发的键盘解决方案平台。通过模块化设计和大量的自定义选项,使得 LeanType 拥有了一针见血的优势——几乎可以满足所有键盘相关的业务需求。当然,也有一些尚待改进的空间,比如针对性能优化,以及对更多高级功能的支持,未来的开发可以进一步挑战功能极限,为用户提供更多可能性。

关于

GitHub 原始描述(英文)

LeanType is an Open-source keyboard, fork of HeliBoard with additional features and customisation

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

AIDL
C++
Kotlin
Makefile
Python
Shell

Release

README

LeanType

LeanType Banner

Latest Release Downloads Stars License: GPL v3 Sponsor Donate on Open Collective

A private, smart, and deeply customizable open-source Android keyboard.
Forked from HeliBoard / OpenBoard / AOSP LatinIME.

Screenshots • Download APKs • Flavor Comparison • Features • Setup Guide • Ecosystem • Other Projects


🚀 Overview

LeanType combines the trusted, lightweight, privacy-focused foundation of HeliBoard with modern productivity features: Multi-Provider Cloud, Self-Hosted & Offline AI proofreading, On-Device Whisper Voice Typing, Handwriting Recognition, In-Keyboard Offline Camera & Screenshot OCR, GIF Search & Media Picker, CJK (Chinese, Japanese & Korean) Engine, Hexagonal Honeycomb Layouts, Real-time Inline Math Calculations, Zero-Latency Custom Sound Packs, Live System Wallpaper Blur, Auto Floating in Landscape, Smart Toolbar Auto-Spanning, Built-in Self-Updater, and Rich Text Tools, while keeping you in complete control over your data.


📸 Screenshots

Plugins & Capabilities LeanType Settings Voice Input Settings Text Recognition Settings Translation Settings AI Integration Appearance & Theme Gesture Typing Suggestions & Correction

📦 Flavor Comparison

LeanType is available in two purpose-built flavors designed to match your exact privacy preferences, hardware specifications, and feature requirements:

Feature / Capability 🌿 Standard (Recommended)
-standard-release.apk
🛡️ Offline
-offline-release.apk
Target Audience Recommended (F-Droid & Direct users) Privacy purists & Air-gapped devices
Cloud AI (Gemini, Groq, OpenAI) ✅ Yes ❌ No
Offline AI (Local GGUF via llama.cpp) ❌ No ✅ Yes (Android 8.0+ via plugin)
Translation (Offline & AI) ✅ Yes (Plugin or AI) ✅ Yes (via Plugin)
Voice Typing (On-device Whisper) ✅ Yes (via plugin) ✅ Yes (via plugin)
Handwriting Input ✅ Yes (via plugin) ✅ Yes (via plugin)
OCR Text Extraction (Camera & Screenshots) ✅ Yes (via plugin) ✅ Yes (via plugin)
Release Update Checker ✅ Yes (GitHub Releases / View Release) ❌ No
Plugins & Models Setup In-app download or File import Browser download + File import
Internet Permission 🌐 Optional (Cloud AI / Updates) 🚫 None (OS-level blocked)
Package ID com.leanbitlab.leantype com.leanbitlab.leantype.offline
Min Android Version Android 6.0+ (SDK 23) Android 5.0+ (SDK 21)
Approximate APK Size ~12.8 MB ~12.5 MB
Tip 提示

APK Installation Notice: Google Play Protect or your browser may block direct APK installations downloaded from web browsers. If you experience installation issues, install via Obtainium or a package manager like App Manager.


✨ Features

🤖 AI Integration & Smart Tools

  • Multi-Provider Cloud & Self-Hosted AI: Integrated proofreading, grammar correction, and text rewriting powered by Google Gemini, Groq (Llama 3.3, Mixtral, DeepSeek), OpenAI, or any Self-Hosted local LLM server (Ollama, LM Studio, LocalAI, vLLM, or custom OpenAI-compatible endpoints).
  • Dynamic Model Fetching: Automatically fetches and populates the latest available model IDs directly from your cloud or self-hosted provider.
  • 🛡️ Offline Neural Proofreading (GGUF): Run compact, quantized GGUF language models directly on your device via embedded llama.cpp (100% private, zero network access in offline flavor).
  • 🌐 Multi-Mode In-Keyboard Translation: Translate text directly into any language without switching apps. Choose between Offline Translation Plugin (supported across all flavors), Built-in Offline Translation (ML Kit), or your configured Cloud / Self-Hosted AI Provider (Gemini, Groq, OpenAI, Ollama) with seamless fallback.
  • 🧠 Custom AI Keys & Capsules: Assign custom prompts, personas (#editor, #proofread), and themed tag capsules to 10 customizable toolbar keys.

🈲 Multilingual & CJK Support

  • CJK (Chinese, Japanese & Korean) Plugin Engine: Complete East Asian language typing via companion plugin without bloating the core app.
  • Chinese Pinyin: Smart Pinyin input engine with fuzzy matching, syllable segmentation, and contextual multi-character phrase predictions (Simplified and Traditional).
  • Japanese Kana & Romaji: 12-key Flick input and standard QWERTY Romaji with live Kana-to-Kanji candidate dictionary lookups.
  • Korean Hangul: 2-Set (Dubeolsik) and 10-key Chunjiin layouts with real-time on-the-fly Jamo syllable combiner (Choseong, Jungseong, Jongseong).
  • Dynamic Candidate Strip: High-performance scrolling candidate bar with expansion grid overlay and frequency-weighted ranking.

📷 Offline Camera & Screenshot OCR

  • In-Keyboard Camera Viewfinder: Open a live camera viewfinder directly inside the keyboard to extract printed or handwritten text with 1 tap.
  • Screenshot Suggestion Pill: Automatically detects newly captured screenshots and displays a compact suggestion pill ([OCR] [Screenshot] [X]) for immediate 1-tap text extraction.
  • Advanced Text Cleaners & Formatting: Clean and format recognized text with options for casing transformations, line joining, dehyphenation, punctuation normalization, bullet/list-marker stripping, whitespace trimming, and noise filtering.
  • Customizable Actions: Automatic clipboard copying, direct insertion into active text fields, persistent flash toggle, and search indexing.

🎙️ Voice & Handwriting Input

  • On-Device Whisper Voice Typing: High-accuracy speech recognition powered by compact quantized Whisper models via the LeanType Voice Plugin.
  • Interactive Voice Toolbar: Real-time waveform audio visualizer, silence detection sensitivity slider, and background keep-alive options.
  • ✍️ Handwriting Recognition: Draw characters or words directly on an expansive writing canvas using the LeanType Handwriting Plugin (supported across all flavors), with dedicated settings and in-app/offline model management.

⌨️ Layouts, Audio & Typing

  • ⬡ Hexagonal Honeycomb Layout Engine: Typewise-style (hex_typewise) and hexagonal QWERTY (hex_qwerty) layouts with enlarged touch targets, mathematical axial hit-testing, gesture flicks, and ergonomic landscape thumb split.
  • 🎵 Custom Sound Packs & Audio Customization: Native zero-latency key audio engine with 12+ built-in sound styles (iOS Tap, Mechanical Cherry MX, Thocky Mechanical, Vintage Typewriter, Retro CRT Terminal, Bubble Pop, Soft Velvet, Woodblock Minimal, Acoustic Marimba, Modern Crisp Tick, Sci-Fi, 8-Bit Chiptune Arcade), live sample audition, remote sound pack catalog, and custom .zip pack import.
  • 👆 Gesture / Glide Typing: Smooth swipe typing powered by native C++ libraries (libjni_latinime.so).
  • 👆 Full Keyboard & 2D Backspace Swipe Gestures: Edge-to-edge horizontal swipes across the full keyboard to switch languages, glide the cursor, or toggle numpad, plus 2D multidirectional backspace gestures for vertical multi-line text selection.
  • 📐 Smart Auto-Spanning Toolbar: Dynamically expands and balances toolbar keys symmetrically to prevent awkward gaps across portrait, landscape, and tablet widths.
  • 🧭 Dedicated Text Editing Panel: Gboard-style precision DPAD arrow navigation, selection mode (Shift + arrows), select word, select all, and editing shortcuts.
  • 🖱️ Touchpad Mode: Swipe up on the spacebar to control the cursor freely across the screen, including full-screen laptop-style touchpad mode.
  • 🪟 Native IME Floating Window: Seamless native IME window architecture with zero sensitive permissions (no SYSTEM_ALERT_WINDOW), pass-through background touches, bottom control bar (close, center-drag pill, resize drag handle), multi-touch tracking, zero dead space, and persistent mode memory.
  • 🪟 Auto Floating Keyboard in Landscape: Automatically switches to a compact moveable floating window when entering landscape orientation and restores full docked width in portrait.
  • 🖼️ Live System Wallpaper & FastBlurEngine: Dynamic blurred home/lock screen wallpaper background beneath keys with adjustable blur intensity slider and adaptive contrast.
  • ⚙️ Per-App Profiles & Compatibility Engine: Tailor keyboard behavior per application (Settings → Plugins & Capabilities → App Profiles): enable web editor compatibility, automatic incognito, force non-incognito, direct commit mode, symbol composing (preserving underscores _ in Tasker variables), dialer search field compatibility (TYPE_NULL), and custom Enter action overrides.
  • ⌨️ First-Class Hardware Keyboard Support: Full predictive text, auto-correction, candidate selection shortcuts (1, 2, 3), and D-PAD navigation in emoji palettes for external Bluetooth/USB keyboards, with smart toolbar elevation above the navigation bar.
  • 🎨 Advanced Appearance & Key Ergonomics: Independent corner radius sliders for Normal Keys, Functional Keys (Shift/Backspace), and Action Keys (Enter/Space), adjustable key gaps, customizable padding scales, and distinct Shift/Caps visual state indicators (outline, filled, underlined).
  • ⌨️ Dual Toolbar / Split Suggestions: Option to split suggestions from the quick-action toolbar.
  • 🎨 Custom Layout Profiles: Save up to 5 custom layout profiles with persistent slot index tracking.
  • ⌨️ Direct Switch Target IME & Custom Keycodes: Bind keycode -10076 to any toolbar key to switch directly to a specific target keyboard (e.g. Japanese, Korean, or Chinese IME). See the Comprehensive Keycodes & Actions Reference for the full keycodes catalog.

📋 Clipboard & Productivity

  • 🎬 GIF Search & Media Picker: High-performance in-keyboard GIF and sticker media picker powered by GIPHY and KLIPY, with live animated preview, trending search, recent tray, and automatic WhatsApp sticker normalization (512x512 WebP).
  • 📋 In-Keyboard Action Pill & Multi-Select Clipboard: Gboard-style compact floating action pill on long press (paste, pin, delete, share), multi-select batch deletion/pinning, and sensitive OTP/card data filtering.
  • 🔢 Real-Time Inline Math Calculations: Automatically evaluates mathematical expressions upon typing = (e.g. 25*4=, 500-15%=, (12+8)/4=) and shows the answer directly in the suggestion strip for 1-tap replacement.
  • 🔍 Smart Clipboard History & Inline Editing: Search clips in real-time, swipe right to edit text directly in the toolbar with full gesture cursor/deletion, swipe left to delete with 5s undo, and fold pinned items.
  • 📸 Screenshot Suggestions: Detects recently taken screenshots and offers instant 1-tap sharing via the suggestion strip or clipboard history.
  • 📝 Versatile Text Expander: Built-in shortcut expansion with dynamic variables (%date%, %time%, %clipboard%, %cursor%), composable modifier filters (%clipboard:clean%, :singleline, :title, :slug, :upper, :replace), and automatic Wikipedia / research paper citation cleaner.
  • 💾 Storage & Cache Management: Visual disk space auditing across AI models, dictionaries, sound packs, and media cache, with 1-tap cache purging and history reset (Settings → Plugins → Storage & Cache).
  • 🔐 Granular Backup & Encrypted API Key Export: Export preferences, layouts, custom wordlists, typing history, and text expander shortcuts separately, with optional AES-256 encrypted export for third-party AI and media API keys.
  • 💾 Selective Category Backup & Restore: Export and restore your data modularly with independent category checkboxes (Layouts, Theme & Custom Backgrounds, Dictionaries & Typing History, Clipboard History, and General Settings) without all-or-nothing overwrites.
  • 🔎 In-Palette Emoji Search: Search emojis instantly by name or keyword directly within the emoji palette view, powered by locale-aware emoji dictionaries.
  • ✉️ Privacy-First OTP Auto-Fill: Notification-based OTP verification code detection without sensitive SMS permissions, with customizable messaging app selection.
  • 📚 Smart Learning & Session Boost: Adaptive personal dictionary learning threshold (1 to 5 times) and dynamic session word boosting.
  • 🚫 Blacklist & Regex Filtering: Filter offensive words or unwanted suggestions with custom regex pattern support.
  • 🔄 Google Dictionary Import: Seamlessly import personal dictionary words exported from Gboard.
  • 🔄 In-App Update Checker: Direct GitHub release checks with single-version changelogs and 1-tap “View Release” redirection (standard flavor).

📥 Download

Get it on GitHub Get it on Obtainium Get it on F-Droid Get Pre-release

🛠️ Setup Guide

1. Cloud & Self-Hosted AI Setup (Gemini / Groq / OpenAI / Ollama)

  1. Cloud API: Obtain an API key from Google AI Studio or Groq Console.
  2. Self-Hosted AI: Run Ollama, LM Studio, or LocalAI on your local network (e.g. http://192.168.1.100:11434/v1).
  3. Open Settings → AI Integration → Set AI Provider.
  4. Select your provider (or choose Custom (OpenAI-compatible) for self-hosted instances), enter your endpoint URL/token, and choose your preferred model and target language.
  5. 👉 Read the Full AI & Prompts Guide

2. Voice Input Setup (On-Device Whisper AI)

  1. Download and install the LeanType Voice Plugin APK on your Android device (installed as a background IPC service).
  2. Grant Microphone permission to the LeanType Voice Plugin.
  3. In LeanType, open Settings → Voice typing (or Settings → Plugins → Voice) and tap Whisper Speech Models.
  4. Download or import your preferred Whisper model (e.g. Base ~74 MB recommended).
  5. Tap the microphone icon on the keyboard toolbar to start speech-to-text!

3. Translation Setup (Offline & Online)

  1. Online Flavor (Standard): Open Settings → Translation and tap Download Plugin to install the LeanType Translation Plugin automatically.
  2. Offline Flavor (Offline): Download translation_plugin-arm64-v8a.apk from GitHub Releases and load it in Settings → Plugins → Translation.
  3. Download or import your required language translation models (~30 MB per language).
  4. Tap the Translate icon on the keyboard toolbar to translate selected text or input fields instantly.

4. Handwriting Recognition Setup

  1. Online Flavor (Standard): Open Settings → Handwriting and tap Download Plugin to fetch the LeanType Handwriting Plugin.
  2. Offline Flavor (Offline): Download handwriting_plugin-arm64-v8a.apk from GitHub Releases and load it in Settings → Plugins → Handwriting.
  3. Download or import handwriting recognition models for your languages.
  4. Tap the Handwriting key on the toolbar or long-press spacebar to draw characters on the writing canvas.

5. Offline AI Setup (Local GGUF Models)

  1. Download ai_plugin-arm64-v8a.apk (or ai_plugin-x86_64.apk) from the LeanType Offline AI Plugin Releases.
  2. In LeanType (offline build), navigate to Settings → Plugins → Offline AI and tap Load Offline AI plugin to load the .apk.
  3. Download a compatible GGUF model (e.g. Qwen2.5-0.5B-Instruct-Q4_K_M.gguf or Llama-3.2-1B-Instruct-Q4_K_M.gguf).
  4. In LeanType, navigate to Settings → Advanced → GGUF Model (.gguf) and select the model file from storage.

6. Dictionaries & Gesture Typing Setup

  1. Dictionaries: With unbundled dictionaries in v4.1.6, open Settings → Dictionaries (or tap the dictionary icon on the toolbar when missing) to download or import your language dictionary (.dict).
  2. Gesture Typing: In online builds, open Settings → Gesture typing to download the gesture library automatically. In offline builds, download the library and load via Settings → Gesture typing → Load gesture library.

7. Offline Camera & Screenshot OCR Setup

  1. Online Flavors: Open Settings → OCR & Text Extraction (or Settings → Plugins → OCR) and tap Download Plugin to install the LeanType OCR Plugin.
  2. Offline Flavors: Download ocr_plugin.apk from GitHub Releases and load it in Settings → Plugins → OCR.
  3. Tap the Camera / OCR icon on the toolbar to open the in-keyboard scanner or take a screenshot to see the instant suggestion pill.

8. GIF Search & Media Picker Setup

  1. Open Settings → Plugins → GIF Settings (or tap the GIF key on the toolbar).
  2. Select your preferred provider (GIPHY or KLIPY). Optionally configure custom API keys.
  3. Search trending GIFs, browse stickers, or insert media directly into compatible messaging apps.

9. CJK (Chinese, Japanese & Korean) Setup

  1. Open Settings → Languages → Add language and select Chinese, Japanese, or Korean.
  2. In Settings → Plugins → CJK Settings, enable the CJK Engine (or install the companion plugin if prompted).
  3. Select your input style (e.g. Pinyin for Chinese, Flick/Romaji for Japanese, 2-Set Hangul for Korean) and type with the live candidate strip.

🧩 Ecosystem & Plugins

Expand LeanType with official companion plugins:

Plugin Repository Description
🧠 Offline AI Plugin LeanBitLab/LeanType-Offline-AI-Plugin Dynamic on-device GGUF / llama.cpp proofreading & LLM engine
🎙️ Voice Plugin LeanBitLab/Leantype-Voice-Plugin On-device Whisper speech-to-text engine
📷 OCR Plugin LeanBitLab/LeanType-Ocr-Plugin On-device ML Kit camera viewfinder & screenshot text extraction
🌐 Translation Plugin LeanBitLab/LeanType-Translation-Plugin Dedicated on-device translation provider engine
✍️ Handwriting Plugin LeanBitLab/Leantype-Handwriting-Plugin ML Kit Digital Ink canvas recognition engine
🎬 GIF Plugin LeanBitLab/LeanType-Gif-Plugin In-keyboard GIF & sticker search engine (GIPHY & KLIPY) with WhatsApp normalization
🈲 CJK Plugin LeanBitLab/LeanType-CJK-Plugin Pinyin Chinese, Japanese Romaji/Kana & Korean Hangul input engine
🎵 Sound Packs LeanBitLab/LeanType-SoundPacks Synthesized and physical modeling keypress sound packs
🎨 Community Themes GitHub: leantype-theme Browse and share custom color themes

📱 More Android Projects by LeanBitLab

Discover our complete suite of privacy-first, open-source Android applications and utilities:
👉 Explore All LeanBitLab Android Projects


🤝 Community & Contributing


💖 Support the Project

Building and maintaining privacy-first, on-device AI and keyboard technologies requires continuous hardware testing, compute for model optimization, and development time.

If LeanType improves your daily typing workflow, please consider sponsoring our work!

Sponsor LeanBitLab on GitHub    Donate to LeanBitLab on Open Collective

📜 Credits & Acknowledgments


⚖️ License

LeanType is licensed under the GNU General Public License v3.0 (GPL-3.0).
See the LICENSE file for details.

评论

暂无评论