Skip to content
CleverKeys Wiki
implemented v1.5.0 User guide

First Time Setup Technical Specification

Overview

Initial keyboard configuration flow including language pack download and preference initialization.

Key Components

ComponentFilePurpose
Settings ActivitySettingsActivity.ktMain configuration UI
ConfigConfig.ktDefault values and preference keys
DirectBootPrefsDirectBootAwarePreferences.ktDevice-encrypted storage
LauncherLauncherActivity.ktFirst-run Enable/Select Keyboard flow
Language Managerlangpack/LanguagePackManager.ktImport and install language packs (SAF, no network)

Initialization Flow

App Install

First keyboard launch

Check isFirstRun preference

Show setup wizard (if first run)

Layout selection → Language pack download → Theme selection

Mark isFirstRun = false

Normal keyboard operation

Configuration Storage

StorageFileContents
Preferencesshared_prefs/cleverkeys_prefs.xmlUser settings
Device Protectedshared_prefs/neural_performance_stats.xmlStats (encrypted)
Language Packsfiles/langpacks/Imported dictionaries + unigrams (LanguagePackManager.kt:29)

Default Values

Key defaults from Config.kt object Defaults (line 18+):

SettingDefaultSource (Config.kt line)
THEME"cleverkeysdark"20
KEYBOARD_HEIGHT_PORTRAIT2723
KEYBOARD_HEIGHT_LANDSCAPE4024
SHORT_GESTURE_MIN_DISTANCE28 (% of key diagonal)119
SHORT_GESTURE_MAX_DISTANCE141 (% of key diagonal; short/long boundary)120
AUTOCORRECT_ENABLEDtrue176
LONGPRESS_TIMEOUT60085
NEURAL_BEAM_WIDTH6134
NEURAL_MAX_LENGTH20135
NEURAL_CONFIDENCE_THRESHOLD0.01f136
ONNX_XNNPACK_THREADS2299
HAPTIC_ENABLEDtrue75
HAPTIC_SWIPE_COMPLETEtrue84
SMART_PUNCTUATIONtrue95
DOUBLE_SPACE_TO_PERIODtrue104
DOUBLE_SPACE_THRESHOLD500105
LANGUAGE_DETECTION_SENSITIVITY0.6f295
CLIPBOARD_HISTORY_LIMIT”0” (unlimited)215

Enable / Select Keyboard Flow (LauncherActivity)

The in-app launcher offers Enable Keyboard and Select Keyboard actions (LauncherActivity.kt:110-111). Select Keyboard never calls showInputMethodPicker() in crash-prone states (UT-6, LauncherActivity.kt:131-164):

  • CleverKeys not yet enabled as an input method → opens the system IME settings screen instead of the picker (isCleverKeysEnabledCompat() check → launchKeyboardSettings()).
  • Enabled and window focused → shows the system input-method picker.
  • Enabled but window unfocused at picker time → falls back to IME settings.

Rationale: showInputMethodPicker() displays a dialog owned by system_server; issuing it while the IME isn’t enabled or the window is unfocused can crash or no-op silently.

Language Pack Import

CleverKeys has no INTERNET permission — language packs are never downloaded by the app. Flow:

  1. Obtain a prebuilt langpack-<lang>.zip (repo scripts/dictionaries/) or build one with scripts/build_langpack.py
  2. Settings → 🌐 Multi-Language → Import Pack (SAF file picker)
  3. Pack contents (manifest.json + dictionary.bin + unigrams.txt) are installed under files/langpacks/
  4. The language becomes selectable; installed packs are detected alongside bundled dictionaries