Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d790cab7a | ||
|
|
af05da4bbe | ||
|
|
e5ea6e0a41 | ||
|
|
c70a6385da | ||
|
|
2ab0cd16d8 | ||
|
|
e760e1096d | ||
|
|
74319714c0 | ||
|
|
3ebeba0619 | ||
|
|
fa094d0cb0 | ||
|
|
61e270bb3d | ||
|
|
5c0ef34196 | ||
|
|
8d9ab0c1da | ||
|
|
17b6bd4400 | ||
|
|
f56ca42b2c | ||
|
|
6eaf2ad46f | ||
|
|
7256639768 | ||
|
|
1ac7207c90 | ||
|
|
9a644f3100 | ||
|
|
45c65ed1b8 | ||
|
|
6aa15b9cc5 | ||
|
|
35a99fd95d | ||
|
|
db2f74a253 | ||
|
|
78c0b016a5 | ||
|
|
4e074b36fb | ||
|
|
b20d76e232 | ||
|
|
681cb29686 | ||
|
|
73b73d89a2 | ||
|
|
06cb2526a4 | ||
|
|
12a95a4604 | ||
|
|
b263d75373 | ||
|
|
495da34e37 | ||
|
|
a2fc16baeb | ||
|
|
98cf27a3a9 | ||
|
|
31eecc2a13 | ||
|
|
08c895aa12 | ||
|
|
be6f455b01 | ||
|
|
5cba22a19a | ||
|
|
0f2f8a47ff | ||
|
|
affc78fb63 | ||
|
|
5781fb6efc | ||
|
|
6be0938566 | ||
|
|
4520271c8f | ||
|
|
656c1e24f4 | ||
|
|
eb9a5103c2 | ||
|
|
f59603c90b | ||
|
|
4534df8bcb | ||
|
|
ecdb43a593 | ||
|
|
939e8da252 | ||
|
|
e2d5b47c7c | ||
|
|
96966332ce | ||
|
|
b034191a1c | ||
|
|
b86481461a | ||
|
|
5fbd21c7d9 | ||
|
|
b6618444a2 | ||
|
|
4a05bf54d5 | ||
|
|
9c70f1113e | ||
|
|
c0a4bca8e2 | ||
|
|
b6ba00a1f6 | ||
|
|
43550a3ad1 | ||
|
|
b73ac529e8 | ||
|
|
f192dfcb32 | ||
|
|
4ab921f112 | ||
|
|
44dcf6e753 | ||
|
|
ccd9568e3d | ||
|
|
21633f22fd | ||
|
|
c6a568a74b | ||
|
|
241e034a3f | ||
|
|
27329091af | ||
|
|
a7645c3934 | ||
|
|
374c47af9d | ||
|
|
49627b63e3 |
@@ -36,6 +36,8 @@ jobs:
|
||||
java-version: '17'
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v4
|
||||
with:
|
||||
gradle-version: 8.14.4
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
|
||||
@@ -11,3 +11,4 @@
|
||||
# Directory _build is not used anymore
|
||||
/_build
|
||||
/release
|
||||
vendor/libswipetype/
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# Harley's Keyboard - agent notes
|
||||
|
||||
Fork of Julow/Unexpected-Keyboard (Unexpected Keyboard). Android IME, Java, Gradle Kotlin DSL.
|
||||
|
||||
## Build & test (exact)
|
||||
|
||||
```bash
|
||||
./gradlew testDebugUnitTest assembleDebug # full verification: unit tests THEN the APK
|
||||
./gradlew clean assembleDebug # when a generated file may be stale
|
||||
```
|
||||
|
||||
- SDK: `local.properties` -> `sdk.dir=/home/nyra/android-sdk` (present, gitignored, do not commit).
|
||||
- JDK 21, build-tools 34.0.0/36.0.0, AGP 8.8.2, compileSdk 36, minSdk 21.
|
||||
- APK: `build/outputs/apk/debug/Unexpected-Keyboard-debug.apk`, package id `harley.keyboard`.
|
||||
|
||||
## Layout & generated code
|
||||
|
||||
- Layout rows live in `srcs/layouts/*.xml`. A layout edit needs a **full build**, not just compile:
|
||||
`gen_layouts.py` regenerates `res/values/layouts.xml`, `res/raw/*.xml` and
|
||||
`srcs/juloo.keyboard2/ComposeKeyData.java`. Unit tests run before regeneration report
|
||||
stale-generated-state failures that are not real bugs.
|
||||
- Never hand-edit generated files (`res/values/layouts.xml`, `res/raw/*`, `ComposeKeyData.java`,
|
||||
`res/xml/method.xml`).
|
||||
|
||||
## Always do
|
||||
|
||||
- Run `./gradlew testDebugUnitTest assembleDebug` before reporting done.
|
||||
- Keep user-visible text in `res/values/strings.xml`.
|
||||
- Keep all network access off the UI thread.
|
||||
|
||||
## Ask first
|
||||
|
||||
- Adding any dependency (prefer the framework: `org.json`, `HttpURLConnection`).
|
||||
- Changing the package id, signing config or versionCode.
|
||||
|
||||
## Never do
|
||||
|
||||
- Commit or print secrets/tokens; no credentials in code, XML, tests or logs.
|
||||
- Touch `.git` internals, force-push, or edit CI workflows.
|
||||
- Enable cleartext HTTP globally (only a per-host network security config).
|
||||
- Change the space-bar peak-colour behaviour (a separate, deliberate feature).
|
||||
|
||||
## Definition of done
|
||||
|
||||
`./gradlew testDebugUnitTest assembleDebug` exits 0, new behaviour is covered by unit tests,
|
||||
and the tree has no generated-file diffs beyond what a normal build produces.
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<application android:label="@string/app_name" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:hardwareAccelerated="false">
|
||||
<application android:label="@string/app_name" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:hardwareAccelerated="false" android:networkSecurityConfig="@xml/network_security_config">
|
||||
<service android:name="juloo.keyboard2.Keyboard2" android:label="@string/app_name" android:permission="android.permission.BIND_INPUT_METHOD" android:exported="true" android:directBootAware="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.view.InputMethod"/>
|
||||
|
||||
Binary file not shown.
+2
-3
@@ -17,7 +17,7 @@ android {
|
||||
compileSdkVersion = "android-36"
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "juloo.keyboard2"
|
||||
applicationId = "harley.keyboard"
|
||||
minSdk = 21
|
||||
targetSdk { version = release(36) }
|
||||
versionCode = 55
|
||||
@@ -82,7 +82,6 @@ android {
|
||||
isMinifyEnabled = false
|
||||
isShrinkResources = false
|
||||
isDebuggable = true
|
||||
applicationIdSuffix = ".debug"
|
||||
resValue("string", "app_name", "@string/app_name_debug")
|
||||
resValue("bool", "debug_logs", "true")
|
||||
signingConfig = signingConfigs["debug"]
|
||||
@@ -194,4 +193,4 @@ tasks.named("preBuild") {
|
||||
// checked in the repository that don't need to be updated during regular
|
||||
// builds.
|
||||
mustRunAfter(genEmojis, genLayoutsList, compileComposeSequences, genMethodXml)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ latin_kbdtuf_tr: These keys are now added automatically, unexpected: f11_placeho
|
||||
latin_kbdtuf_tr: Missing programming keys, missing: loc esc, loc tab
|
||||
latn_colemak: Some keys contain whitespaces, unexpected: ́
|
||||
latn_dvorak: Missing important key, missing: loc capslock
|
||||
latn_neo2: Layout redefines the bottom row but some important keys are missing, missing: loc switch_clipboard
|
||||
latn_neo2: Layout redefines the bottom row but some important keys are missing, missing: alt, loc switch_clipboard, meta, pgdn, pgup, switch_fn, switch_lights, switch_roku
|
||||
latn_qwertz_cz_multifunctional: Layout includes some ASCII punctuation but not all, missing: `
|
||||
latn_qwertz_sk: Layout includes some ASCII punctuation but not all, missing: `
|
||||
latn_qzerty_it: Layout includes some ASCII punctuation but not all, missing: #, $, \, `, ~
|
||||
|
||||
+36
-19
@@ -43,37 +43,50 @@ def unexpected_keys(keys, symbols, msg):
|
||||
if len(unexpected) > 0:
|
||||
warn("%s, unexpected: %s" % (msg, key_list_str(unexpected)))
|
||||
|
||||
# Write to [keys] and [dup].
|
||||
def parse_row_from_et(row, keys, dup):
|
||||
for key in row:
|
||||
for attr in key.keys():
|
||||
def duplicates(keys):
|
||||
dup = [ k for k, key_elts in keys.items() if len(key_elts) >= 2 ]
|
||||
if len(dup) > 0:
|
||||
warn("Duplicate keys: " + key_list_str(dup))
|
||||
|
||||
def should_have_role(keys_map, role, keys):
|
||||
def is_center_key(key):
|
||||
def center(key_elt): return key_elt.get("key0", key_elt.get("c"))
|
||||
return any(( center(key_elt) == key for key_elt in keys_map.get(key, []) ))
|
||||
def key_roles(key):
|
||||
return ( key_elt.get("role", "normal") for key_elt in keys_map[key] )
|
||||
for key in keys:
|
||||
if is_center_key(key) and role not in key_roles(key):
|
||||
warn("Key '%s' is not on a key with role=\"%s\"" % (key, role))
|
||||
|
||||
# Write to [keys], dict of keyvalue to the key elements they appear in
|
||||
def parse_row_from_et(row, keys):
|
||||
for key_elt in row:
|
||||
for attr in key_elt.keys():
|
||||
if attr in KEY_ATTRIBUTES:
|
||||
k = key.get(attr).removeprefix("\\")
|
||||
if k in keys: dup.add(k)
|
||||
keys.add(k)
|
||||
k = key_elt.get(attr).removeprefix("\\")
|
||||
keys.setdefault(k, []).append(key_elt)
|
||||
|
||||
def parse_layout(fname):
|
||||
keys = set()
|
||||
dup = set()
|
||||
keys = {}
|
||||
root = ET.parse(fname).getroot()
|
||||
if root.tag != "keyboard":
|
||||
return None
|
||||
for row in root:
|
||||
parse_row_from_et(row, keys, dup)
|
||||
return root, keys, dup
|
||||
parse_row_from_et(row, keys)
|
||||
return root, keys
|
||||
|
||||
def parse_row(fname):
|
||||
keys = set()
|
||||
dup = set()
|
||||
keys = {}
|
||||
root = ET.parse(fname).getroot()
|
||||
if root.tag != "row":
|
||||
return None
|
||||
parse_row_from_et(root, keys, dup)
|
||||
return root, keys, dup
|
||||
parse_row_from_et(root, keys)
|
||||
return root, keys
|
||||
|
||||
def check_layout(layout):
|
||||
root, keys, dup = layout
|
||||
if len(dup) > 0: warn("Duplicate keys: " + key_list_str(dup))
|
||||
root, keys_map = layout
|
||||
keys = set(keys_map.keys())
|
||||
duplicates(keys_map)
|
||||
missing_some_of(keys, "~!@#$%^&*(){}`[]=\\-_;:/.,?<>'\"+|", "ASCII punctuation")
|
||||
missing_some_of(keys, "0123456789", "digits")
|
||||
missing_required(keys, ["backspace", "delete"], "Layout doesn't define some important keys")
|
||||
@@ -94,8 +107,8 @@ def check_layout(layout):
|
||||
missing_required(keys, ["shift", "loc capslock"], "Missing important key")
|
||||
missing_required(keys, ["loc esc", "loc tab"], "Missing programming keys")
|
||||
|
||||
_, bottom_row_keys, _ = parse_row("res/xml/bottom_row.xml")
|
||||
|
||||
_, bottom_row_keys_map = parse_row("res/xml/bottom_row.xml")
|
||||
bottom_row_keys = set(bottom_row_keys_map.keys())
|
||||
if root.get("bottom_row") == "false":
|
||||
missing_required(keys, bottom_row_keys,
|
||||
"Layout redefines the bottom row but some important keys are missing")
|
||||
@@ -106,6 +119,10 @@ def check_layout(layout):
|
||||
if root.get("script") == None:
|
||||
warn("Layout doesn't specify a script.")
|
||||
|
||||
should_have_role(keys_map, "action",
|
||||
[ "shift", "ctrl", "fn", "backspace", "enter" ])
|
||||
should_have_role(keys_map, "space_bar", [ "space" ])
|
||||
|
||||
keys_without_loc = set(( k.removeprefix("loc ") for k in keys ))
|
||||
# Keys with a len under 3 are often composed characters
|
||||
special_keys = set(( k for k in keys_without_loc if len(k) > 3 and ":" not in k ))
|
||||
|
||||
@@ -190,6 +190,16 @@ Value | Meaning
|
||||
`voice_typing` | Begin voice typing.
|
||||
`voice_typing_chooser` | Shows a menu where you can choose which voice typing provider to use, then begins voice typing when you make a selection.
|
||||
`shareText` | Emit a share Intent for the selected text. **Oddity:** This is in CamelCase.
|
||||
`hide_self` | Hide the keyboard.
|
||||
|
||||
## Suggestions
|
||||
|
||||
Value | Meaning
|
||||
:---- | :------
|
||||
`complete_first` | Enter the best suggestion (the one in the middle)
|
||||
`complete_second` | Enter the second best suggestion (the right one)
|
||||
`complete_third` | Enter the third best suggestion (the left one)
|
||||
`complete_emoji` | Enter the emoji suggestion
|
||||
|
||||
## Unused
|
||||
These keys are known to do nothing.
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ LOCALES = [
|
||||
loc("gl", "latin", "latn_qwerty_us"),
|
||||
loc("ha_NG", "latin", "latn_qwerty_us", extra_keys="₦|ɓ|ɗ|ƙ|’|ƴ|r̃"),
|
||||
loc("haw_US", "latin", "latn_qwerty_haw", extra_keys="ʻ@l|accent_macron:ā:ē:ī:ō:ū@m"),
|
||||
loc("he_IL", "hebrew", "default_layout=hebr_1_il,extra_keys=₪@r|€"),
|
||||
loc("he_IL", "hebrew", "hebr_1_il", extra_keys="₪@r"),
|
||||
loc("hi_IN", "devanagari", "deva_inscript", extra_keys="₹"),
|
||||
loc("hr", "latin", "latn_qwerty_us", extra_keys="č|ć|dž|đ|lj|nj|š|ž"),
|
||||
loc("hu_HU", "latin", "latn_qwertz_hu", extra_keys="accent_aigu:á:é:í:ó:ú@d|accent_trema:ö:ü@u|accent_ogonek@s|accent_double_aigu:ő:ű@k|€"),
|
||||
|
||||
@@ -154,7 +154,6 @@
|
||||
<string name="pref_dialog_edit_text">eigene Definition</string>
|
||||
<string name="dictionaries_from_internet">Lade ein Wörterbuch aus dem Internet</string>
|
||||
<string name="dictionaries_download_success">Wörterbuch installiert</string>
|
||||
<string name="dictionaries_download_failed">Herunterladen fehlgeschlagen</string>
|
||||
<string name="dictionaries_activity_not_enabled">Du musst die Tastatur aktivieren um Wörterbücher herunterzuladen.</string>
|
||||
<string name="pref_portrait_unfolded">im Hochformat aufgeklappt</string>
|
||||
<string name="pref_landscape_unfolded">Im Querformat aufgeklappt</string>
|
||||
|
||||
@@ -159,6 +159,5 @@
|
||||
<string name="pref_dialog_edit_text">Definición personalizada</string>
|
||||
<string name="dictionaries_from_internet">Descargar un diccionario de internet</string>
|
||||
<string name="dictionaries_download_success">Diccionario instalado</string>
|
||||
<string name="dictionaries_download_failed">Falló la descarga</string>
|
||||
<string name="dictionaries_activity_not_enabled">Primero tienes que habilitar al teclado para descargar diccionarios.</string>
|
||||
</resources>
|
||||
|
||||
@@ -144,7 +144,6 @@
|
||||
<string name="key_descr_end">Lõpp</string>
|
||||
<string name="key_descr_ª">Järgarvu tunnus</string>
|
||||
<string name="dictionaries_download_success">Sõnastik on paigaldatud</string>
|
||||
<string name="dictionaries_download_failed">Allalaadimine ei õnnestunud</string>
|
||||
<string name="dictionaries_activity_not_enabled">Sõnastike allalaadimiseks pead esmalt klahvistiku kasutusele võtma.</string>
|
||||
<string name="key_descr_clipboard">Lõikelaua haldur</string>
|
||||
<string name="key_descr_combining">Täpitähemärkide kombineerimine</string>
|
||||
|
||||
@@ -132,6 +132,5 @@
|
||||
<string name="pref_clipboard_history_duration_stop">تا زمان بسته شدن برنامه</string>
|
||||
<string name="dictionaries_from_internet">دانلود دیکشنری از اینترنت</string>
|
||||
<string name="dictionaries_download_success">دیکشنری نصب شد</string>
|
||||
<string name="dictionaries_download_failed">دانلود با خطا مواجه شد</string>
|
||||
<string name="dictionaries_activity_not_enabled">شما ابتدا باید صفحه کلید را برای دانلود دیکشنری ها فعال کنید.</string>
|
||||
</resources>
|
||||
|
||||
@@ -159,7 +159,6 @@
|
||||
<string name="pref_dialog_edit_text">Personnalisée</string>
|
||||
<string name="dictionaries_from_internet">Télécharger un dictionnaire depuis Internet</string>
|
||||
<string name="dictionaries_download_success">Dictionnaire installé</string>
|
||||
<string name="dictionaries_download_failed">Le téléchargement a échoué</string>
|
||||
<string name="dictionaries_activity_not_enabled">Vous devez d\'abord activer le clavier.</string>
|
||||
<string name="candidates_status_click_to_install">Cliquez pour installer un dictionnaire pour le %s</string>
|
||||
</resources>
|
||||
|
||||
@@ -131,7 +131,6 @@
|
||||
<string name="pref_theme_e_epaperblack">ePapīrs melns</string>
|
||||
<string name="launcher_button_dictionaries">Uzstādīt vārdnīcas</string>
|
||||
<string name="dictionaries_download_success">Vārdnīca uzstādīta</string>
|
||||
<string name="dictionaries_download_failed">Neizdevās lejupielādēt</string>
|
||||
<string name="key_descr_delete_word">Dzēst vārdu</string>
|
||||
<string name="pref_clipboard_history_duration">Starpliktuves glabāšanas ilgums</string>
|
||||
<string name="pref_change_method_key_replacement_e_prev">Pārslēgties uz pēdējo izmantoto</string>
|
||||
|
||||
@@ -158,7 +158,6 @@
|
||||
<string name="pref_clipboard_history_duration_stop">Do zatrzymania aplikacji</string>
|
||||
<string name="dictionaries_from_internet">Pobierz słownik z internetu</string>
|
||||
<string name="dictionaries_download_success">Słownik zainstalowany</string>
|
||||
<string name="dictionaries_download_failed">Pobieranie nieudane</string>
|
||||
<string name="dictionaries_activity_not_enabled">Aby pobrać słowniki, najpierw włącz klawiaturę.</string>
|
||||
<string name="pref_dialog_edit_text">Własna definicja</string>
|
||||
</resources>
|
||||
|
||||
@@ -158,7 +158,6 @@
|
||||
<string name="pref_clipboard_history_duration_stop">До остановки приложения</string>
|
||||
<string name="dictionaries_from_internet">Загрузить словарь из Интернета</string>
|
||||
<string name="dictionaries_download_success">Словарь установлен</string>
|
||||
<string name="dictionaries_download_failed">Ошибка при загрузке</string>
|
||||
<string name="dictionaries_activity_not_enabled">Необходимо включить клавиатуру до загрузки словарей.</string>
|
||||
<string name="pref_dialog_edit_text">Собственное определение</string>
|
||||
<string name="candidates_status_click_to_install">Нажмите, чтобы установить словарь для %s</string>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Colors for the Monet themes. -->
|
||||
<color name="system_accent1_100">@android:color/system_accent1_100</color>
|
||||
<color name="system_accent1_200">@android:color/system_accent1_200</color>
|
||||
<color name="system_accent1_400">@android:color/system_accent1_400</color>
|
||||
<color name="system_accent1_600">@android:color/system_accent1_600</color>
|
||||
<color name="system_accent2_900">@android:color/system_accent2_900</color>
|
||||
<color name="system_neutral1_0">@android:color/system_neutral1_0</color>
|
||||
<color name="system_neutral1_100">@android:color/system_neutral1_100</color>
|
||||
<color name="system_neutral1_400">@android:color/system_neutral1_400</color>
|
||||
|
||||
@@ -159,6 +159,5 @@
|
||||
<string name="pref_dialog_edit_text">自定義</string>
|
||||
<string name="dictionaries_from_internet">從網路下載字典</string>
|
||||
<string name="dictionaries_download_success">字典已安裝</string>
|
||||
<string name="dictionaries_download_failed">下載失敗</string>
|
||||
<string name="dictionaries_activity_not_enabled">需要啟用鍵盤才能下載字典。</string>
|
||||
</resources>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<item>@string/pref_theme_e_everforestlight</item>
|
||||
<item>@string/pref_theme_e_cobalt</item>
|
||||
<item>@string/pref_theme_e_pine</item>
|
||||
<item>@string/pref_theme_e_orchid</item>
|
||||
<item>@string/pref_theme_e_epaperblack</item>
|
||||
</string-array>
|
||||
<string-array name="pref_theme_values">
|
||||
@@ -64,6 +65,7 @@
|
||||
<item>everforestlight</item>
|
||||
<item>cobalt</item>
|
||||
<item>pine</item>
|
||||
<item>orchid</item>
|
||||
<item>epaperblack</item>
|
||||
</string-array>
|
||||
<string-array name="pref_swipe_dist_entries">
|
||||
@@ -134,4 +136,22 @@
|
||||
<item>prev</item>
|
||||
<item>next</item>
|
||||
</string-array>
|
||||
<string-array name="pref_physical_keyboard_behavior_entries">
|
||||
<item>@string/pref_physical_keyboard_behavior_hide</item>
|
||||
<item>@string/pref_physical_keyboard_behavior_show</item>
|
||||
</string-array>
|
||||
<string-array name="pref_physical_keyboard_behavior_values">
|
||||
<item>hide</item>
|
||||
<item>show</item>
|
||||
</string-array>
|
||||
<string-array name="pref_split_layout_entries">
|
||||
<item>@string/pref_split_layout_wide</item>
|
||||
<item>@string/pref_split_layout_landscape</item>
|
||||
<item>@string/pref_split_layout_never</item>
|
||||
</string-array>
|
||||
<string-array name="pref_split_layout_values">
|
||||
<item>wide</item>
|
||||
<item>landscape</item>
|
||||
<item>never</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
+14
-3
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name_release">Unexpected Keyboard</string>
|
||||
<string name="app_name_debug">Unexpected Keyboard (Debug)</string>
|
||||
<string name="app_name_release">Harley\'s Keyboard</string>
|
||||
<string name="app_name_debug">Harley\'s Keyboard</string>
|
||||
<string name="short_description">Lightweight and privacy-conscious virtual keyboard for Android.</string>
|
||||
<string name="store_description">The main feature is that you can type more characters by swiping the keys towards the corners.\n\nThis application was originally designed for programmers using Termux.\nNow perfect for everyday use.\n\nThis application contains no ads and is Open Source.</string>
|
||||
<string name="pref_portrait">In portrait mode</string>
|
||||
@@ -9,6 +9,9 @@
|
||||
<string name="pref_landscape">In landscape mode</string>
|
||||
<string name="pref_landscape_unfolded">In landscape mode unfolded</string>
|
||||
<string name="pref_category_layout">Layout</string>
|
||||
<string name="pref_usage_gauge_enabled">Usage gauge key</string>
|
||||
<string name="pref_usage_gauge_url">Usage gauge URL</string>
|
||||
<string name="pref_usage_gauge_token">Usage gauge bearer token</string>
|
||||
<string name="pref_label_brightness">Adjust label brightness</string>
|
||||
<string name="pref_keyboard_opacity">Adjust keyboard background opacity</string>
|
||||
<string name="pref_key_opacity">Adjust key opacity</string>
|
||||
@@ -82,6 +85,7 @@
|
||||
<string name="pref_theme_e_everforestlight">Everforest Light</string>
|
||||
<string name="pref_theme_e_cobalt">Cobalt</string>
|
||||
<string name="pref_theme_e_pine">Pine</string>
|
||||
<string name="pref_theme_e_orchid">Orchid</string>
|
||||
<string name="pref_theme_e_epaperblack">ePaper Black</string>
|
||||
<string name="pref_swipe_dist_e_very_short">Very short</string>
|
||||
<string name="pref_swipe_dist_e_short">Short</string>
|
||||
@@ -159,7 +163,14 @@
|
||||
<string name="pref_dialog_edit_text">Custom definition</string>
|
||||
<string name="dictionaries_from_internet">Download a dictionary from the Internet</string>
|
||||
<string name="dictionaries_download_success">Dictionary installed</string>
|
||||
<string name="dictionaries_download_failed">Download failed</string>
|
||||
<string name="dictionaries_download_failed">Download failed: Please allow internet access</string>
|
||||
<string name="dictionaries_activity_not_enabled">You must first enable the keyboard to download dictionaries.</string>
|
||||
<string name="candidates_status_click_to_install">Click to install a dictionary for %s</string>
|
||||
<string name="pref_physical_keyboard_behavior">When a physical keyboard is connected</string>
|
||||
<string name="pref_physical_keyboard_behavior_hide">Hide everything</string>
|
||||
<string name="pref_physical_keyboard_behavior_show">Show everything</string>
|
||||
<string name="pref_split_layout">Split layout</string>
|
||||
<string name="pref_split_layout_never">Never</string>
|
||||
<string name="pref_split_layout_landscape">In landscape orientation</string>
|
||||
<string name="pref_split_layout_wide">On wide screens</string>
|
||||
</resources>
|
||||
|
||||
@@ -7,11 +7,28 @@
|
||||
<attr name="colorKey" format="color"/>
|
||||
<!-- Background of the keys when pressed -->
|
||||
<attr name="colorKeyActivated" format="color"/>
|
||||
<!-- Adjust the lightness of keys depending on their role. -->
|
||||
<attr name="colorKeyAction" format="color"/>
|
||||
<attr name="colorKeySpaceBar" format="color"/>
|
||||
<!-- Label colors -->
|
||||
<attr name="colorLabel" format="color"/>
|
||||
<attr name="colorLabelPressed" format="color"/> <!-- defaults to colorLabel -->
|
||||
<attr name="colorLabelActivated" format="color"/>
|
||||
<attr name="colorLabelLocked" format="color"/>
|
||||
<!-- The Roku page's four direction keys. They carry FLAG_SECONDARY like every
|
||||
other event key, so without a colour of their own they come out dimmed to
|
||||
secondaryLabelColor. This is the same cyan the keyboard already uses for
|
||||
"the blue" (the space bar's io-stall line, the DeepSeek off-peak indicator),
|
||||
and it is deliberately the same value in every theme. -->
|
||||
<attr name="colorRokuArrow" format="color"/>
|
||||
<!-- The lights page's colour rule: a light that is ON is BLUE, one that is OFF is PINK, and
|
||||
one nobody can see - 'unavailable', 'unknown', or no data at all - is the stale grey.
|
||||
These are the only colours the rule is written with, and colorLightOn takes the very blue
|
||||
the Roku arrows wear instead of repeating its hex, so swapping on and off is a one-line
|
||||
change here and no key holds a colour of its own. -->
|
||||
<attr name="colorLightOn" format="color"/>
|
||||
<attr name="colorLightOff" format="color"/>
|
||||
<attr name="colorLightStale" format="color"/>
|
||||
<attr name="secondaryDimming" format="float"/>
|
||||
<attr name="greyedDimming" format="float"/>
|
||||
<!-- Corner labels -->
|
||||
@@ -20,6 +37,8 @@
|
||||
<attr name="keyBorderRadius" format="dimension"/>
|
||||
<attr name="keyBorderWidth" format="dimension"/>
|
||||
<attr name="keyBorderWidthActivated" format="dimension"/>
|
||||
<attr name="keyBorderWidthAction" format="dimension"/>
|
||||
<attr name="keyBorderWidthSpaceBar" format="dimension"/>
|
||||
<attr name="keyBorderColorLeft" format="color"/>
|
||||
<attr name="keyBorderColorTop" format="color"/>
|
||||
<attr name="keyBorderColorRight" format="color"/>
|
||||
@@ -46,6 +65,8 @@
|
||||
<item name="keyBorderRadius">5dp</item>
|
||||
<item name="keyBorderWidth">0dp</item>
|
||||
<item name="keyBorderWidthActivated">0dp</item>
|
||||
<item name="keyBorderWidthAction">?attr/keyBorderWidth</item>
|
||||
<item name="keyBorderWidthSpaceBar">?attr/keyBorderWidth</item>
|
||||
<item name="secondaryDimming">0.25</item>
|
||||
<item name="greyedDimming">0.5</item>
|
||||
<item name="emoji_key_bg" type="color">?attr/emoji_button_bg</item>
|
||||
@@ -54,14 +75,22 @@
|
||||
<item name="clipboard_divider_height">1px</item>
|
||||
<item name="suggestions_background">?attr/colorKeyboard</item>
|
||||
<item name="suggestions_border_radius">?attr/keyBorderRadius</item>
|
||||
<item name="colorRokuArrow">#00E5FF</item>
|
||||
<item name="colorLightOn">?attr/colorRokuArrow</item>
|
||||
<item name="colorLightOff">#FF2D95</item>
|
||||
<item name="colorLightStale">#8a8d93</item>
|
||||
</style>
|
||||
<style name="Dark" parent="BaseTheme">
|
||||
<item name="android:isLightTheme">false</item>
|
||||
<item name="colorKeyboard">#1b1b1b</item>
|
||||
<item name="colorKey">#333333</item>
|
||||
<item name="colorKeyActivated">#1b1b1b</item>
|
||||
<item name="colorKeyAction">#262626</item>
|
||||
<item name="colorKeySpaceBar">#2b2b2b</item>
|
||||
<item name="keyBorderWidth">1.2dp</item>
|
||||
<item name="keyBorderWidthActivated">0dp</item>
|
||||
<item name="keyBorderWidthAction">0dp</item>
|
||||
<item name="keyBorderWidthSpaceBar">0dp</item>
|
||||
<item name="keyBorderColorBottom">#404040</item>
|
||||
<item name="colorLabel">#ffffff</item>
|
||||
<item name="colorLabelActivated">#3399ff</item>
|
||||
@@ -75,8 +104,12 @@
|
||||
<item name="colorKeyboard">#e3e3e3</item>
|
||||
<item name="colorKey">#cccccc</item>
|
||||
<item name="colorKeyActivated">#e3e3e3</item>
|
||||
<item name="colorKeyAction">#d9d9d9</item>
|
||||
<item name="colorKeySpaceBar">#dedede</item>
|
||||
<item name="keyBorderWidth">0.6dp</item>
|
||||
<item name="keyBorderWidthActivated">0dp</item>
|
||||
<item name="keyBorderWidthAction">0dp</item>
|
||||
<item name="keyBorderWidthSpaceBar">0dp</item>
|
||||
<item name="keyBorderColorLeft">#cccccc</item>
|
||||
<item name="keyBorderColorTop">#eeeeee</item>
|
||||
<item name="keyBorderColorRight">#cccccc</item>
|
||||
@@ -93,6 +126,8 @@
|
||||
<item name="colorKeyboard">#000000</item>
|
||||
<item name="colorKey">#000000</item>
|
||||
<item name="colorKeyActivated">#333333</item>
|
||||
<item name="colorKeyAction">#000000</item>
|
||||
<item name="colorKeySpaceBar">#000000</item>
|
||||
<item name="keyBorderWidth">0dp</item>
|
||||
<item name="keyBorderWidthActivated">1dp</item>
|
||||
<item name="keyBorderColorLeft">#2a2a2a</item>
|
||||
@@ -114,6 +149,8 @@
|
||||
<item name="android:isLightTheme">true</item>
|
||||
<item name="colorKeyboard">#ffffff</item>
|
||||
<item name="colorKey">#ffffff</item>
|
||||
<item name="colorKeyAction">#ffffff</item>
|
||||
<item name="colorKeySpaceBar">#ffffff</item>
|
||||
<item name="keyBorderWidth">1dp</item>
|
||||
<item name="keyBorderWidthActivated">1dp</item>
|
||||
<item name="keyBorderColorLeft">#f0f0f0</item>
|
||||
@@ -133,6 +170,8 @@
|
||||
<item name="android:isLightTheme">true</item>
|
||||
<item name="colorKeyboard">#ffffff</item>
|
||||
<item name="colorKey">#ffffff</item>
|
||||
<item name="colorKeyAction">#ffffff</item>
|
||||
<item name="colorKeySpaceBar">#ffffff</item>
|
||||
<item name="keyBorderWidth">2dp</item>
|
||||
<item name="keyBorderWidthActivated">5dp</item>
|
||||
<item name="keyBorderColorLeft">#000000</item>
|
||||
@@ -154,6 +193,8 @@
|
||||
<item name="colorKeyboard">#ffe0b2</item>
|
||||
<item name="colorKey">#fff3e0</item>
|
||||
<item name="colorKeyActivated">#ffcc80</item>
|
||||
<item name="colorKeyAction">#ffe9c6</item>
|
||||
<item name="colorKeySpaceBar">#ffedd0</item>
|
||||
<item name="colorLabel">#000000</item>
|
||||
<item name="colorLabelActivated">#ffffff</item>
|
||||
<item name="colorLabelLocked">#e65100</item>
|
||||
@@ -172,6 +213,8 @@
|
||||
<item name="colorKeyboard">#4db6ac</item>
|
||||
<item name="colorKey">#e0f2f1</item>
|
||||
<item name="colorKeyActivated">#00695c</item>
|
||||
<item name="colorKeyAction">#b8e3de</item>
|
||||
<item name="colorKeySpaceBar">#c3e7e3</item>
|
||||
<item name="colorLabel">#000000</item>
|
||||
<item name="colorLabelActivated">#ffffff</item>
|
||||
<item name="colorLabelLocked">#64ffda</item>
|
||||
@@ -190,6 +233,8 @@
|
||||
<item name="colorKeyboard">@color/system_neutral1_100</item>
|
||||
<item name="colorKey">@color/system_neutral1_50</item>
|
||||
<item name="colorKeyActivated">?colorKeyboard</item>
|
||||
<item name="colorKeyAction">@color/system_accent1_100</item>
|
||||
<item name="colorKeySpaceBar">@color/system_accent1_200</item>
|
||||
<item name="colorLabel">@color/system_neutral1_800</item>
|
||||
<item name="colorLabelActivated">@color/system_accent1_400</item>
|
||||
<item name="colorLabelLocked">@color/system_accent1_600</item>
|
||||
@@ -202,6 +247,7 @@
|
||||
<item name="colorKeyboard">@color/system_neutral1_900</item>
|
||||
<item name="colorKey">@color/system_neutral1_800</item>
|
||||
<item name="colorKeyActivated">?colorKeyboard</item>
|
||||
<item name="colorKeyAction">@color/system_accent2_900</item>
|
||||
<item name="colorLabel">@color/system_neutral1_0</item>
|
||||
<item name="colorLabelActivated">@color/system_accent1_400</item>
|
||||
<item name="colorLabelLocked">@color/system_accent1_600</item>
|
||||
@@ -214,6 +260,8 @@
|
||||
<item name="colorKeyboard">#191724</item>
|
||||
<item name="colorKey">#26233a</item>
|
||||
<item name="colorKeyActivated">#403d52</item>
|
||||
<item name="colorKeyAction">#2a2740</item>
|
||||
<item name="colorKeySpaceBar">#2e2b47</item>
|
||||
<item name="keyBorderWidth">0dp</item>
|
||||
<item name="keyBorderWidthActivated">1dp</item>
|
||||
<item name="keyBorderColorLeft">#6e6a86</item>
|
||||
@@ -281,6 +329,25 @@
|
||||
<item name="emoji_color">?colorLabel</item>
|
||||
<item name="clipboard_divider_color">?colorKey</item>
|
||||
</style>
|
||||
<style name="Orchid" parent="BaseTheme">
|
||||
<item name="android:isLightTheme">false</item>
|
||||
<item name="colorKeyboard">#100a1c</item>
|
||||
<item name="colorKey">?colorKeyboard</item>
|
||||
<item name="colorKeyActivated">#a855f7</item>
|
||||
<item name="colorLabel">#ff8ad8</item>
|
||||
<item name="colorLabelActivated">?colorKey</item>
|
||||
<item name="colorLabelLocked">#9db8ff</item>
|
||||
<item name="colorSubLabel">#c67dff</item>
|
||||
<item name="keyBorderWidth">0.0dip</item>
|
||||
<item name="keyBorderWidthActivated">0.0dip</item>
|
||||
<item name="keyBorderColorLeft">#241734</item>
|
||||
<item name="keyBorderColorTop">#241734</item>
|
||||
<item name="keyBorderColorRight">#241734</item>
|
||||
<item name="keyBorderColorBottom">#241734</item>
|
||||
<item name="emoji_button_bg">?colorKeyboard</item>
|
||||
<item name="emoji_color">?colorLabel</item>
|
||||
<item name="clipboard_divider_color">?colorKey</item>
|
||||
</style>
|
||||
<style name="ePaperBlack" parent="BaseTheme">
|
||||
<item name="android:isLightTheme">false</item>
|
||||
<item name="colorKeyboard">#000000</item>
|
||||
|
||||
@@ -15,8 +15,13 @@
|
||||
<bool name="debug_logs">false</bool>
|
||||
<!-- Color fallback for the Monet themes on Android API < 31. This makes the
|
||||
Monet themes very similar to the "Dark" and "Light" themes. -->
|
||||
<color name="system_accent1_100">#3333ff</color>
|
||||
<color name="system_accent1_200">#3366ff</color>
|
||||
<color name="system_accent1_400">#3399ff</color>
|
||||
<color name="system_accent1_600">#33cc33</color>
|
||||
<color name="system_accent1_600">#33ccff</color>
|
||||
<color name="system_accent1_900">#33ffff</color>
|
||||
<!-- accent2 is inverted accent1-->
|
||||
<color name="system_accent2_900">#009999</color>
|
||||
<color name="system_neutral1_0">#ffffff</color>
|
||||
<color name="system_neutral1_100">#e3e3e3</color>
|
||||
<color name="system_neutral1_400">#cccccc</color>
|
||||
|
||||
+11
-5
@@ -1,8 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<row height="0.95">
|
||||
<key width="1.7" key0="ctrl" key1="loc switch_greekmath" key2="loc meta" key3="loc switch_clipboard" key4="switch_numeric"/>
|
||||
<key width="1.1" key0="fn" key1="loc alt" key2="loc change_method" key3="switch_emoji" key4="config"/>
|
||||
<key width="4.4" key0="space" key7="switch_forward" key8="switch_backward" key5="cursor_left" key6="cursor_right"/>
|
||||
<key width="1.1" key0="loc compose" key7="up" key6="right" key5="left" key8="down" key1="loc home" key2="loc page_up" key3="loc end" key4="loc page_down"/>
|
||||
<key width="1.7" key0="enter" key1="loc voice_typing" key2="action"/>
|
||||
<key width="1.5" role="action" key0="ctrl" key1="loc meta" key3="loc switch_clipboard"/>
|
||||
<!-- The Alt key's four corner slots (1 top-left, 2 top-right, 3 bottom-left, 4 bottom-right):
|
||||
three are taken - the Roku page, the emoji pane and the config - so the free bottom-right one
|
||||
carries the lights page, drawn with the lamp glyph at 0xE025 (res/xml/lights.xml). Swipe
|
||||
up-right on Alt to open it. -->
|
||||
<key width="1.3" role="action" key0="alt" key1="switch_roku" key2="switch_emoji" key3="config" key4="switch_lights"/>
|
||||
<key width="1.0" role="action" key7="pgup" key8="pgdn"/>
|
||||
<key width="4.5" role="space_bar" key0="space" key7="switch_forward" key8="switch_backward" key5="cursor_left" key6="cursor_right"/>
|
||||
<key width="1.0" role="action" key7="up" key8="down"/>
|
||||
<key width="1.4" role="action" key0="switch_numeric" key1="meta" key2="loc change_method" key3="loc voice_typing" key4="switch_fn"/>
|
||||
<key width="1.5" role="action" key0="enter" key4="loc compose" key2="action"/>
|
||||
</row>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<!-- The bottom row used in the clipboard history pane. -->
|
||||
<keyboard bottom_row="false">
|
||||
<row height="0.95">
|
||||
<key key0="switch_back_clipboard"/>
|
||||
<key width="3" key0="space" key5="cursor_left" key6="cursor_right"/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key key0="enter" key2="action"/>
|
||||
<key role="action" key0="switch_back_clipboard"/>
|
||||
<key width="3" role="space_bar" key0="space" key5="cursor_left" key6="cursor_right"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="enter" key2="action"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<!-- The bottom row used in the emoji pane. -->
|
||||
<keyboard bottom_row="false">
|
||||
<row height="0.95">
|
||||
<key key0="switch_back_emoji"/>
|
||||
<key width="3" key0="space" key5="cursor_left" key6="cursor_right"/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key key0="enter" key2="action"/>
|
||||
<key role="action" key0="switch_back_emoji"/>
|
||||
<key role="space_bar" width="3" key0="space" key5="cursor_left" key6="cursor_right"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="enter" key2="action"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<keyboard bottom_row="false">
|
||||
<row>
|
||||
<key key0="f1"/>
|
||||
<key key0="f2"/>
|
||||
<key key0="f3"/>
|
||||
<key key0="f4"/>
|
||||
<key key0="f5"/>
|
||||
<key key0="f6"/>
|
||||
<key key0="f7"/>
|
||||
<key key0="f8"/>
|
||||
<key key0="f9"/>
|
||||
<key key0="f10"/>
|
||||
<key key0="f11"/>
|
||||
<key key0="f12"/>
|
||||
</row>
|
||||
<row height="0.95">
|
||||
<key width="1.5" role="action" key0="shift"/>
|
||||
<key width="1.5" role="action" key0="ctrl"/>
|
||||
<key width="1.3" role="action" key0="alt"/>
|
||||
<key width="1.4" role="action" key0="meta"/>
|
||||
<key width="4.2" role="space_bar" key0="space"/>
|
||||
<key width="1.4" role="action" key0="switch_text"/>
|
||||
<key width="1.5" role="action" key0="enter" key2="action"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
@@ -25,7 +25,7 @@
|
||||
<key key0="ϡ" key1="⌀"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.5" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="ζ" key3="⇌" key4="√"/>
|
||||
<key key0="χ" key3="accent_arrow_right" key4="∪"/>
|
||||
<key key0="ϛ" key4="∩"/>
|
||||
@@ -33,15 +33,15 @@
|
||||
<key key0="β" key1="≤" key3="ℤ" key4="1"/>
|
||||
<key key0="ν" key1="≠" key3="ℚ" key4="2"/>
|
||||
<key key0="μ" key1="≥" key3="×" key4="3"/>
|
||||
<key width="1.5" key0="backspace" key3="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key3="delete"/>
|
||||
</row>
|
||||
<row height="0.95">
|
||||
<key width="1.2" key0="switch_text" key2="loc esc"/>
|
||||
<key width="1.2" key0="switch_numeric" key2="loc tab"/>
|
||||
<key width="1.2" key0="fn"/>
|
||||
<key width="2.8" key0="space" key1="superscript" key3="subscript"/>
|
||||
<key width="1.2" key0="0" key2="."/>
|
||||
<key width="1.2" key0="loc compose" key7="up" key6="right" key5="left" key8="down"/>
|
||||
<key width="1.2" key0="enter" key1="=" key2="action"/>
|
||||
<key width="1.2" role="action" key0="switch_text" key2="loc esc"/>
|
||||
<key width="1.2" role="action" key0="switch_numeric" key2="loc tab"/>
|
||||
<key width="1.2" role="action" key0="fn"/>
|
||||
<key width="2.8" role="space_bar" key0="space" key1="superscript" key3="subscript"/>
|
||||
<key width="1.2" role="action" key0="0" key2="."/>
|
||||
<key width="1.2" role="action" key0="loc compose" key7="up" key6="right" key5="left" key8="down"/>
|
||||
<key width="1.2" role="action" key0="enter" key1="=" key2="action"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- The lights page. Not a user-selectable layout: it is opened by the switch_lights key (the lamp
|
||||
glyph at 0xE025, in the free bottom-right corner of the Alt key) and left with lights_close.
|
||||
|
||||
This file is only the page's skeleton: one row of three light slots, and the full-width
|
||||
"Keyboard" key that fires Event.SWITCH_TEXT, exactly like roku_close on the Roku page.
|
||||
[Keyboard2.loadLightsLayout] repeats the slot row once per row of lights the lights-proxy
|
||||
reports and replaces both values of every slot - the label with the light's name as the
|
||||
registry gives it, the top-centre corner with the state glyph (the lit lamp at 0xE025 for a
|
||||
light that is on, the unlit one at 0xE026 for everything else) - so one key per light, three to
|
||||
a row, the last row stretched if it is short. Before the proxy has answered, the three
|
||||
placeholder slots below stand as-is: a dash and the unlit lamp in the stale look, because until
|
||||
somebody names the lights there is nothing honest to show. The "light_N" names below exist only
|
||||
so this file parses; [LightsPage] replaces them.
|
||||
|
||||
Like res/xml/roku.xml it is loaded as a plain layout, NOT through LayoutModifier.modify_layout,
|
||||
so the forced config key and the user's extra keys cannot land on it: the page is its own keys
|
||||
and the way back, and nothing else.
|
||||
|
||||
Row height 1.0 (not the Roku page's 0.8) because these keys carry words, not just glyphs. -->
|
||||
<keyboard bottom_row="false">
|
||||
<row height="1.0">
|
||||
<key width="3.3" role="action" key0="light_1"/>
|
||||
<key width="3.3" role="action" key0="light_2"/>
|
||||
<key width="3.3" role="action" key0="light_3"/>
|
||||
</row>
|
||||
<row height="1.0">
|
||||
<key width="9.9" role="action" key0="lights_close"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
<subtype android:label="%s" android:languageTag="gl" android:imeSubtypeLocale="gl" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwerty_us,dictionary=gl" />
|
||||
<subtype android:label="%s" android:languageTag="ha" android:imeSubtypeLocale="ha_NG" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwerty_us,extra_keys=₦|ɓ|ɗ|ƙ|’|ƴ|r̃" />
|
||||
<subtype android:label="%s" android:languageTag="haw" android:imeSubtypeLocale="haw_US" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwerty_haw,extra_keys=ʻ@l|accent_macron:ā:ē:ī:ō:ū@m" />
|
||||
<subtype android:label="%s" android:languageTag="he" android:imeSubtypeLocale="he_IL" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=hebrew,default_layout=default_layout=hebr_1_il,extra_keys=₪@r|€" />
|
||||
<subtype android:label="%s" android:languageTag="he" android:imeSubtypeLocale="he_IL" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=hebrew,default_layout=hebr_1_il,extra_keys=₪@r" />
|
||||
<subtype android:label="%s" android:languageTag="hi" android:imeSubtypeLocale="hi_IN" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=devanagari,default_layout=deva_inscript,dictionary=hi,extra_keys=₹" />
|
||||
<subtype android:label="%s" android:languageTag="hr" android:imeSubtypeLocale="hr" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwerty_us,dictionary=hr,extra_keys=č|ć|dž|đ|lj|nj|š|ž" />
|
||||
<subtype android:label="%s" android:languageTag="hu" android:imeSubtypeLocale="hu_HU" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="script=latin,default_layout=latn_qwertz_hu,dictionary=hu,extra_keys=accent_aigu:á:é:í:ó:ú@d|accent_trema:ö:ü@u|accent_ogonek@s|accent_double_aigu:ő:ű@k|€" />
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="false"/>
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="false">10.10.10.1</domain>
|
||||
</domain-config>
|
||||
</network-security-config>
|
||||
+10
-10
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- See [number_row_no_symbols.xml] for the number row with no symbols. -->
|
||||
<row height="0.75">
|
||||
<key key0="1" se="!"/>
|
||||
<key key0="2" se="@"/>
|
||||
<key key0="3" se="#"/>
|
||||
<key key0="4" se="$"/>
|
||||
<key key0="5" se="%"/>
|
||||
<key key0="6" sw="^"/>
|
||||
<key key0="7" sw="&"/>
|
||||
<key key0="8" sw="*"/>
|
||||
<key key0="9" sw="("/>
|
||||
<key key0="0" sw=")"/>
|
||||
<key role="action" key0="1" se="!"/>
|
||||
<key role="action" key0="2" se="@"/>
|
||||
<key role="action" key0="3" se="#"/>
|
||||
<key role="action" key0="4" se="$"/>
|
||||
<key role="action" key0="5" se="%"/>
|
||||
<key role="action" key0="6" sw="^"/>
|
||||
<key role="action" key0="7" sw="&"/>
|
||||
<key role="action" key0="8" sw="*"/>
|
||||
<key role="action" key0="9" sw="("/>
|
||||
<key role="action" key0="0" sw=")"/>
|
||||
</row>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<row height="0.75">
|
||||
<key key0="1"/>
|
||||
<key key0="2"/>
|
||||
<key key0="3"/>
|
||||
<key key0="4"/>
|
||||
<key key0="5"/>
|
||||
<key key0="6"/>
|
||||
<key key0="7"/>
|
||||
<key key0="8"/>
|
||||
<key key0="9"/>
|
||||
<key key0="0"/>
|
||||
<key role="action" key0="1"/>
|
||||
<key role="action" key0="2"/>
|
||||
<key role="action" key0="3"/>
|
||||
<key role="action" key0="4"/>
|
||||
<key role="action" key0="5"/>
|
||||
<key role="action" key0="6"/>
|
||||
<key role="action" key0="7"/>
|
||||
<key role="action" key0="8"/>
|
||||
<key role="action" key0="9"/>
|
||||
<key role="action" key0="0"/>
|
||||
</row>
|
||||
|
||||
+15
-15
@@ -1,36 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<keyboard bottom_row="false">
|
||||
<row>
|
||||
<key width="0.75" key0="loc esc" key2="~" key4="!"/>
|
||||
<key width="0.75" key0="(" key2="[" key4="{"/>
|
||||
<key width="0.75" role="action" key0="loc esc" key2="~" key4="!"/>
|
||||
<key width="0.75" role="action" key0="(" key2="[" key4="{"/>
|
||||
<key key0="7" key1="<" key2=">"/>
|
||||
<key key0="8" key2="∞"/>
|
||||
<key key0="9" key2="π"/>
|
||||
<key width="0.75" key0="*" key1="√" key2="×" key3="\#"/>
|
||||
<key width="0.75" key0="/" key1="%" key3="÷"/>
|
||||
<key width="0.75" role="action" key0="*" key1="√" key2="×" key3="\#"/>
|
||||
<key width="0.75" role="action" key0="/" key1="%" key3="÷"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="0.75" key0="loc tab" key2="|" key4="\\"/>
|
||||
<key width="0.75" key0=")" key2="]" key4="}"/>
|
||||
<key width="0.75" role="action" key0="loc tab" key2="|" key4="\\"/>
|
||||
<key width="0.75" role="action" key0=")" key2="]" key4="}"/>
|
||||
<key key0="4" key1="box" key3="arrows"/>
|
||||
<key key0="5" key7="up" key6="right" key5="left" key8="down"/>
|
||||
<key key0="6"/>
|
||||
<key width="0.75" key0="+" key1="Σ" key2="$"/>
|
||||
<key width="0.75" key0="-" key1="^"/>
|
||||
<key width="0.75" role="action" key0="+" key1="Σ" key2="$"/>
|
||||
<key width="0.75" role="action" key0="-" key1="^"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="0.75" key0="switch_greekmath"/>
|
||||
<key width="0.75" key0="shift" key2="fn" key4="loc alt"/>
|
||||
<key width="0.75" role="action" key0="switch_greekmath"/>
|
||||
<key width="0.75" role="action" key0="shift" key2="fn" key4="loc alt"/>
|
||||
<key key0="1" key1="superscript" key2="ordinal" key3="subscript"/>
|
||||
<key key0="2"/>
|
||||
<key key0="3"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
<row height="0.95">
|
||||
<key width="1.5" key0="switch_text" key2="ctrl"/>
|
||||
<key width="1.5" role="action" key0="switch_text" key2="ctrl"/>
|
||||
<key width="1.5" key0="0"/>
|
||||
<key width="0.75" key0="." key1=":" key2="," key3=";"/>
|
||||
<key width="0.75" key0="space" key1=""" key2="'" key3="loc compose" key4="_"/>
|
||||
<key width="1.5" key0="enter" key1="±" key2="action" key3="="/>
|
||||
<key width="0.75" role="action" key0="." key1=":" key2="," key3=";"/>
|
||||
<key width="0.75" role="action" key0="action" key1=""" key2="'" key3="loc compose" key4="_"/>
|
||||
<key width="1.5" role="action" key0="enter" key1="±" key2="action" key3="="/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<keyboard bottom_row="false">
|
||||
<row>
|
||||
<key width="0.75" role="action" key0="loc esc" key2="~" key4="!"/>
|
||||
<key width="0.75" role="action" key0="(" key2="[" key4="{"/>
|
||||
<key key0="7"/>
|
||||
<key key0="8"/>
|
||||
<key key0="9"/>
|
||||
<key shift="4" key0="7" key1="<" key2=">"/>
|
||||
<key key0="8" key2="∞"/>
|
||||
<key key0="9" key2="π"/>
|
||||
<key width="0.75" role="action" key0="*" key1="√" key2="×" key3="\#"/>
|
||||
<key width="0.75" role="action" key0="/" key1="%" key3="÷"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="0.75" role="action" key0="loc tab" key2="|" key4="\\"/>
|
||||
<key width="0.75" role="action" key0=")" key2="]" key4="}"/>
|
||||
<key key0="4"/>
|
||||
<key key0="5"/>
|
||||
<key key0="6"/>
|
||||
<key shift="4" key0="4" key1="box" key3="arrows"/>
|
||||
<key key0="5" key7="up" key6="right" key5="left" key8="down"/>
|
||||
<key key0="6"/>
|
||||
<key width="0.75" role="action" key0="+" key1="Σ" key2="$"/>
|
||||
<key width="0.75" role="action" key0="-" key1="^"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="0.75" role="action" key0="switch_greekmath"/>
|
||||
<key width="0.75" role="action" key0="shift" key2="fn" key4="loc alt"/>
|
||||
<key key0="1"/>
|
||||
<key key0="2"/>
|
||||
<key key0="3"/>
|
||||
<key shift="4" key0="1" key1="superscript" key2="ordinal" key3="subscript"/>
|
||||
<key key0="2"/>
|
||||
<key key0="3"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
<row height="0.95">
|
||||
<key width="1.5" role="action" key0="switch_text" key2="ctrl"/>
|
||||
<key width="2" key0="0"/>
|
||||
<key role="action" key0="." key1=":" key2="," key3=";"/>
|
||||
<key width="1.5" shift="4" role="action" key0="space" key1=""" key2="'" key3="loc compose" key4="_"/>
|
||||
<key width="1.5" key0="0"/>
|
||||
<key width="1.5" role="action" key0="enter" key1="±" key2="action" key3="="/>
|
||||
</row>
|
||||
</keyboard>
|
||||
+17
-17
@@ -1,27 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<keyboard bottom_row="false">
|
||||
<row>
|
||||
<key key0="7"/>
|
||||
<key key0="8"/>
|
||||
<key key0="9"/>
|
||||
<key key0="/"/>
|
||||
<key role="action" key0="7"/>
|
||||
<key role="action" key0="8"/>
|
||||
<key role="action" key0="9"/>
|
||||
<key role="action" key0="/"/>
|
||||
</row>
|
||||
<row>
|
||||
<key key0="4"/>
|
||||
<key key0="5"/>
|
||||
<key key0="6"/>
|
||||
<key key0="*"/>
|
||||
<key role="action" key0="4"/>
|
||||
<key role="action" key0="5"/>
|
||||
<key role="action" key0="6"/>
|
||||
<key role="action" key0="*"/>
|
||||
</row>
|
||||
<row>
|
||||
<key key0="1"/>
|
||||
<key key0="2"/>
|
||||
<key key0="3"/>
|
||||
<key key0="-"/>
|
||||
<key role="action" key0="1"/>
|
||||
<key role="action" key0="2"/>
|
||||
<key role="action" key0="3"/>
|
||||
<key role="action" key0="-"/>
|
||||
</row>
|
||||
<row height="0.95">
|
||||
<key key0="0"/>
|
||||
<key key0="."/>
|
||||
<key key0="="/>
|
||||
<key key0="+"/>
|
||||
<key role="action" key0="0"/>
|
||||
<key role="action" key0="."/>
|
||||
<key role="action" key0="="/>
|
||||
<key role="action" key0="+"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
</keyboard>
|
||||
|
||||
+6
-6
@@ -4,24 +4,24 @@
|
||||
<key shift="1.0" key0="1"/>
|
||||
<key key0="2" indication="ABC"/>
|
||||
<key key0="3" indication="DEF"/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
<row>
|
||||
<key shift="1.0" key0="4" indication="GHI"/>
|
||||
<key key0="5" indication="JKL"/>
|
||||
<key key0="6" indication="MNO"/>
|
||||
<key key0="(" key1="paste" key2="=" key3=":" key4="-"/>
|
||||
<key role="action" key0="(" key1="paste" key2="=" key3=":" key4="-"/>
|
||||
</row>
|
||||
<row>
|
||||
<key shift="1.0" key0="7" indication="PQRS"/>
|
||||
<key key0="8" indication="TUV"/>
|
||||
<key key0="9" indication="WXYZ"/>
|
||||
<key key0=")" key2="," key3="/" key4="."/>
|
||||
<key role="action" key0=")" key2="," key3="/" key4="."/>
|
||||
</row>
|
||||
<row>
|
||||
<key shift="1.0" key0="*" key1="switch_text" key3="switch_numeric"/>
|
||||
<key role="action" shift="1.0" key0="*" key1="switch_text" key3="switch_numeric"/>
|
||||
<key key0="0" key3="+" key4="space"/>
|
||||
<key key0="\#" key7="up" key6="right" key5="left" key8="down"/>
|
||||
<key key0="action" key2="enter"/>
|
||||
<key role="action" key0="\#" key7="up" key6="right" key5="left" key8="down"/>
|
||||
<key role="action" key0="action" key2="enter"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<keyboard width="13.0" bottom_row="false">
|
||||
<row>
|
||||
<key shift="1" key0="1"/>
|
||||
<key key0="2"/>
|
||||
<key key0="3"/>
|
||||
<key shift="5" key0="1"/>
|
||||
<key key0="2" indication="ABC"/>
|
||||
<key key0="3" indication="DEF"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
<row>
|
||||
<key shift="1" key0="4"/>
|
||||
<key key0="5"/>
|
||||
<key key0="6"/>
|
||||
<key shift="5" key0="4" indication="GHI"/>
|
||||
<key key0="5" indication="JKL"/>
|
||||
<key key0="6" indication="MNO"/>
|
||||
<key role="action" key0="(" key1="paste" key2="=" key3=":" key4="-"/>
|
||||
</row>
|
||||
<row>
|
||||
<key shift="1" key0="7"/>
|
||||
<key key0="8"/>
|
||||
<key key0="9"/>
|
||||
<key shift="5" key0="7" indication="PQRS"/>
|
||||
<key key0="8" indication="TUV"/>
|
||||
<key key0="9" indication="WXYZ"/>
|
||||
<key role="action" key0=")" key2="," key3="/" key4="."/>
|
||||
</row>
|
||||
<row>
|
||||
<key shift="1" width="1.5" key0="0"/>
|
||||
<key width="1.5" role="action" key0="space"/>
|
||||
<key shift="5" role="action" key0="*" key1="switch_text" key3="switch_numeric"/>
|
||||
<key key0="0" key3="+" key4="space"/>
|
||||
<key role="action" key0="\#" key7="up" key6="right" key5="left" key8="down"/>
|
||||
<key role="action" key0="action" key2="enter"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- The Roku remote page. Not a user-selectable layout: it is opened by the
|
||||
switch_roku key and left with roku_close. Every key above the last row sends
|
||||
an HTTP keypress to the TV (see RokuRemote) instead of typing.
|
||||
|
||||
This page carries nothing but remote keys. It is loaded as a plain layout
|
||||
(Keyboard2.loadRokuLayout), NOT through LayoutModifier.modify_layout, so the
|
||||
forced config key and the configured extra keys do not land on it and do not
|
||||
fill the empty corner slots of these keys. That is why the last row is a
|
||||
full-width "Keyboard" key instead of the config gear: it fires the same
|
||||
Event.SWITCH_TEXT as the switch_text key on other pages and is the way back
|
||||
to the letter keyboard.
|
||||
|
||||
Vol- is also the page's mute: holding it sends mute instead of volume-down
|
||||
(KeyModifier.modify_long_press), so mute is on the page without a slot. -->
|
||||
<keyboard bottom_row="false">
|
||||
<row height="0.8">
|
||||
<key width="3.3" role="action" key0="roku_home"/>
|
||||
<key width="3.3" role="action" key0="roku_back"/>
|
||||
<key width="3.3" role="action" key0="roku_power"/>
|
||||
</row>
|
||||
<row height="0.8">
|
||||
<key shift="3.3" width="3.3" role="action" key0="roku_up"/>
|
||||
</row>
|
||||
<row height="0.8">
|
||||
<key width="3.3" role="action" key0="roku_left"/>
|
||||
<key width="3.3" role="action" key0="roku_select"/>
|
||||
<key width="3.3" role="action" key0="roku_right"/>
|
||||
</row>
|
||||
<row height="0.8">
|
||||
<key shift="3.3" width="3.3" role="action" key0="roku_down"/>
|
||||
</row>
|
||||
<row height="0.8">
|
||||
<key width="3.3" role="action" key0="roku_voldown"/>
|
||||
<key width="3.3" role="action" key0="roku_play"/>
|
||||
<key width="3.3" role="action" key0="roku_volup"/>
|
||||
</row>
|
||||
<row height="1.0">
|
||||
<key width="9.9" role="action" key0="roku_close"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
@@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory android:title="@string/pref_category_layout">
|
||||
<CheckBoxPreference android:key="usage_gauge_enabled" android:title="@string/pref_usage_gauge_enabled" android:defaultValue="true"/>
|
||||
<EditTextPreference android:key="usage_gauge_url" android:title="@string/pref_usage_gauge_url" android:defaultValue="http://10.10.10.1:8771/usage" android:inputType="textUri"/>
|
||||
<EditTextPreference android:key="usage_gauge_token" android:title="@string/pref_usage_gauge_token" android:defaultValue="" android:inputType="textPassword"/>
|
||||
<juloo.keyboard2.prefs.LayoutsPreference/>
|
||||
<PreferenceScreen android:title="@string/pref_extra_keys_title">
|
||||
<PreferenceCategory android:title="@string/pref_extra_keys_custom">
|
||||
@@ -11,6 +14,7 @@
|
||||
<ListPreference android:key="number_row" android:title="@string/pref_number_row_title" android:summary="%s" android:defaultValue="no_number_row" android:entries="@array/pref_show_number_row_entries" android:entryValues="@array/pref_show_number_row_values"/>
|
||||
<ListPreference android:key="show_numpad" android:title="@string/pref_show_numpad_title" android:summary="%s" android:defaultValue="1" android:entries="@array/pref_show_numpad_entries" android:entryValues="@array/pref_show_numpad_values"/>
|
||||
<ListPreference android:key="numpad_layout" android:title="@string/pref_numpad_layout" android:summary="%s" android:defaultValue="high_first" android:entries="@array/pref_numpad_layout_entries" android:entryValues="@array/pref_numpad_layout_values"/>
|
||||
<ListPreference android:key="split_layout" android:title="@string/pref_split_layout" android:summary="%s" android:defaultValue="wide" android:entries="@array/pref_split_layout_entries" android:entryValues="@array/pref_split_layout_values"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_category_suggestions">
|
||||
<CheckBoxPreference android:key="suggestions" android:title="@string/pref_suggestions_title" android:summary="@string/pref_suggestions_summary" android:defaultValue="true"/>
|
||||
@@ -24,6 +28,7 @@
|
||||
<CheckBoxPreference android:key="keyrepeat_enabled" android:title="@string/pref_keyrepeat_enabled" android:defaultValue="true"/>
|
||||
<juloo.keyboard2.prefs.IntSlideBarPreference android:key="longpress_interval" android:dependency="keyrepeat_enabled" android:title="@string/pref_long_interval_title" android:summary="%sms" android:defaultValue="25" min="5" max="100"/>
|
||||
<CheckBoxPreference android:key="lock_double_tap" android:title="@string/pref_lock_double_tap_title" android:summary="@string/pref_lock_double_tap_summary" android:defaultValue="false"/>
|
||||
<ListPreference android:key="physical_keyboard_behavior" android:title="@string/pref_physical_keyboard_behavior" android:summary="%s" android:defaultValue="hide" android:entries="@array/pref_physical_keyboard_behavior_entries" android:entryValues="@array/pref_physical_keyboard_behavior_values"/>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/pref_category_behavior">
|
||||
<CheckBoxPreference android:key="autocapitalisation" android:title="@string/pref_autocapitalisation_title" android:summary="@string/pref_autocapitalisation_summary" android:defaultValue="true"/>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This file define a row but it's layed out as a column instead in
|
||||
[LayoutLandscapeModifier]. -->
|
||||
<row>
|
||||
<key role="suggestion" width="1" c="complete_emoji"/>
|
||||
<key role="suggestion" width="3" c="complete_first"/>
|
||||
<key role="suggestion" width="3" c="complete_second"/>
|
||||
<key role="suggestion" width="3" c="complete_third"/>
|
||||
</row>
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
" ": {
|
||||
// Override the default space-space sequence to show the nbsp symbol
|
||||
" ": "nbsp"
|
||||
},
|
||||
"V": {
|
||||
"~": "Ṽ",
|
||||
"s": "Š",
|
||||
|
||||
@@ -114,11 +114,11 @@ public final class ClipboardHistoryService
|
||||
if (!Config.globalConfig().clipboard_history_enabled)
|
||||
return;
|
||||
int size = _history.size();
|
||||
if (clip.equals("") || (size > 0 && _history.get(size - 1).content.equals(clip)))
|
||||
if (clip.equals("") || (size > 0 && _history.get(0).content.equals(clip)))
|
||||
return;
|
||||
if (size >= MAX_HISTORY_SIZE)
|
||||
_history.remove(0);
|
||||
_history.add(new HistoryEntry(clip));
|
||||
_history.remove(size - 1);
|
||||
_history.add(0,new HistoryEntry(clip));
|
||||
if (_listener != null)
|
||||
_listener.on_clipboard_history_change();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public final class ClipboardPinView extends NonScrollListView
|
||||
/** Pin a clipboard and persist the change. */
|
||||
public void add_entry(String text)
|
||||
{
|
||||
_entries.add(text);
|
||||
_entries.add(0,text);
|
||||
_adapter.notifyDataSetChanged();
|
||||
persist();
|
||||
invalidate();
|
||||
|
||||
@@ -43,7 +43,12 @@ public final class ComposeKey
|
||||
new String(states, next + 1, next_length - 1));
|
||||
}
|
||||
else // Character final state.
|
||||
{
|
||||
// Preserve the named-key identity used by compose sequences for NBSP.
|
||||
if (next_header == '\u00a0')
|
||||
return KeyValue.getKeyByName("nbsp");
|
||||
return KeyValue.makeCharKey((char)next_header);
|
||||
}
|
||||
}
|
||||
|
||||
/** Apply char [c] to the pending compose sequence. If the application resolves
|
||||
|
||||
@@ -75,6 +75,10 @@ public final class Config
|
||||
public boolean clipboard_history_enabled;
|
||||
public int clipboard_history_duration;
|
||||
public boolean space_bar_auto_complete;
|
||||
public boolean physical_keyboard_hide;
|
||||
public boolean usageGaugeEnabled;
|
||||
public String usageGaugeUrl;
|
||||
public String usageGaugeToken;
|
||||
|
||||
// Dynamically set
|
||||
/** Configuration options implied by the connected editor. */
|
||||
@@ -94,6 +98,8 @@ public final class Config
|
||||
[get_current_layout()] and [set_current_layout()]. */
|
||||
int current_layout_narrow;
|
||||
int current_layout_wide;
|
||||
/** Whether to automatically split the layout. */
|
||||
public boolean split_layout;
|
||||
|
||||
private Config(SharedPreferences prefs, Resources res,
|
||||
Boolean foldableUnfolded, Dictionaries dicts)
|
||||
@@ -104,7 +110,7 @@ public final class Config
|
||||
marginTop = res.getDimension(R.dimen.margin_top);
|
||||
keyPadding = res.getDimension(R.dimen.key_padding);
|
||||
labelTextSize = 0.33f;
|
||||
sublabelTextSize = 0.22f;
|
||||
sublabelTextSize = 0.20f;
|
||||
// from prefs
|
||||
refresh(res, foldableUnfolded, dicts);
|
||||
// initialized later
|
||||
@@ -158,8 +164,8 @@ public final class Config
|
||||
longPressInterval = _prefs.getInt("longpress_interval", 65);
|
||||
keyrepeat_enabled = _prefs.getBoolean("keyrepeat_enabled", true);
|
||||
margin_bottom = get_dip_pref_oriented(dm, "margin_bottom", 7, 3);
|
||||
key_vertical_margin = get_dip_pref(dm, "key_vertical_margin", 1.5f) / 100;
|
||||
key_horizontal_margin = get_dip_pref(dm, "key_horizontal_margin", 2) / 100;
|
||||
key_vertical_margin = get_dip_pref(dm, "key_vertical_margin", 6f) / 100;
|
||||
key_horizontal_margin = get_dip_pref(dm, "key_horizontal_margin", 13) / 100;
|
||||
// Label brightness is used as the alpha channel
|
||||
labelBrightness = _prefs.getInt("label_brightness", 100) * 255 / 100;
|
||||
// Keyboard opacity
|
||||
@@ -176,7 +182,7 @@ public final class Config
|
||||
// a layout in KeyboardData unit. The keyboard will be higher if the layout
|
||||
// has more rows and smaller if it has less because rows stay the same
|
||||
// height.
|
||||
keyboard_rows_height_pixels = screenHeightPixels * keyboardHeightPercent / 395;
|
||||
keyboard_rows_height_pixels = (int)(screenHeightPixels * keyboardHeightPercent / 395 * 0.81f);
|
||||
horizontal_margin =
|
||||
get_dip_pref_oriented(dm, "horizontal_margin", 3, 28);
|
||||
double_tap_lock_shift = _prefs.getBoolean("lock_double_tap", false);
|
||||
@@ -195,9 +201,13 @@ public final class Config
|
||||
clipboard_history_enabled = _prefs.getBoolean("clipboard_history_enabled", false);
|
||||
clipboard_history_duration = Integer.parseInt(_prefs.getString("clipboard_history_duration", "5"));
|
||||
space_bar_auto_complete = _prefs.getBoolean("space_bar_auto_complete", false);
|
||||
|
||||
physical_keyboard_hide = _prefs.getString("physical_keyboard_behavior", "hide").equals("hide");
|
||||
usageGaugeEnabled = _prefs.getBoolean("usage_gauge_enabled", true);
|
||||
usageGaugeUrl = _prefs.getString("usage_gauge_url", "http://10.10.10.1:8771/usage");
|
||||
usageGaugeToken = _prefs.getString("usage_gauge_token", "");
|
||||
float screen_width_dp = dm.widthPixels / dm.density;
|
||||
wide_screen = screen_width_dp >= WIDE_DEVICE_THRESHOLD;
|
||||
split_layout = get_split_layout();
|
||||
}
|
||||
|
||||
public int get_current_layout()
|
||||
@@ -272,6 +282,7 @@ public final class Config
|
||||
case "everforestlight": return R.style.EverforestLight;
|
||||
case "cobalt": return R.style.Cobalt;
|
||||
case "pine": return R.style.Pine;
|
||||
case "orchid": return R.style.Orchid;
|
||||
case "epaperblack": return R.style.ePaperBlack;
|
||||
default:
|
||||
case "system":
|
||||
@@ -292,6 +303,16 @@ public final class Config
|
||||
}
|
||||
}
|
||||
|
||||
final boolean get_split_layout()
|
||||
{
|
||||
switch (_prefs.getString("split_layout", "wide"))
|
||||
{
|
||||
case "wide": return wide_screen;
|
||||
case "landscape": return orientation_landscape;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static Config _globalConfig = null;
|
||||
|
||||
public static void initGlobalConfig(SharedPreferences prefs, Resources res,
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package juloo.keyboard2;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class DeepSeekPeak
|
||||
{
|
||||
/**
|
||||
* Peak is Monday through Friday from 01:00 to 04:00 UTC or from 06:00 to
|
||||
* 10:00 UTC. DeepSeek additionally excludes Chinese public holidays; this
|
||||
* helper deliberately ignores that exception.
|
||||
*/
|
||||
public static boolean isPeak(long epochMillis)
|
||||
{
|
||||
Calendar utc = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||
utc.setTimeInMillis(epochMillis);
|
||||
int day = utc.get(Calendar.DAY_OF_WEEK);
|
||||
if (day == Calendar.SATURDAY || day == Calendar.SUNDAY)
|
||||
return false;
|
||||
|
||||
int hour = utc.get(Calendar.HOUR_OF_DAY);
|
||||
return (hour >= 1 && hour < 4) || (hour >= 6 && hour < 10);
|
||||
}
|
||||
|
||||
public static int colorFor(long epochMillis)
|
||||
{
|
||||
return isPeak(epochMillis) ? 0xFFFF2D95 : 0xFF00E5FF;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
long[] samples = {
|
||||
1704675540000L, // Monday 00:59 UTC
|
||||
1704675600000L, // Monday 01:00 UTC
|
||||
1704700800000L, // Monday 08:00 UTC
|
||||
1704711600000L // Monday 11:00 UTC
|
||||
};
|
||||
for (long sample : samples)
|
||||
System.out.println(sample + ": " + (isPeak(sample) ? "peak" : "off-peak"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package juloo.keyboard2;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/** Host load history behind the space bar ribbon.
|
||||
*
|
||||
* Two rules, both Harley's, and they are the whole design:
|
||||
* - failure is quiet. Offline, VPN down, Utumno off, junk payload or a timeout all end as
|
||||
* "no data" - never a crash, and never a stale trace wearing a live face.
|
||||
* - parsing happens on the fetch thread, so the draw path can neither block nor throw.
|
||||
*/
|
||||
public final class HostGraph
|
||||
{
|
||||
/** Payload series order. io leads: a stalled disk is the thing worth seeing. */
|
||||
public static final String[] SERIES = { "io", "cpu", "util" };
|
||||
/** A sample older than this is not worth drawing as if it were now. */
|
||||
/** Safety net only: with the 1 Hz re-arm this never trips, but if fetches stop the ribbon
|
||||
blanks rather than freezing mid-thought. */
|
||||
public static final long MAX_AGE_MS = 15000L;
|
||||
private static final int CONNECT_TIMEOUT_MS = 2500;
|
||||
private static final int READ_TIMEOUT_MS = 2500;
|
||||
/** Matches the server's 1 Hz sampling; only ever called while the keyboard is visible. */
|
||||
private static final long MIN_INTERVAL_MS = 900L;
|
||||
private static final int DEFAULT_N = 60;
|
||||
|
||||
private static final Object _lock = new Object();
|
||||
private static float[][] _values = new float[SERIES.length][];
|
||||
private static long _fetchedAt = 0L;
|
||||
private static long _lastAttempt = 0L;
|
||||
private static boolean _inFlight = false;
|
||||
|
||||
private HostGraph() {}
|
||||
|
||||
/** True only when there is something honest to draw: data, and data that is still current. */
|
||||
public static boolean hasData()
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
if (_values[0] == null || _values[0].length == 0)
|
||||
return false;
|
||||
return System.currentTimeMillis() - _fetchedAt < MAX_AGE_MS;
|
||||
}
|
||||
}
|
||||
|
||||
/** Copy of one series; empty when there is nothing to draw. Safe on the draw path. */
|
||||
public static float[] series(int index)
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
float[] v = (index >= 0 && index < _values.length) ? _values[index] : null;
|
||||
return v == null ? new float[0] : v.clone();
|
||||
}
|
||||
}
|
||||
|
||||
/** The server root, so the ribbon rides the same preference as the usage endpoint. */
|
||||
static String baseOf(String url)
|
||||
{
|
||||
if (url == null)
|
||||
return "";
|
||||
int scheme = url.indexOf("://");
|
||||
int from = scheme < 0 ? 0 : scheme + 3;
|
||||
int slash = url.indexOf('/', from);
|
||||
return slash < 0 ? url : url.substring(0, slash);
|
||||
}
|
||||
|
||||
/** Fetch at most every couple of seconds; call freely while the keyboard is visible. */
|
||||
public static void fetchIfNeeded(String baseUrl, String token, Runnable onDone)
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
synchronized (_lock)
|
||||
{
|
||||
if (_inFlight || now - _lastAttempt < MIN_INTERVAL_MS)
|
||||
return;
|
||||
_inFlight = true;
|
||||
_lastAttempt = now;
|
||||
}
|
||||
Thread worker = new Thread(() -> {
|
||||
try
|
||||
{
|
||||
run(baseUrl, token);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
forget();
|
||||
}
|
||||
finally
|
||||
{
|
||||
synchronized (_lock) { _inFlight = false; }
|
||||
if (onDone != null)
|
||||
{
|
||||
try { onDone.run(); }
|
||||
catch (Throwable t) { /* a repaint request must never take the keyboard down */ }
|
||||
}
|
||||
}
|
||||
}, "host-graph");
|
||||
worker.setDaemon(true);
|
||||
worker.start();
|
||||
}
|
||||
|
||||
private static void forget()
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
_values = new float[SERIES.length][];
|
||||
_fetchedAt = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
private static void run(String baseUrl, String token)
|
||||
{
|
||||
HttpURLConnection connection = null;
|
||||
try
|
||||
{
|
||||
String url = baseUrl + "/graph?n=" + DEFAULT_N;
|
||||
connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT_MS);
|
||||
connection.setReadTimeout(READ_TIMEOUT_MS);
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
if (token != null && !token.isEmpty())
|
||||
connection.setRequestProperty("Authorization", "Bearer " + token);
|
||||
StringBuilder body = new StringBuilder();
|
||||
try (InputStream input = connection.getInputStream();
|
||||
InputStreamReader reader = new InputStreamReader(input, "UTF-8"))
|
||||
{
|
||||
char[] buf = new char[4096];
|
||||
int n;
|
||||
while ((n = reader.read(buf)) > 0)
|
||||
body.append(buf, 0, n);
|
||||
}
|
||||
float[][] parsed = parse(body.toString());
|
||||
if (parsed == null)
|
||||
{
|
||||
forget();
|
||||
return;
|
||||
}
|
||||
synchronized (_lock)
|
||||
{
|
||||
_values = parsed;
|
||||
_fetchedAt = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// No VPN, no route, host off, refused, unreadable: one answer for all of them.
|
||||
forget();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (connection != null)
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/** Parses the payload, or returns null when it cannot be trusted. Pure, therefore tested. */
|
||||
static float[][] parse(String json)
|
||||
{
|
||||
if (json == null)
|
||||
return null;
|
||||
float[][] out = new float[SERIES.length][];
|
||||
for (int i = 0; i < SERIES.length; i++)
|
||||
{
|
||||
int nameAt = json.indexOf("\"" + SERIES[i] + "\"");
|
||||
if (nameAt < 0)
|
||||
return null; // a series we cannot read is no data at all
|
||||
int open = json.indexOf('[', nameAt);
|
||||
int close = open < 0 ? -1 : json.indexOf(']', open);
|
||||
if (open < 0 || close < 0)
|
||||
return null;
|
||||
String[] parts = json.substring(open + 1, close).split(",");
|
||||
float[] values = new float[parts.length];
|
||||
for (int j = 0; j < parts.length; j++)
|
||||
{
|
||||
try
|
||||
{
|
||||
values[j] = Float.parseFloat(parts[j].trim());
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (values.length == 0)
|
||||
return null;
|
||||
out[i] = values;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -36,14 +36,14 @@ public final class KeyEventHandler
|
||||
LastAction _last_action = null;
|
||||
LastAction _next_last_action = null;
|
||||
|
||||
public KeyEventHandler(IReceiver recv, Config config)
|
||||
public KeyEventHandler(IReceiver recv, Suggestions sg)
|
||||
{
|
||||
_recv = recv;
|
||||
Handler handler = recv.getHandler();
|
||||
_autocap = new Autocapitalisation(handler,
|
||||
this.new Autocapitalisation_callback());
|
||||
_mods = Pointers.Modifiers.EMPTY;
|
||||
_suggestions = new Suggestions(recv, config);
|
||||
_suggestions = sg;
|
||||
_typedword = new CurrentlyTypedWord(handler, this);
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ public final class KeyEventHandler
|
||||
case Compose_pending: _recv.set_compose_pending(true); break;
|
||||
case Slider: handle_slider(key.getSlider(), key.getSliderRepeat(), false); break;
|
||||
case Macro: evaluate_macro(key.getMacro()); break;
|
||||
case Stateful: handle_stateful(key.getStateful()); break;
|
||||
}
|
||||
update_meta_state(old_mods);
|
||||
_last_action = _next_last_action;
|
||||
@@ -334,6 +335,19 @@ public final class KeyEventHandler
|
||||
}
|
||||
}
|
||||
|
||||
void handle_stateful(KeyValue.Stateful st)
|
||||
{
|
||||
switch (st)
|
||||
{
|
||||
case Complete_first:
|
||||
case Complete_second:
|
||||
case Complete_third:
|
||||
case Complete_emoji:
|
||||
suggestion_entered(st.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Move the cursor right or left, if possible without sending key events.
|
||||
Unlike arrow keys, the selection is not removed even if shift is not on.
|
||||
Falls back to sending arrow keys events if the editor do not support
|
||||
|
||||
@@ -112,6 +112,13 @@ public final class KeyModifier
|
||||
return KeyValue.CHANGE_METHOD;
|
||||
case SWITCH_VOICE_TYPING:
|
||||
return KeyValue.VOICE_TYPING_CHOOSER;
|
||||
/* The Roku page's volume-down key: held, it is the TV's mute instead of
|
||||
volume-down. This is the same path the two keys above take, so [Pointers]
|
||||
replaces the pointer's value while the finger is still down and the single
|
||||
[key_up] on release carries the mute - the short press is not sent as well.
|
||||
Mute therefore lives on the page without taking a slot of its own. */
|
||||
case ROKU_VOLDOWN:
|
||||
return KeyValue.ROKU_VOLUME_MUTE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -141,23 +148,19 @@ public final class KeyModifier
|
||||
{
|
||||
switch (kv.getKind())
|
||||
{
|
||||
case Char:
|
||||
case String:
|
||||
/* These keys are not greyed. */
|
||||
case Event:
|
||||
case Modifier:
|
||||
return kv;
|
||||
/* Tapping compose again exits the pending sequence. */
|
||||
case Compose_pending:
|
||||
return KeyValue.COMPOSE_CANCEL;
|
||||
default:
|
||||
KeyValue res = ComposeKey.apply(state, kv);
|
||||
// Grey-out characters not part of any sequence.
|
||||
if (res == null)
|
||||
return kv.withFlags(kv.getFlags() | KeyValue.FLAG_GREYED);
|
||||
return res;
|
||||
/* Tapping compose again exits the pending sequence. */
|
||||
case Compose_pending:
|
||||
return KeyValue.COMPOSE_CANCEL;
|
||||
/* These keys are not greyed. */
|
||||
case Event:
|
||||
case Modifier:
|
||||
return kv;
|
||||
/* Other keys cannot be part of sequences. */
|
||||
default:
|
||||
return kv.withFlags(kv.getFlags() | KeyValue.FLAG_GREYED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
{
|
||||
CONFIG,
|
||||
SWITCH_TEXT,
|
||||
SWITCH_FN,
|
||||
SWITCH_NUMERIC,
|
||||
SWITCH_EMOJI,
|
||||
SWITCH_BACK_EMOJI,
|
||||
@@ -24,6 +25,41 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
CAPS_LOCK,
|
||||
SWITCH_VOICE_TYPING,
|
||||
SWITCH_VOICE_TYPING_CHOOSER,
|
||||
HIDE_SELF,
|
||||
/* The Roku remote page and the keys on it. These are appended: the ordinals are
|
||||
in-process only, so adding at the end never renumbers an existing key. */
|
||||
SWITCH_ROKU,
|
||||
ROKU_HOME,
|
||||
ROKU_BACK,
|
||||
ROKU_UP,
|
||||
ROKU_DOWN,
|
||||
ROKU_LEFT,
|
||||
ROKU_RIGHT,
|
||||
ROKU_SELECT,
|
||||
ROKU_PLAY,
|
||||
ROKU_REWIND,
|
||||
ROKU_FORWARD,
|
||||
ROKU_POWER,
|
||||
ROKU_VOLUP,
|
||||
ROKU_VOLDOWN,
|
||||
ROKU_VOLMUTE,
|
||||
/* The lights page (res/xml/lights.xml) and its keys. Appended for the same reason as the Roku
|
||||
events above: the ordinals only mean anything in-process. LIGHT_1..LIGHT_12 are the page's
|
||||
slots - one per light, in the order the proxy lists them - and SWITCH_LIGHTS is the door to
|
||||
the page itself. */
|
||||
SWITCH_LIGHTS,
|
||||
LIGHT_1,
|
||||
LIGHT_2,
|
||||
LIGHT_3,
|
||||
LIGHT_4,
|
||||
LIGHT_5,
|
||||
LIGHT_6,
|
||||
LIGHT_7,
|
||||
LIGHT_8,
|
||||
LIGHT_9,
|
||||
LIGHT_10,
|
||||
LIGHT_11,
|
||||
LIGHT_12,
|
||||
}
|
||||
|
||||
// Must be evaluated in the reverse order of their values.
|
||||
@@ -104,6 +140,7 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
String, // [_payload] is also the string to output, value is unused.
|
||||
Slider, // [_payload] is a [KeyValue.Slider], value is slider repeatition.
|
||||
Macro, // [_payload] is a [KeyValue.Macro], value is unused.
|
||||
Stateful, // [_payload] is a [KeyValue.Stateful], value is the query.
|
||||
}
|
||||
|
||||
private static final int FLAGS_OFFSET = 20;
|
||||
@@ -238,6 +275,12 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
return ((Macro)_payload).keys;
|
||||
}
|
||||
|
||||
/** Defined only when [getKind() == Kind.Stateful]. */
|
||||
public Stateful getStateful()
|
||||
{
|
||||
return (Stateful)_payload;
|
||||
}
|
||||
|
||||
/* Update the char and the symbol. */
|
||||
public KeyValue withChar(char c)
|
||||
{
|
||||
@@ -422,6 +465,11 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
id.ordinal(), flags | FLAG_KEY_FONT);
|
||||
}
|
||||
|
||||
private static KeyValue statefulKey(Stateful st)
|
||||
{
|
||||
return new KeyValue(st, Kind.Stateful, 0, FLAG_SMALLER_FONT | FLAG_SPECIAL);
|
||||
}
|
||||
|
||||
public static KeyValue makeStringKey(String str)
|
||||
{
|
||||
return makeStringKey(str, 0);
|
||||
@@ -480,6 +528,26 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
return eventKey(symbol, Event.ACTION, FLAG_SMALLER_FONT);
|
||||
}
|
||||
|
||||
/** A key on the lights page: one light, labelled with the name the proxy reported for it, already
|
||||
shortened to fit the key (see [LightsPage.displayName]). The label travels in the key value,
|
||||
so the page shows exactly the names the box gave us, and the state colour is applied when the
|
||||
key is drawn ([LightsPage.colorFor]). */
|
||||
public static KeyValue lightKey(String label, Event ev)
|
||||
{
|
||||
return eventKey(label, ev, FLAG_SMALLER_FONT);
|
||||
}
|
||||
|
||||
/** The state glyph of a lights key, drawn in the corner above the light's name. It carries
|
||||
FLAG_KEY_FONT - it is a glyph, not text - and that is what tells it apart from the name on the
|
||||
same key, so [LightsPage.isStateGlyph] can pick it out. Which of the two lamps is drawn is
|
||||
decided when the key is drawn, not here: a press or a poll changes the state under the key
|
||||
without the page being rebuilt. The value stored is the unlit lamp, so that anything that
|
||||
draws this key without asking for the state (a fallback, a preview) never shows a light on. */
|
||||
public static KeyValue lightGlyphKey(Event ev)
|
||||
{
|
||||
return eventKey(0xE026, ev, FLAG_KEY_FONT);
|
||||
}
|
||||
|
||||
/** Make a key that types a string. A char key is returned for a string of
|
||||
length 1. */
|
||||
public static KeyValue makeStringKey(String str, int flags)
|
||||
@@ -530,6 +598,10 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
public static final KeyValue CHANGE_METHOD_PREV = eventKey(0xE009, Event.CHANGE_METHOD_PREV, FLAG_SMALLER_FONT);
|
||||
public static final KeyValue CHANGE_METHOD_NEXT = eventKey(0xE009, Event.CHANGE_METHOD_NEXT, FLAG_SMALLER_FONT);
|
||||
public static final KeyValue VOICE_TYPING_CHOOSER = eventKey(0xE015, Event.SWITCH_VOICE_TYPING_CHOOSER, FLAG_SMALLER_FONT);
|
||||
/** The Roku page's mute key. It is also what a long press on the page's volume-down key
|
||||
sends (see [KeyModifier.modify_long_press]), so mute lives on the page without
|
||||
spending a slot on it; both uses share this one key. */
|
||||
public static final KeyValue ROKU_VOLUME_MUTE = eventKey("Mute", Event.ROKU_VOLMUTE, FLAG_SMALLER_FONT);
|
||||
public static final KeyValue COMPOSE_CANCEL = placeholderKey(0xE01A, Placeholder.COMPOSE_CANCEL, FLAG_SECONDARY);
|
||||
|
||||
public static KeyValue getSpecialKeyByName(String name)
|
||||
@@ -576,6 +648,7 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
case "box": return modifierKey("Box", Modifier.BOX, 0);
|
||||
case "fn": return modifierKey("Fn", Modifier.FN, 0);
|
||||
case "meta": return modifierKey("Meta", Modifier.META, 0);
|
||||
case "tux": return modifierKey("Meta", Modifier.META, 0);
|
||||
|
||||
/* Combining diacritics */
|
||||
/* Glyphs is the corresponding dead-key + 0x0100. */
|
||||
@@ -628,14 +701,51 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
/* Special event keys */
|
||||
case "config": return CONFIG;
|
||||
case "switch_text": return eventKey("ABC", Event.SWITCH_TEXT, FLAG_SMALLER_FONT);
|
||||
case "switch_fn": return eventKey("Fn", Event.SWITCH_FN, FLAG_SMALLER_FONT);
|
||||
case "switch_numeric": return eventKey("123+", Event.SWITCH_NUMERIC, FLAG_SMALLER_FONT);
|
||||
case "switch_emoji": return eventKey(0xE001, Event.SWITCH_EMOJI, FLAG_SMALLER_FONT);
|
||||
case "switch_emoji": return eventKey(0xE01D, Event.SWITCH_EMOJI, FLAG_SMALLER_FONT);
|
||||
case "switch_back_emoji": return eventKey("ABC", Event.SWITCH_BACK_EMOJI, 0);
|
||||
case "switch_clipboard": return eventKey(0xE017, Event.SWITCH_CLIPBOARD, 0);
|
||||
case "switch_back_clipboard": return eventKey("ABC", Event.SWITCH_BACK_CLIPBOARD, 0);
|
||||
case "switch_forward": return eventKey(0xE013, Event.SWITCH_FORWARD, FLAG_SMALLER_FONT);
|
||||
case "switch_backward": return eventKey(0xE014, Event.SWITCH_BACKWARD, FLAG_SMALLER_FONT);
|
||||
case "switch_greekmath": return eventKey("πλ∇¬", Event.SWITCH_GREEKMATH, FLAG_SMALLER_FONT);
|
||||
/* Opens the Roku remote page (res/xml/roku.xml). The glyph is the remote drawn
|
||||
at 0xE024 in the special font. */
|
||||
case "switch_roku": return eventKey(0xE024, Event.SWITCH_ROKU, FLAG_SMALLER_FONT);
|
||||
/* The remote's own keys. Labels only: the key sends an HTTP request instead of
|
||||
typing (see RokuRemote). */
|
||||
case "roku_home": return eventKey("Home", Event.ROKU_HOME, FLAG_SMALLER_FONT);
|
||||
case "roku_back": return eventKey("Back", Event.ROKU_BACK, FLAG_SMALLER_FONT);
|
||||
case "roku_up": return eventKey(0xE005, Event.ROKU_UP, FLAG_SMALLER_FONT);
|
||||
case "roku_down": return eventKey(0xE007, Event.ROKU_DOWN, FLAG_SMALLER_FONT);
|
||||
case "roku_left": return eventKey(0xE008, Event.ROKU_LEFT, FLAG_SMALLER_FONT);
|
||||
case "roku_right": return eventKey(0xE006, Event.ROKU_RIGHT, FLAG_SMALLER_FONT);
|
||||
case "roku_select": return eventKey("OK", Event.ROKU_SELECT, FLAG_SMALLER_FONT);
|
||||
case "roku_play": return eventKey("Play", Event.ROKU_PLAY, FLAG_SMALLER_FONT);
|
||||
case "roku_rewind": return eventKey("Rewind", Event.ROKU_REWIND, FLAG_SMALLER_FONT);
|
||||
case "roku_forward": return eventKey("Forward", Event.ROKU_FORWARD, FLAG_SMALLER_FONT);
|
||||
case "roku_power": return eventKey("Power", Event.ROKU_POWER, FLAG_SMALLER_FONT);
|
||||
/* The TV's volume, same ECP path as the rest of the page (RokuRemote sends the
|
||||
VolumeUp/VolumeDown/VolumeMute keypresses Harley's own web remote uses). */
|
||||
case "roku_volup": return eventKey("Vol+", Event.ROKU_VOLUP, FLAG_SMALLER_FONT);
|
||||
case "roku_voldown": return eventKey("Vol-", Event.ROKU_VOLDOWN, FLAG_SMALLER_FONT);
|
||||
case "roku_volmute": return ROKU_VOLUME_MUTE;
|
||||
/* The way back from the Roku page. The same event as "switch_text", which is
|
||||
unchanged, but labelled: the page has no config key, so this is the only exit
|
||||
and "ABC" does not read as one on a page full of remote keys. */
|
||||
case "roku_close": return eventKey("Keyboard", Event.SWITCH_TEXT, FLAG_SMALLER_FONT);
|
||||
/* The lights page (res/xml/lights.xml). The door is the lamp drawn at 0xE025 in the special
|
||||
font, in a corner slot of the Alt key. The three "light_N" names are the template's slot
|
||||
row: [LightsPage.build] repeats that row once per row of lights and replaces both values of
|
||||
each slot - the label with a light's name and the corner with its state glyph - so the
|
||||
value here only has to exist for the XML to parse. Which lights those slots are is decided
|
||||
by the proxy's answer, never by a name written down here. */
|
||||
case "switch_lights": return eventKey(0xE025, Event.SWITCH_LIGHTS, FLAG_SMALLER_FONT);
|
||||
case "lights_close": return eventKey("Keyboard", Event.SWITCH_TEXT, FLAG_SMALLER_FONT);
|
||||
case "light_1": return eventKey(LightsPage.PLACEHOLDER, Event.LIGHT_1, FLAG_SMALLER_FONT);
|
||||
case "light_2": return eventKey(LightsPage.PLACEHOLDER, Event.LIGHT_2, FLAG_SMALLER_FONT);
|
||||
case "light_3": return eventKey(LightsPage.PLACEHOLDER, Event.LIGHT_3, FLAG_SMALLER_FONT);
|
||||
case "change_method": return CHANGE_METHOD;
|
||||
case "change_method_prev": return CHANGE_METHOD_PREV;
|
||||
case "change_method_next": return CHANGE_METHOD_NEXT;
|
||||
@@ -643,6 +753,11 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
case "capslock": return eventKey(0xE012, Event.CAPS_LOCK, 0);
|
||||
case "voice_typing": return eventKey(0xE015, Event.SWITCH_VOICE_TYPING, FLAG_SMALLER_FONT);
|
||||
case "voice_typing_chooser": return VOICE_TYPING_CHOOSER;
|
||||
case "complete_first": return statefulKey(Stateful.Complete_first);
|
||||
case "complete_second": return statefulKey(Stateful.Complete_second);
|
||||
case "complete_third": return statefulKey(Stateful.Complete_third);
|
||||
case "complete_emoji": return statefulKey(Stateful.Complete_emoji);
|
||||
case "hide_self": return eventKey("⊻", Event.HIDE_SELF, FLAG_SMALLER_FONT);
|
||||
|
||||
/* Key events */
|
||||
case "esc": return keyeventKey("Esc", KeyEvent.KEYCODE_ESCAPE, FLAG_SMALLER_FONT);
|
||||
@@ -653,6 +768,8 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
case "left": return keyeventKey(0xE008, KeyEvent.KEYCODE_DPAD_LEFT, FLAG_SMALLER_FONT);
|
||||
case "page_up": return keyeventKey(0xE002, KeyEvent.KEYCODE_PAGE_UP, 0);
|
||||
case "page_down": return keyeventKey(0xE003, KeyEvent.KEYCODE_PAGE_DOWN, 0);
|
||||
case "pgup": return keyeventKey("pgup", KeyEvent.KEYCODE_PAGE_UP, FLAG_SMALLER_FONT);
|
||||
case "pgdn": return keyeventKey("pgdn", KeyEvent.KEYCODE_PAGE_DOWN, FLAG_SMALLER_FONT);
|
||||
case "home": return keyeventKey(0xE00B, KeyEvent.KEYCODE_MOVE_HOME, FLAG_SMALLER_FONT);
|
||||
case "end": return keyeventKey(0xE00C, KeyEvent.KEYCODE_MOVE_END, FLAG_SMALLER_FONT);
|
||||
case "delete": return keyeventKey(0xE010, KeyEvent.KEYCODE_FORWARD_DEL, 0);
|
||||
@@ -676,7 +793,7 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
/* Spaces */
|
||||
case "\\t": return charKey("\\t", '\t', 0); // Send the tab character
|
||||
case "\\n": return charKey("\\n", '\n', 0); // Send the newline character
|
||||
case "space": return editingKey(0xE00D, Editing.SPACE_BAR, FLAG_SMALLER_FONT | FLAG_GREYED);
|
||||
case "space": return editingKey(0xE001, Editing.SPACE_BAR, FLAG_SMALLER_FONT | FLAG_GREYED);
|
||||
case "nbsp": return charKey("\u237d", '\u00a0', FLAG_SMALLER_FONT);
|
||||
case "nnbsp": return charKey("\u2423", '\u202F', FLAG_SMALLER_FONT);
|
||||
|
||||
@@ -740,6 +857,7 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
case "cursor_right": return sliderKey(Slider.Cursor_right, 1);
|
||||
case "cursor_up": return sliderKey(Slider.Cursor_up, 1);
|
||||
case "cursor_down": return sliderKey(Slider.Cursor_down, 1);
|
||||
case "cursor_joystick": return sliderKey(Slider.Cursor_joystick, 1);
|
||||
case "selection_cancel": return editingKey("Esc", Editing.SELECTION_CANCEL, FLAG_SMALLER_FONT | FLAG_SPECIAL);
|
||||
case "selection_cursor_left": return sliderKey(Slider.Selection_cursor_left, -1); // Move the left side of the selection
|
||||
case "selection_cursor_right": return sliderKey(Slider.Selection_cursor_right, 1);
|
||||
@@ -852,7 +970,8 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
Cursor_up(0xE005, true),
|
||||
Cursor_down(0xE007, true),
|
||||
Selection_cursor_left(0xE008, false),
|
||||
Selection_cursor_right(0xE006, false);
|
||||
Selection_cursor_right(0xE006, false),
|
||||
Cursor_joystick(0xE001, false);
|
||||
|
||||
final String symbol;
|
||||
final boolean vertical;
|
||||
@@ -867,6 +986,10 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
return vertical;
|
||||
}
|
||||
|
||||
public boolean isJoystick() {
|
||||
return this == Cursor_joystick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return symbol; }
|
||||
|
||||
@@ -912,4 +1035,33 @@ public final class KeyValue implements Comparable<KeyValue>
|
||||
return _symbol.compareTo(snd._symbol);
|
||||
}
|
||||
};
|
||||
|
||||
/** Stateful keys are keys whose symbol must be constantly computed from the
|
||||
app's state. */
|
||||
public static enum Stateful implements Describe
|
||||
{
|
||||
Complete_first,
|
||||
Complete_second,
|
||||
Complete_third,
|
||||
Complete_emoji;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if (_handler == null)
|
||||
return "";
|
||||
String s = _handler.provide_stateful_key_symbol(this);
|
||||
return (s == null) ? "" : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() { return name(); }
|
||||
|
||||
public static Symbol_provider _handler = null;
|
||||
|
||||
public static interface Symbol_provider
|
||||
{
|
||||
public String provide_stateful_key_symbol(Stateful q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,63 @@ import juloo.keyboard2.suggestions.Suggestions;
|
||||
public class Keyboard2 extends InputMethodService
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||
{
|
||||
/** The ribbon follows the server's 1 Hz sampling, so it crawls instead of jumping. */
|
||||
private static final long HOST_GRAPH_REFRESH_MS = 1000L;
|
||||
|
||||
/** Re-armed only while the keyboard is on screen, so hiding it stops the polling dead. */
|
||||
private final Runnable _hostGraphRefresh = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (!_keyboard_layout_view.isShown())
|
||||
return;
|
||||
if (_config.usageGaugeEnabled)
|
||||
HostGraph.fetchIfNeeded(HostGraph.baseOf(_config.usageGaugeUrl), _config.usageGaugeToken,
|
||||
() -> _handler.post(() -> _keyboard_layout_view.invalidate()));
|
||||
_handler.postDelayed(this, HOST_GRAPH_REFRESH_MS);
|
||||
}
|
||||
};
|
||||
/** The lights page (res/xml/lights.xml): a page of its own, opened by the switch_lights key.
|
||||
Non-null means it is the page on screen, and only then is [LightsProxy] asked for anything -
|
||||
once per [LightsProxy.POLL_MS], because a light changes rarely and the usage gauge's 1 Hz
|
||||
would be absurd here. */
|
||||
private KeyboardData _lightsLayout = null;
|
||||
/** The [LightsProxy.version] the open lights page was built from. A different version means a
|
||||
light was added, removed or renamed under the page, so it has to be rebuilt. */
|
||||
private int _lightsVersion = -1;
|
||||
|
||||
/** Re-armed only while the lights page is on screen, so closing it stops the polling dead. */
|
||||
private final Runnable _lightsRefresh = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (_lightsLayout == null || !_keyboard_layout_view.isShown())
|
||||
return;
|
||||
LightsProxy.fetchIfNeeded(false, () -> _handler.post(Keyboard2.this::onLightsLoaded));
|
||||
_handler.postDelayed(this, LightsProxy.POLL_MS);
|
||||
}
|
||||
};
|
||||
|
||||
/** Called on the main thread when a lights read or a press has finished: repaint, and rebuild
|
||||
the page if the light list itself changed. */
|
||||
void onLightsLoaded()
|
||||
{
|
||||
if (_keyboard_layout_view == null)
|
||||
return;
|
||||
if (_lightsLayout != null && _lightsVersion != LightsProxy.version())
|
||||
{
|
||||
_lightsVersion = LightsProxy.version();
|
||||
_lightsLayout = loadLightsLayout();
|
||||
_keyboard_layout_view.setKeyboard(_lightsLayout);
|
||||
}
|
||||
_keyboard_layout_view.invalidate();
|
||||
}
|
||||
|
||||
/** The view containing the keyboard and candidates view. */
|
||||
private ViewGroup _keyboard_container_view;
|
||||
private Keyboard2View _keyboard_layout_view;
|
||||
private CandidatesView _candidates_view;
|
||||
private Suggestions _suggestions;
|
||||
private KeyEventHandler _keyeventhandler;
|
||||
/** If not 'null', the layout to use instead of [_config.current_layout]. */
|
||||
private KeyboardData _currentSpecialLayout;
|
||||
@@ -49,6 +102,16 @@ public class Keyboard2 extends InputMethodService
|
||||
private ViewGroup _emojiPane = null;
|
||||
private ViewGroup _clipboard_pane = null;
|
||||
private Handler _handler;
|
||||
private final Runnable _peakIndicatorRefresh = new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_keyboard_layout_view != null)
|
||||
_keyboard_layout_view.invalidate();
|
||||
_handler.postDelayed(this, 60000);
|
||||
}
|
||||
};
|
||||
|
||||
private Config _config;
|
||||
|
||||
@@ -82,6 +145,7 @@ public class Keyboard2 extends InputMethodService
|
||||
{
|
||||
_config.set_current_layout(l);
|
||||
_currentSpecialLayout = null;
|
||||
_lightsLayout = null; // the lights page is not the page any more
|
||||
_keyboard_layout_view.setKeyboard(current_layout());
|
||||
}
|
||||
|
||||
@@ -93,6 +157,9 @@ public class Keyboard2 extends InputMethodService
|
||||
|
||||
void setSpecialLayout(KeyboardData l)
|
||||
{
|
||||
/* Any other page replaces the lights page, and only the lights page polls. */
|
||||
if (l != _lightsLayout)
|
||||
_lightsLayout = null;
|
||||
_currentSpecialLayout = l;
|
||||
_keyboard_layout_view.setKeyboard(l);
|
||||
}
|
||||
@@ -109,6 +176,39 @@ public class Keyboard2 extends InputMethodService
|
||||
current_layout_unmodified());
|
||||
}
|
||||
|
||||
KeyboardData loadNumericLayout()
|
||||
{
|
||||
return loadNumpad(_config.orientation_landscape ?
|
||||
R.xml.numeric_landscape : R.xml.numeric);
|
||||
}
|
||||
|
||||
KeyboardData loadFnLayout()
|
||||
{
|
||||
return LayoutModifier.modify_layout(
|
||||
KeyboardData.load(getResources(), R.xml.fn));
|
||||
}
|
||||
|
||||
/** The Roku remote: a whole page of keys that send commands instead of typing.
|
||||
Loaded as a plain layout ([loadLayout]), deliberately NOT through
|
||||
[LayoutModifier.modify_layout]: the page is nothing but remote keys, so the
|
||||
config key the modifier force-adds and the extra keys it drops into the free
|
||||
corner slots must stay off it. The page's own 'roku_close' key
|
||||
(Event.SWITCH_TEXT, labelled 'Keyboard') is the way back to the text layout. */
|
||||
KeyboardData loadRokuLayout()
|
||||
{
|
||||
return loadLayout(R.xml.roku);
|
||||
}
|
||||
|
||||
/** The lights page: the skeleton in res/xml/lights.xml with one key per light the proxy last
|
||||
reported (see [LightsPage.build]). Loaded as a plain layout for the same reason as the Roku
|
||||
page: the page is its own keys and the way back, so the config key and the user's extra keys
|
||||
must stay off it. It is rebuilt - not modified - when the light list changes, which is why
|
||||
each light's name and slot live in its key values. */
|
||||
KeyboardData loadLightsLayout()
|
||||
{
|
||||
return LightsPage.build(loadLayout(R.xml.lights), LightsProxy.lights());
|
||||
}
|
||||
|
||||
KeyboardData loadPinentry(int layout_id)
|
||||
{
|
||||
return LayoutModifier.modify_pinentry(KeyboardData.load(getResources(), layout_id),
|
||||
@@ -126,7 +226,10 @@ public class Keyboard2 extends InputMethodService
|
||||
Config.initGlobalConfig(prefs, getResources(),
|
||||
_foldStateTracker.isUnfolded(), _dictionaries);
|
||||
_config = Config.globalConfig();
|
||||
_keyeventhandler = new KeyEventHandler(this.new Receiver(), _config);
|
||||
Receiver recvr = this.new Receiver();
|
||||
_suggestions = new Suggestions(recvr, _config);
|
||||
_keyeventhandler = new KeyEventHandler(recvr, _suggestions);
|
||||
KeyValue.Stateful._handler = recvr;
|
||||
_config.handler = _keyeventhandler;
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
Logs.set_debug_logs(getResources().getBoolean(R.bool.debug_logs));
|
||||
@@ -138,6 +241,7 @@ public class Keyboard2 extends InputMethodService
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
_handler.removeCallbacks(_peakIndicatorRefresh);
|
||||
super.onDestroy();
|
||||
|
||||
_foldStateTracker.close();
|
||||
@@ -192,7 +296,8 @@ public class Keyboard2 extends InputMethodService
|
||||
{
|
||||
boolean should_show =
|
||||
_config.suggestions_enabled
|
||||
&& _config.editor_config.should_show_candidates_view;
|
||||
&& _config.editor_config.should_show_candidates_view
|
||||
&& !_config.split_layout;
|
||||
if (should_show)
|
||||
_candidates_view.refresh_config(_config);
|
||||
_candidates_view.setVisibility(should_show ? View.VISIBLE : View.GONE);
|
||||
@@ -227,8 +332,11 @@ public class Keyboard2 extends InputMethodService
|
||||
{
|
||||
switch (_config.selected_number_layout)
|
||||
{
|
||||
case PIN: return loadPinentry(R.xml.pin);
|
||||
case NUMBER: return loadNumpad(R.xml.numeric);
|
||||
case PIN:
|
||||
return loadPinentry(_config.orientation_landscape ?
|
||||
R.xml.pin_landscape : R.xml.pin);
|
||||
case NUMBER:
|
||||
return loadNumericLayout();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -240,10 +348,21 @@ public class Keyboard2 extends InputMethodService
|
||||
_config.editor_config.refresh(info, getResources());
|
||||
refresh_config();
|
||||
_currentSpecialLayout = refresh_special_layout();
|
||||
_lightsLayout = null; // a fresh input session starts on a text layout
|
||||
_keyboard_layout_view.setKeyboard(current_layout());
|
||||
_keyeventhandler.started(_config);
|
||||
setInputView(_keyboard_container_view);
|
||||
Logs.debug_startup_input_view(info, _config);
|
||||
_handler.removeCallbacks(_peakIndicatorRefresh);
|
||||
_handler.postDelayed(_peakIndicatorRefresh, 60000);
|
||||
if (_config.usageGaugeEnabled)
|
||||
UsageGauge.fetchIfNeeded(_config.usageGaugeUrl, _config.usageGaugeToken,
|
||||
() -> _handler.post(() -> _keyboard_layout_view.invalidate()));
|
||||
if (_config.usageGaugeEnabled)
|
||||
HostGraph.fetchIfNeeded(HostGraph.baseOf(_config.usageGaugeUrl), _config.usageGaugeToken,
|
||||
() -> _handler.post(() -> _keyboard_layout_view.invalidate()));
|
||||
_handler.removeCallbacks(_hostGraphRefresh);
|
||||
_handler.postDelayed(_hostGraphRefresh, HOST_GRAPH_REFRESH_MS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -343,6 +462,7 @@ public class Keyboard2 extends InputMethodService
|
||||
@Override
|
||||
public void onFinishInputView(boolean finishingInput)
|
||||
{
|
||||
_handler.removeCallbacks(_peakIndicatorRefresh);
|
||||
super.onFinishInputView(finishingInput);
|
||||
_keyboard_layout_view.reset();
|
||||
}
|
||||
@@ -368,7 +488,8 @@ public class Keyboard2 extends InputMethodService
|
||||
if (super.onEvaluateInputViewShown())
|
||||
return true;
|
||||
if (getResources().getConfiguration().hardKeyboardHidden
|
||||
== Configuration.HARDKEYBOARDHIDDEN_NO)
|
||||
== Configuration.HARDKEYBOARDHIDDEN_NO
|
||||
&& _config.physical_keyboard_hide)
|
||||
{
|
||||
Logs.debug("Physical keyboard is present");
|
||||
return false;
|
||||
@@ -390,7 +511,8 @@ public class Keyboard2 extends InputMethodService
|
||||
}
|
||||
|
||||
/** Not static */
|
||||
public class Receiver implements KeyEventHandler.IReceiver
|
||||
public class Receiver implements KeyEventHandler.IReceiver,
|
||||
KeyValue.Stateful.Symbol_provider
|
||||
{
|
||||
public void handle_event_key(KeyValue.Event ev)
|
||||
{
|
||||
@@ -402,11 +524,53 @@ public class Keyboard2 extends InputMethodService
|
||||
|
||||
case SWITCH_TEXT:
|
||||
_currentSpecialLayout = null;
|
||||
_lightsLayout = null; // the way back from the lights page: stop its polling
|
||||
_keyboard_layout_view.setKeyboard(current_layout());
|
||||
break;
|
||||
|
||||
case SWITCH_NUMERIC:
|
||||
setSpecialLayout(loadNumpad(R.xml.numeric));
|
||||
setSpecialLayout(loadNumericLayout());
|
||||
break;
|
||||
|
||||
case SWITCH_FN:
|
||||
setSpecialLayout(loadFnLayout());
|
||||
break;
|
||||
|
||||
case SWITCH_ROKU:
|
||||
setSpecialLayout(loadRokuLayout());
|
||||
break;
|
||||
|
||||
case SWITCH_LIGHTS:
|
||||
/* Opening the page asks at once - its keys are drawn from the last snapshot and this is
|
||||
the moment to make it current - and then re-arms the slow poll. */
|
||||
_lightsVersion = LightsProxy.version();
|
||||
_lightsLayout = loadLightsLayout();
|
||||
setSpecialLayout(_lightsLayout);
|
||||
LightsProxy.fetchIfNeeded(true, () -> _handler.post(() -> onLightsLoaded()));
|
||||
_handler.removeCallbacks(_lightsRefresh);
|
||||
_handler.postDelayed(_lightsRefresh, LightsProxy.POLL_MS);
|
||||
break;
|
||||
|
||||
/* One key per light. Like the Roku keys, a press only hands the work to a worker thread
|
||||
and returns: the POST waits for Home Assistant to settle, which is seconds, and
|
||||
[handle_event_key] runs on the main thread. A press is never retried (see
|
||||
[LightsProxy.toggle]), and a second press on a light whose toggle is still in flight is
|
||||
refused - that would flip the light back exactly as a retry would. */
|
||||
case LIGHT_1: case LIGHT_2: case LIGHT_3: case LIGHT_4:
|
||||
case LIGHT_5: case LIGHT_6: case LIGHT_7: case LIGHT_8:
|
||||
case LIGHT_9: case LIGHT_10: case LIGHT_11: case LIGHT_12:
|
||||
LightsProxy.toggle(LightsPage.slotOf(ev), () -> _handler.post(() -> onLightsLoaded()));
|
||||
break;
|
||||
|
||||
/* Roku remote commands. handle_event_key runs on the main thread, so these
|
||||
only hand the key to RokuRemote and return: the POST happens on a worker
|
||||
thread and a failure there is nobody's problem but its own. */
|
||||
case ROKU_HOME: case ROKU_BACK:
|
||||
case ROKU_UP: case ROKU_DOWN: case ROKU_LEFT: case ROKU_RIGHT:
|
||||
case ROKU_SELECT: case ROKU_PLAY: case ROKU_REWIND: case ROKU_FORWARD:
|
||||
case ROKU_VOLUP: case ROKU_VOLDOWN: case ROKU_VOLMUTE:
|
||||
case ROKU_POWER:
|
||||
RokuRemote.press(ev);
|
||||
break;
|
||||
|
||||
case SWITCH_EMOJI:
|
||||
@@ -476,6 +640,9 @@ public class Keyboard2 extends InputMethodService
|
||||
VoiceImeSwitcher.choose_voice_ime(Keyboard2.this, get_imm(),
|
||||
Config.globalPrefs());
|
||||
break;
|
||||
case HIDE_SELF:
|
||||
Keyboard2.this.requestHideSelf(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,6 +675,18 @@ public class Keyboard2 extends InputMethodService
|
||||
{
|
||||
_candidates_view.set_candidates(suggestions);
|
||||
}
|
||||
|
||||
public String provide_stateful_key_symbol(KeyValue.Stateful q)
|
||||
{
|
||||
switch (q)
|
||||
{
|
||||
case Complete_first: return _suggestions.suggestions[0];
|
||||
case Complete_second: return _suggestions.suggestions[1];
|
||||
case Complete_third: return _suggestions.suggestions[2];
|
||||
case Complete_emoji: return _suggestions.emoji_suggestion;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private IBinder getConnectionToken()
|
||||
|
||||
@@ -2,13 +2,20 @@ package juloo.keyboard2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.inputmethodservice.InputMethodService;
|
||||
import android.net.Uri;
|
||||
import android.os.Build.VERSION;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.MotionEvent;
|
||||
@@ -19,6 +26,7 @@ import android.view.WindowManager;
|
||||
import android.view.WindowMetrics;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Keyboard2View extends View
|
||||
implements View.OnTouchListener, Pointers.IPointerEventHandler
|
||||
@@ -36,6 +44,13 @@ public class Keyboard2View extends View
|
||||
|
||||
private Pointers.Modifiers _mods;
|
||||
|
||||
/** Long-pressing the usage gauge key opens the usage page; a tap stays inert. */
|
||||
private final Handler _gaugeHandler = new Handler(Looper.getMainLooper());
|
||||
private Runnable _gaugeLongPress;
|
||||
/** Its own paint, so the ribbon cannot disturb whatever the key drawing left configured. */
|
||||
private final Paint _ribbonPaint = new Paint();
|
||||
private boolean _gaugePressed;
|
||||
|
||||
private static int _currentWhat = 0;
|
||||
|
||||
private Config _config;
|
||||
@@ -54,6 +69,13 @@ public class Keyboard2View extends View
|
||||
private Theme.Computed _tc;
|
||||
|
||||
private static RectF _tmpRect = new RectF();
|
||||
private static final Paint GAUGE_PAINT = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
/** The ring around the spend number gets its own paint, so the number's own settings and its
|
||||
halo cannot be disturbed by whatever the ring leaves configured. */
|
||||
private static final Paint GAUGE_RING_PAINT = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private static final Path GAUGE_PATH = new Path();
|
||||
/** Reused for measuring the number. Nothing on the draw path allocates. */
|
||||
private static final Rect _gaugeTextBounds = new Rect();
|
||||
|
||||
enum Vertical
|
||||
{
|
||||
@@ -199,6 +221,7 @@ public class Keyboard2View extends View
|
||||
{
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
cancelGaugePress();
|
||||
_pointers.onTouchUp(event.getPointerId(event.getActionIndex()));
|
||||
break;
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
@@ -207,14 +230,23 @@ public class Keyboard2View extends View
|
||||
float tx = event.getX(p);
|
||||
float ty = event.getY(p);
|
||||
KeyboardData.Key key = getKeyAtPosition(tx, ty);
|
||||
if (key != null)
|
||||
if (key != null && UsageGauge.isGaugeKey(key))
|
||||
startGaugePress();
|
||||
else if (key != null)
|
||||
_pointers.onTouchDown(tx, ty, event.getPointerId(p), key);
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (_gaugePressed)
|
||||
{
|
||||
KeyboardData.Key moved = getKeyAtPosition(event.getX(0), event.getY(0));
|
||||
if (moved == null || !UsageGauge.isGaugeKey(moved))
|
||||
cancelGaugePress(); // slid off the gauge: no longer a press on it
|
||||
}
|
||||
for (p = 0; p < event.getPointerCount(); p++)
|
||||
_pointers.onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p));
|
||||
break;
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
cancelGaugePress();
|
||||
_pointers.onTouchCancel();
|
||||
break;
|
||||
default:
|
||||
@@ -294,7 +326,9 @@ public class Keyboard2View extends View
|
||||
{
|
||||
if (!changed)
|
||||
return;
|
||||
if (VERSION.SDK_INT >= 29)
|
||||
// Since SDK 30, this is done automatically:
|
||||
// https://android.googlesource.com/platform/frameworks/base/+/android11-release/core/java/android/inputmethodservice/InputMethodService.java#852
|
||||
if (VERSION.SDK_INT == 29)
|
||||
{
|
||||
// Disable the back-gesture on the keyboard area
|
||||
_cached_exclusion_rect.set(
|
||||
@@ -349,22 +383,338 @@ public class Keyboard2View extends View
|
||||
x += k.shift * _keyWidth;
|
||||
float keyW = _keyWidth * k.width - _tc.horizontal_margin;
|
||||
boolean isKeyDown = _pointers.isKeyDown(k);
|
||||
Theme.Computed.Key tc_key = isKeyDown ? _tc.key_activated : _tc.key;
|
||||
// A key whose Roku command has been sent wears the pressed look until the TV
|
||||
// answers, so a slow command does not look like a dead key. Same colours as a
|
||||
// real press (key_activated + the activated label), which is the only pair the
|
||||
// theme guarantees to be readable together.
|
||||
boolean isSent = RokuRemote.isLit(k.keys[0], System.currentTimeMillis());
|
||||
Theme.Computed.Key tc_key;
|
||||
if (isKeyDown || isSent)
|
||||
tc_key = _tc.key_activated;
|
||||
else
|
||||
switch (k.role)
|
||||
{
|
||||
case Action: tc_key = _tc.key_action; break;
|
||||
case Space_bar: tc_key = _tc.key_space_bar; break;
|
||||
case Suggestion: tc_key = _tc.key_suggestion; break;
|
||||
default:
|
||||
case Normal: tc_key = _tc.key; break;
|
||||
}
|
||||
drawKeyFrame(canvas, x, y, keyW, keyH, tc_key);
|
||||
if (k.keys[0] != null)
|
||||
if (k.role == KeyboardData.Key.Role.Space_bar)
|
||||
drawHostRibbon(canvas, x, y, keyW, keyH);
|
||||
if (UsageGauge.isGaugeKey(k))
|
||||
drawUsageGauge(canvas, x, y, keyW, keyH, tc_key);
|
||||
else if (k.keys[0] != null)
|
||||
drawLabel(canvas, k.keys[0], keyW / 2f + x, y, keyH, isKeyDown, tc_key);
|
||||
for (int i = 1; i < 9; i++)
|
||||
{
|
||||
if (k.keys[i] != null)
|
||||
drawSubLabel(canvas, k.keys[i], x, y, keyW, keyH, i, isKeyDown, tc_key);
|
||||
}
|
||||
drawIndication(canvas, k, x, y, keyW, keyH, _tc);
|
||||
if (!UsageGauge.isGaugeKey(k))
|
||||
drawIndication(canvas, k, x, y, keyW, keyH, _tc);
|
||||
x += _keyWidth * k.width;
|
||||
}
|
||||
y += row.height * _tc.row_height;
|
||||
}
|
||||
}
|
||||
|
||||
/** Holding the gauge key opens the usage page. Short taps do nothing: the key never types. */
|
||||
private void startGaugePress()
|
||||
{
|
||||
cancelGaugePress();
|
||||
_gaugePressed = true;
|
||||
_gaugeLongPress = new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
if (!_gaugePressed)
|
||||
return;
|
||||
_gaugePressed = false;
|
||||
_gaugeLongPress = null;
|
||||
openUsagePage();
|
||||
}
|
||||
};
|
||||
// Same delay the keyboard uses for every other long press, so it feels like the rest of it.
|
||||
_gaugeHandler.postDelayed(_gaugeLongPress, _config != null ? _config.longPressTimeout : 600L);
|
||||
}
|
||||
|
||||
private void cancelGaugePress()
|
||||
{
|
||||
_gaugePressed = false;
|
||||
if (_gaugeLongPress != null)
|
||||
{
|
||||
_gaugeHandler.removeCallbacks(_gaugeLongPress);
|
||||
_gaugeLongPress = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void openUsagePage()
|
||||
{
|
||||
try
|
||||
{
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(UsageGauge.USAGE_PAGE_URL));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// No browser, or the launcher refused: the keyboard must never crash over a long press.
|
||||
}
|
||||
}
|
||||
|
||||
/** Two smooth lanes along the bottom of the space bar: cpu utilisation as a filled neon wave,
|
||||
the disk stall as a cyan line riding the same curve. Columns became a curve because a row
|
||||
of separate bars read as a bar chart; the ask was a colour field, like a picker.
|
||||
*
|
||||
* Nothing at all is drawn without data: a missing ribbon is the honest "cannot reach Utumno",
|
||||
* while a live-but-idle host still draws its baseline, so blank is never read as zero. */
|
||||
/** Cached so the draw path allocates nothing: it only changes when the key geometry does. */
|
||||
/** Where the ribbon reaches the theme's pink; lower starts the colour change sooner. */
|
||||
private static final float RIBBON_PINK_AT = 0.3f;
|
||||
|
||||
/** Reused every frame so the smooth wave never allocates on the draw path. */
|
||||
private final android.graphics.Path _ribbonPath = new android.graphics.Path();
|
||||
private android.graphics.Shader _ribbonShader;
|
||||
private float _ribbonShaderBottom = -1f;
|
||||
private float _ribbonShaderHeight = -1f;
|
||||
|
||||
/** The ribbon's own ramp in the keyboard's colours: orchid violet at rest, through the
|
||||
theme's pink at half, to the hot pink that peaks the space bar glyph when the box is flat out. */
|
||||
private static int ribbonColor(float level)
|
||||
{
|
||||
level = Math.max(0f, Math.min(1f, level));
|
||||
if (level < RIBBON_PINK_AT)
|
||||
// 0xFFC67DFF is the theme's own alternate violet: same family, but its luma is up with
|
||||
// the cyan stall line, so a low-utilisation wave still reads instead of looking dim.
|
||||
return ribbonLerp(0xFFC67DFF, 0xFFFF2D95, level / RIBBON_PINK_AT);
|
||||
return ribbonLerp(0xFFFF2D95, 0xFFFF2FF0, (level - RIBBON_PINK_AT) / (1f - RIBBON_PINK_AT));
|
||||
}
|
||||
|
||||
private static int ribbonLerp(int from, int to, float t)
|
||||
{
|
||||
int r = (int) ((from >> 16 & 0xFF) + (((to >> 16 & 0xFF) - (from >> 16 & 0xFF)) * t));
|
||||
int g = (int) ((from >> 8 & 0xFF) + (((to >> 8 & 0xFF) - (from >> 8 & 0xFF)) * t));
|
||||
int b = (int) ((from & 0xFF) + (((to & 0xFF) - (from & 0xFF)) * t));
|
||||
return 0xFF000000 | r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
private void drawHostRibbon(Canvas canvas, float x, float y, float keyW, float keyH)
|
||||
{
|
||||
if (!HostGraph.hasData())
|
||||
return;
|
||||
float[] util = HostGraph.series(2);
|
||||
if (util.length == 0)
|
||||
return;
|
||||
float left = x + _tc.horizontal_margin;
|
||||
float right = x + keyW - _tc.horizontal_margin;
|
||||
float width = right - left;
|
||||
if (width <= 4f)
|
||||
return;
|
||||
float bottom = y + keyH - 1f;
|
||||
// One gradient the whole way up, keyed to *height* rather than to each sample's own value, so
|
||||
// a taller wave reveals more of the ramp. Built once per key geometry.
|
||||
if (_ribbonShader == null || _ribbonShaderBottom != bottom || _ribbonShaderHeight != keyH)
|
||||
{
|
||||
_ribbonShader = new android.graphics.LinearGradient(0f, bottom, 0f, bottom - keyH,
|
||||
new int[] { ribbonColor(0f), ribbonColor(RIBBON_PINK_AT), ribbonColor(1f) },
|
||||
new float[] { 0f, RIBBON_PINK_AT, 1f }, android.graphics.Shader.TileMode.CLAMP);
|
||||
_ribbonShaderBottom = bottom;
|
||||
_ribbonShaderHeight = keyH;
|
||||
}
|
||||
_ribbonPaint.setAntiAlias(true);
|
||||
_ribbonPaint.setShader(_ribbonShader);
|
||||
_ribbonPaint.setStyle(android.graphics.Paint.Style.FILL);
|
||||
buildWave(_ribbonPath, util, left, width, bottom, keyH, true);
|
||||
canvas.drawPath(_ribbonPath, _ribbonPaint);
|
||||
// Second lane: how much of each second was spent *waiting* on the disk. Utilisation says
|
||||
// "busy"; this says "stuck", and only this one tells the two apart.
|
||||
float[] stall = HostGraph.series(0);
|
||||
if (stall.length > 0)
|
||||
{
|
||||
_ribbonPaint.setShader(null);
|
||||
_ribbonPaint.setColor(0xFF00E5FF);
|
||||
_ribbonPaint.setStyle(android.graphics.Paint.Style.STROKE);
|
||||
_ribbonPaint.setStrokeWidth(Math.max(2f, keyH * 0.03f));
|
||||
_ribbonPaint.setStrokeCap(android.graphics.Paint.Cap.ROUND);
|
||||
_ribbonPaint.setStrokeJoin(android.graphics.Paint.Join.ROUND);
|
||||
buildWave(_ribbonPath, stall, left, width, bottom, keyH, false);
|
||||
canvas.drawPath(_ribbonPath, _ribbonPaint);
|
||||
_ribbonPaint.setStyle(android.graphics.Paint.Style.FILL);
|
||||
}
|
||||
// The baseline says "connected". Without it a blank space bar would read as zero load.
|
||||
_ribbonPaint.setStrokeWidth(1f);
|
||||
_ribbonPaint.setColor(0x55FFFFFF);
|
||||
canvas.drawRect(left, bottom - 1f, right, bottom, _ribbonPaint);
|
||||
}
|
||||
|
||||
/** A smooth curve through the samples, filled to the bottom when `area`.
|
||||
*
|
||||
* Quadratic segments whose control points are the samples and whose ends are the midpoints:
|
||||
* that is what removes the corner at each sample and turns a row of columns into one wave. */
|
||||
private static void buildWave(android.graphics.Path path, float[] series, float left, float width,
|
||||
float bottom, float full, boolean area)
|
||||
{
|
||||
int n = series.length;
|
||||
if (n == 0)
|
||||
return;
|
||||
path.reset();
|
||||
float dx = n > 1 ? width / (n - 1) : width;
|
||||
float px = left;
|
||||
float py = bottom - ribbonLevel(series[0]) * full;
|
||||
path.moveTo(px, py);
|
||||
if (area)
|
||||
path.lineTo(px, bottom);
|
||||
for (int i = 1; i < n; i++)
|
||||
{
|
||||
float cx = left + i * dx;
|
||||
float cy = bottom - ribbonLevel(series[i]) * full;
|
||||
if (i < n - 1)
|
||||
path.quadTo(px, py, (px + cx) / 2f, (py + cy) / 2f);
|
||||
else
|
||||
path.quadTo(px, py, cx, cy);
|
||||
px = cx;
|
||||
py = cy;
|
||||
}
|
||||
if (area)
|
||||
{
|
||||
path.lineTo(left + width, bottom);
|
||||
path.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static float ribbonLevel(float v)
|
||||
{
|
||||
return Math.max(0f, Math.min(100f, v)) / 100f;
|
||||
}
|
||||
|
||||
private void drawUsageGauge(Canvas canvas, float x, float y, float keyW,
|
||||
float keyH, Theme.Computed.Key tc)
|
||||
{
|
||||
UsageGauge.Reading reading = UsageGauge.cachedReading();
|
||||
boolean stale = !_config.usageGaugeEnabled
|
||||
|| UsageGauge.isStaleNow(_config.usageGaugeToken);
|
||||
float inset = Math.max(1.f, tc.border_width);
|
||||
RectF bounds = new RectF(x + inset, y + inset, x + keyW - inset, y + keyH - inset);
|
||||
GAUGE_PATH.reset();
|
||||
GAUGE_PATH.addRoundRect(bounds, tc.border_radius, tc.border_radius, Path.Direction.CW);
|
||||
canvas.save();
|
||||
canvas.clipPath(GAUGE_PATH);
|
||||
if (stale || reading == null)
|
||||
{
|
||||
GAUGE_PAINT.setShader(null);
|
||||
GAUGE_PAINT.setColor(0xff55585e);
|
||||
canvas.drawRect(bounds, GAUGE_PAINT);
|
||||
}
|
||||
else
|
||||
{
|
||||
float level = UsageGauge.fillFraction(reading);
|
||||
int hue = UsageGauge.hueColor(level);
|
||||
GAUGE_PAINT.setColor(tc.bg_paint.getColor());
|
||||
canvas.drawRect(bounds, GAUGE_PAINT);
|
||||
if (level > 0)
|
||||
{
|
||||
float fillTop = bounds.bottom - bounds.height() * level;
|
||||
int darker = blendColor(hue, 0xff000000, 0.22f);
|
||||
GAUGE_PAINT.setShader(new LinearGradient(0, bounds.bottom, 0, fillTop,
|
||||
darker, hue, Shader.TileMode.CLAMP));
|
||||
canvas.drawRect(bounds.left, fillTop, bounds.right, bounds.bottom, GAUGE_PAINT);
|
||||
GAUGE_PAINT.setShader(null);
|
||||
}
|
||||
}
|
||||
String label = reading == null ? "—" : String.format(Locale.US, "%.1f", reading.spentTodayUsd);
|
||||
float size = Math.min(_subLabelSize, keyW * 0.40f);
|
||||
GAUGE_PAINT.setTextSize(size);
|
||||
GAUGE_PAINT.setTypeface(android.graphics.Typeface.DEFAULT);
|
||||
GAUGE_PAINT.setTextAlign(Paint.Align.CENTER);
|
||||
// Stale hides the number behind a dash; a partial day keeps the number but dims it, so a
|
||||
// floor can never be read as the day's total. A low balance stays red: that reading is live.
|
||||
int labelColor = stale ? 0xff92949a :
|
||||
(UsageGauge.isLowBalance(reading) ? 0xffe53935 :
|
||||
(reading.partial ? 0xff92949a : _theme.labelColor));
|
||||
if (!stale)
|
||||
{
|
||||
// The ring is the only part of this key that can carry the low-balance warning as a
|
||||
// colour: the number itself is a stroked outline whose colour comes from luminance
|
||||
// so it stays legible over the ramped fill, which means a red label has nowhere
|
||||
// else to show and only flips that outline white.
|
||||
drawGaugeRing(canvas, label, bounds, size, y, keyH,
|
||||
UsageGauge.isLowBalance(reading) ? 0xffe53935 : _theme.subLabelColor);
|
||||
// The outline is derived from the theme's own label colour and deliberately NOT from
|
||||
// labelColor: otherwise a low balance would flip this outline white, which changes how
|
||||
// the number looks. The ring carries the red; the number keeps its normal appearance.
|
||||
int outlineBase = stale || reading.partial ? 0xff92949a : _theme.labelColor;
|
||||
int luminance = (android.graphics.Color.red(outlineBase) * 299
|
||||
+ android.graphics.Color.green(outlineBase) * 587
|
||||
+ android.graphics.Color.blue(outlineBase) * 114) / 1000;
|
||||
GAUGE_PAINT.setStyle(Paint.Style.STROKE);
|
||||
GAUGE_PAINT.setStrokeWidth(Math.max(1.f, size * 0.12f));
|
||||
GAUGE_PAINT.setColor(luminance > 140 ? 0xff202020 : 0xfff5f5f5);
|
||||
canvas.drawText(label, bounds.centerX(),
|
||||
(keyH - GAUGE_PAINT.ascent() - GAUGE_PAINT.descent()) / 2f + y, GAUGE_PAINT);
|
||||
GAUGE_PAINT.setStyle(Paint.Style.FILL);
|
||||
}
|
||||
GAUGE_PAINT.setColor(labelColor);
|
||||
canvas.drawText(label, bounds.centerX(),
|
||||
(keyH - GAUGE_PAINT.ascent() - GAUGE_PAINT.descent()) / 2f + y, GAUGE_PAINT);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
/** A ring around the spend number, in the theme's alternate violet.
|
||||
*
|
||||
* [GAUGE_PAINT] must already carry the label's size and typeface, and [bounds], [y], [keyH] the
|
||||
* key's own geometry: the radius, the centre and the baseline are all measured from those rather
|
||||
* than assumed, so the ring wraps the glyphs the device's font actually draws.
|
||||
*
|
||||
* The radius is the ink box's half-diagonal plus the gap, so the gap is exact at the ink's
|
||||
* corners - the furthest ink from the centre - and larger everywhere else. Centring on the ink
|
||||
* box's own middle rather than on the line box matters for digits, which have no descender: the
|
||||
* line box would pull the ring down by half a descent and eat the gap above the number.
|
||||
*
|
||||
* The dark casing under the coloured stroke is the trick the number's own halo already uses, and
|
||||
* for the same reason: the fill behind it runs from cyan or violet through amber to red, and a
|
||||
* lone violet stroke would disappear into part of that ramp. */
|
||||
private void drawGaugeRing(Canvas canvas, String label, RectF bounds, float size,
|
||||
float y, float keyH, int ringColor)
|
||||
{
|
||||
GAUGE_PAINT.getTextBounds(label, 0, label.length(), _gaugeTextBounds);
|
||||
float halfW = _gaugeTextBounds.width() / 2f;
|
||||
float halfH = _gaugeTextBounds.height() / 2f;
|
||||
// Align.CENTER centres the advance, not the ink: recentre on the ink box's own middle.
|
||||
float cx = bounds.centerX() - GAUGE_PAINT.measureText(label) / 2f
|
||||
+ (_gaugeTextBounds.left + _gaugeTextBounds.right) / 2f;
|
||||
// The number's own baseline, plus the ink box's own middle: see the comment above.
|
||||
float cy = (keyH - GAUGE_PAINT.ascent() - GAUGE_PAINT.descent()) / 2f + y
|
||||
+ (_gaugeTextBounds.top + _gaugeTextBounds.bottom) / 2f;
|
||||
float gap = Math.max(1.5f, size * 0.08f);
|
||||
float stroke = Math.max(1.5f, size * 0.07f);
|
||||
float casing = Math.max(1f, size * 0.02f);
|
||||
float radius = (float)Math.sqrt(halfW * halfW + halfH * halfH) + gap + casing + stroke / 2f;
|
||||
// A ring squeezed inwards would cut across the digits it frames, which is worse than no ring,
|
||||
// so refuse it rather than clamp it; either way keep a margin off the key's own edge. A circle
|
||||
// wide enough to enclose a five-character total needs more width than the key has.
|
||||
float room = Math.min(Math.min(cx - bounds.left, bounds.right - cx),
|
||||
Math.min(cy - bounds.top, bounds.bottom - cy)) - Math.max(1f, size * 0.03f);
|
||||
if (radius + stroke / 2f + casing > room)
|
||||
return;
|
||||
GAUGE_RING_PAINT.setStyle(Paint.Style.STROKE);
|
||||
GAUGE_RING_PAINT.setStrokeWidth(stroke + 2f * casing);
|
||||
GAUGE_RING_PAINT.setColor(0xff202020);
|
||||
canvas.drawCircle(cx, cy, radius, GAUGE_RING_PAINT);
|
||||
GAUGE_RING_PAINT.setStrokeWidth(stroke);
|
||||
GAUGE_RING_PAINT.setColor(ringColor);
|
||||
canvas.drawCircle(cx, cy, radius, GAUGE_RING_PAINT);
|
||||
}
|
||||
|
||||
private static int blendColor(int from, int to, float amount)
|
||||
{
|
||||
return android.graphics.Color.rgb(
|
||||
(int)(android.graphics.Color.red(from) * (1 - amount) + android.graphics.Color.red(to) * amount),
|
||||
(int)(android.graphics.Color.green(from) * (1 - amount) + android.graphics.Color.green(to) * amount),
|
||||
(int)(android.graphics.Color.blue(from) * (1 - amount) + android.graphics.Color.blue(to) * amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow()
|
||||
{
|
||||
@@ -402,6 +752,22 @@ public class Keyboard2View extends View
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
/** True for the four direction keys of the Roku page (res/xml/roku.xml), matched by
|
||||
EVENT and never by glyph: 0xE005-0xE008 are ordinary arrow glyphs that the default
|
||||
layouts and other pages also use, and those must keep their own colours.
|
||||
[KeyValue.getEvent()] is only valid for its own kind, so the kind is checked first,
|
||||
the same guard [RokuRemote.isLit] uses. */
|
||||
private static boolean isRokuDirection(KeyValue k)
|
||||
{
|
||||
if (k.getKind() != KeyValue.Kind.Event)
|
||||
return false;
|
||||
switch (k.getEvent())
|
||||
{
|
||||
case ROKU_UP: case ROKU_DOWN: case ROKU_LEFT: case ROKU_RIGHT: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
private int labelColor(KeyValue k, boolean isKeyDown, boolean sublabel)
|
||||
{
|
||||
if (isKeyDown)
|
||||
@@ -415,6 +781,21 @@ public class Keyboard2View extends View
|
||||
}
|
||||
return _theme.pressedColor;
|
||||
}
|
||||
/* The Roku page's four direction keys are event keys, and every event key carries
|
||||
FLAG_SECONDARY, which dims them to secondaryLabelColor - a muted pink on the
|
||||
Orchid theme, which reads as "disabled" on the one page where they are the main
|
||||
controls. They get the theme's blue accent instead. Only these four events are
|
||||
affected: no other key on any page or layout changes colour. A press is answered
|
||||
above, and [drawLabel]'s RokuRemote.isLit() still overrides this, so neither the
|
||||
pressed look nor the sent acknowledgement changes. */
|
||||
if (isRokuDirection(k))
|
||||
return _theme.rokuArrowColor;
|
||||
/* The lights page's keys are event keys too, and every event key carries FLAG_SECONDARY, which
|
||||
would dim them all to the same secondary grey - useless on the one page whose whole point is
|
||||
telling one light's state from another's. They get the state's colour instead, from the one
|
||||
mapping in [LightsProxy.colorFor]. */
|
||||
if (LightsPage.isLightKey(k))
|
||||
return LightsPage.colorFor(k, _theme);
|
||||
if (k.hasFlagsAny(KeyValue.FLAG_SECONDARY | KeyValue.FLAG_GREYED))
|
||||
{
|
||||
if (k.hasFlagsAny(KeyValue.FLAG_GREYED))
|
||||
@@ -431,8 +812,36 @@ public class Keyboard2View extends View
|
||||
if (kv == null)
|
||||
return;
|
||||
float textSize = scaleTextSize(kv, true);
|
||||
Paint p = tc.label_paint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT), labelColor(kv, isKeyDown, false), textSize);
|
||||
canvas.drawText(kv.getString(), x, (keyH - p.ascent() - p.descent()) / 2f + y, p);
|
||||
// DeepSeek peak/off-peak: the space bar's joystick glyph doubles as the rate
|
||||
// indicator (neon blue = off-peak, neon pink = peak).
|
||||
int color = kv.getKind() == KeyValue.Kind.Editing
|
||||
&& KeyValue.Editing.SPACE_BAR.equals(kv.getEditing())
|
||||
? DeepSeekPeak.colorFor(System.currentTimeMillis())
|
||||
: labelColor(kv, isKeyDown, false);
|
||||
// The emoji badge (0xE01D, Alt's top-right corner) sits in a corner slot,
|
||||
// which labelColor() would dim to secondaryLabelColor. Draw it in labelColor
|
||||
// so it matches the rest of the keyboard's labels.
|
||||
String glyph = kv.getString();
|
||||
if (glyph != null && glyph.length() == 1 && glyph.charAt(0) == 0xE01D)
|
||||
color = _theme.labelColor;
|
||||
/* A lights key shows the light's name until a press has something to say. The answer to that
|
||||
press - a refusal, or that Home Assistant could not be read back - is then the honest thing
|
||||
to put on the key, in the stale colour, until the box reports a state for that light again. */
|
||||
String note = LightsPage.noteFor(kv, System.currentTimeMillis());
|
||||
if (note != null)
|
||||
{
|
||||
glyph = note;
|
||||
color = _theme.lightStaleColor;
|
||||
}
|
||||
// A Roku key wears the theme's activated colours for a moment after it is pressed:
|
||||
// the command goes out on a worker thread and a press against a sleeping TV takes
|
||||
// ~5 s to be answered, so without this a slow press looks like a dead key and gets
|
||||
// pressed twice. The state is one enum reference and one long in RokuRemote, written
|
||||
// by the worker thread and only read from the draw path.
|
||||
if (RokuRemote.isLit(kv, System.currentTimeMillis()))
|
||||
color = _theme.activatedColor;
|
||||
Paint p = tc.label_paint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT), color, textSize);
|
||||
canvas.drawText(glyph, x, (keyH - p.ascent() - p.descent()) / 2f + y, p);
|
||||
}
|
||||
|
||||
private void drawSubLabel(Canvas canvas, KeyValue kv, float x, float y,
|
||||
@@ -445,7 +854,23 @@ public class Keyboard2View extends View
|
||||
if (kv == null)
|
||||
return;
|
||||
float textSize = scaleTextSize(kv, false);
|
||||
Paint p = tc.sublabel_paint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT), labelColor(kv, isKeyDown, true), textSize, a);
|
||||
int color = labelColor(kv, isKeyDown, true);
|
||||
// Corner badges drawn with an icon glyph. labelColor() dims every key carrying
|
||||
// FLAG_SECONDARY to secondaryLabelColor, and every eventKey carries it, so the
|
||||
// emoji badge (0xE01D, Alt's top-right corner), the Roku badge (0xE024) and the
|
||||
// lights badge (0xE025, Alt's bottom-right corner) would all come out dim next to
|
||||
// the theme's own labels. drawLabel() has the same test for 0xE01D, but drawLabel()
|
||||
// is only ever called with k.keys[0]: a corner badge lives in k.keys[2] and is drawn
|
||||
// here, so that copy never runs.
|
||||
if (kv.getKind() == KeyValue.Kind.Event)
|
||||
{
|
||||
String badge = kv.getString();
|
||||
if (badge != null && badge.length() == 1
|
||||
&& (badge.charAt(0) == 0xE01D || badge.charAt(0) == 0xE024
|
||||
|| badge.charAt(0) == 0xE025))
|
||||
color = _theme.labelColor;
|
||||
}
|
||||
Paint p = tc.sublabel_paint(kv.hasFlagsAny(KeyValue.FLAG_KEY_FONT), color, textSize, a);
|
||||
float subPadding = _config.keyPadding;
|
||||
if (v == Vertical.CENTER)
|
||||
y += (keyH - p.ascent() - p.descent()) / 2f;
|
||||
@@ -455,7 +880,13 @@ public class Keyboard2View extends View
|
||||
x += keyW / 2f;
|
||||
else
|
||||
x += (a == Paint.Align.LEFT) ? subPadding : keyW - subPadding;
|
||||
String label = kv.getString();
|
||||
/* A lights key's state glyph is chosen as it is drawn, not when the page was built: a press
|
||||
or a poll changes the state under the key without the page being rebuilt, so what is stored
|
||||
in the key value is only a marker. [LightsPage.glyphFor] returns shared Strings, so this
|
||||
allocates nothing. */
|
||||
String label = LightsPage.isStateGlyph(kv)
|
||||
? LightsPage.glyphFor(LightsProxy.stateAt(LightsPage.slotOf(kv.getEvent())))
|
||||
: kv.getString();
|
||||
int label_len = label.length();
|
||||
// Limit the label of string keys to 3 characters
|
||||
if (label_len > 3 && kv.getKind() == KeyValue.Kind.String)
|
||||
|
||||
@@ -43,7 +43,7 @@ public final class KeyboardData
|
||||
ArrayList<Row> rows_ = new ArrayList<Row>();
|
||||
for (Row r : rows)
|
||||
rows_.add(r.mapKeys(f));
|
||||
return new KeyboardData(this, rows_);
|
||||
return with_rows(rows_);
|
||||
}
|
||||
|
||||
/** Add keys from the given iterator into the keyboard. Preferred position is
|
||||
@@ -61,7 +61,7 @@ public final class KeyboardData
|
||||
}
|
||||
for (KeyValue kv : unplaced_keys)
|
||||
add_key_to_preferred_pos(rows, kv, PreferredPos.ANYWHERE);
|
||||
return new KeyboardData(this, rows);
|
||||
return with_rows(rows);
|
||||
}
|
||||
|
||||
/** Place a key on the keyboard according to its preferred position. Mutates
|
||||
@@ -141,9 +141,9 @@ public final class KeyboardData
|
||||
keys.add(nps.get(i));
|
||||
}
|
||||
}
|
||||
extendedRows.add(new Row(keys, row.height, row.shift));
|
||||
extendedRows.add(row.with_keys(keys));
|
||||
}
|
||||
return new KeyboardData(this, extendedRows);
|
||||
return with_rows(extendedRows);
|
||||
}
|
||||
|
||||
/** Insert the given row at the given indice. The row is scaled so that the
|
||||
@@ -152,7 +152,7 @@ public final class KeyboardData
|
||||
{
|
||||
ArrayList<Row> rows_ = new ArrayList<Row>(this.rows);
|
||||
rows_.add(i, row.updateWidth(keysWidth));
|
||||
return new KeyboardData(this, rows_);
|
||||
return with_rows(rows_);
|
||||
}
|
||||
|
||||
public Key findKeyWithValue(KeyValue kv)
|
||||
@@ -304,10 +304,11 @@ public final class KeyboardData
|
||||
}
|
||||
|
||||
/** Copies the fields of a keyboard, with rows changed. */
|
||||
protected KeyboardData(KeyboardData src, List<Row> rows)
|
||||
public KeyboardData with_rows(List<Row> rows_)
|
||||
{
|
||||
this(rows, compute_max_width(rows), src.modmap, src.script,
|
||||
src.numpad_script, src.name, src.bottom_row, src.embedded_number_row, src.locale_extra_keys);
|
||||
return new KeyboardData(rows_, compute_max_width(rows_), modmap, script,
|
||||
numpad_script, name, bottom_row, embedded_number_row,
|
||||
locale_extra_keys);
|
||||
}
|
||||
|
||||
public static class Row
|
||||
@@ -347,7 +348,14 @@ public final class KeyboardData
|
||||
|
||||
public Row copy()
|
||||
{
|
||||
return new Row(new ArrayList<Key>(keys), height, shift);
|
||||
return with_keys(new ArrayList<Key>(keys));
|
||||
}
|
||||
|
||||
/** Copy the row with the keys changed. The list [keys] is not copied and
|
||||
should be immutable. */
|
||||
public Row with_keys(List<Key> keys)
|
||||
{
|
||||
return new Row(keys, height, shift);
|
||||
}
|
||||
|
||||
public void getKeys(Map<KeyValue, KeyPos> dst, int row)
|
||||
@@ -368,7 +376,7 @@ public final class KeyboardData
|
||||
ArrayList<Key> keys_ = new ArrayList<Key>();
|
||||
for (Key k : keys)
|
||||
keys_.add(f.apply(k));
|
||||
return new Row(keys_, height, shift);
|
||||
return with_keys(keys_);
|
||||
}
|
||||
|
||||
/** Change the width of every keys so that the row is 's' units wide. */
|
||||
@@ -406,12 +414,14 @@ public final class KeyboardData
|
||||
public final float shift;
|
||||
/** String printed on the keys. It has no other effect. */
|
||||
public final String indication;
|
||||
/** Keys are rendered differently according to their role. */
|
||||
public final Role role;
|
||||
|
||||
/** Whether a key was declared with the 'loc' prefix. */
|
||||
public static final int F_LOC = 1;
|
||||
public static final int ALL_FLAGS = F_LOC;
|
||||
|
||||
protected Key(KeyValue[] ks, KeyValue antic, int f, float w, float s, String i)
|
||||
protected Key(KeyValue[] ks, KeyValue antic, int f, float w, float s, String i, Role role_)
|
||||
{
|
||||
keys = ks;
|
||||
anticircle = antic;
|
||||
@@ -419,9 +429,11 @@ public final class KeyboardData
|
||||
width = Math.max(w, 0f);
|
||||
shift = Math.max(s, 0f);
|
||||
indication = i;
|
||||
role = role_;
|
||||
}
|
||||
|
||||
static final Key EMPTY = new Key(new KeyValue[9], null, 0, 1.f, 1.f, null);
|
||||
static final Key EMPTY =
|
||||
new Key(new KeyValue[9], null, 0, 1.f, 1.f, null, Role.Normal);
|
||||
|
||||
/** Read a key value attribute that have a synonym. Having both synonyms
|
||||
present at the same time is an error.
|
||||
@@ -489,9 +501,11 @@ public final class KeyboardData
|
||||
float width = attribute_float(parser, "width", 1f);
|
||||
float shift = attribute_float(parser, "shift", 0.f);
|
||||
String indication = parser.getAttributeValue(null, "indication");
|
||||
String role_str = parser.getAttributeValue(null, "role");
|
||||
Role role = (role_str == null) ? Role.Normal : Role.parse(role_str);
|
||||
while (parser.next() != XmlPullParser.END_TAG)
|
||||
continue;
|
||||
return new Key(ks, anticircle, keysflags, width, shift, indication);
|
||||
return new Key(ks, anticircle, keysflags, width, shift, indication, role);
|
||||
}
|
||||
|
||||
/** Whether key at [index] as [flag]. */
|
||||
@@ -503,7 +517,7 @@ public final class KeyboardData
|
||||
/** New key with the width multiplied by 's'. */
|
||||
public Key scaleWidth(float s)
|
||||
{
|
||||
return new Key(keys, anticircle, keysflags, width * s, shift, indication);
|
||||
return new Key(keys, anticircle, keysflags, width * s, shift, indication, role);
|
||||
}
|
||||
|
||||
public void getKeys(Map<KeyValue, KeyPos> dst, int row, int col)
|
||||
@@ -524,12 +538,22 @@ public final class KeyboardData
|
||||
for (int j = 0; j < keys.length; j++) ks[j] = keys[j];
|
||||
ks[i] = kv;
|
||||
int flags = (keysflags & ~(ALL_FLAGS << i));
|
||||
return new Key(ks, anticircle, flags, width, shift, indication);
|
||||
return new Key(ks, anticircle, flags, width, shift, indication, role);
|
||||
}
|
||||
|
||||
public Key withWidth(float w)
|
||||
{
|
||||
return withWidthAndShift(w, shift);
|
||||
}
|
||||
|
||||
public Key withShift(float s)
|
||||
{
|
||||
return new Key(keys, anticircle, keysflags, width, s, indication);
|
||||
return withWidthAndShift(width, s);
|
||||
}
|
||||
|
||||
public Key withWidthAndShift(float w, float s)
|
||||
{
|
||||
return new Key(keys, anticircle, keysflags, w, s, indication, role);
|
||||
}
|
||||
|
||||
public boolean hasValue(KeyValue kv)
|
||||
@@ -539,6 +563,25 @@ public final class KeyboardData
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static enum Role
|
||||
{
|
||||
Normal,
|
||||
Action, // Generally Shift, Delete and keys on the bottom row
|
||||
Space_bar,
|
||||
Suggestion;
|
||||
|
||||
public static Role parse(String str)
|
||||
{
|
||||
switch (str)
|
||||
{
|
||||
case "action": return Action;
|
||||
case "space_bar": return Space_bar;
|
||||
case "suggestion": return Suggestion;
|
||||
default: case "normal": return Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not using Function<KeyValue, KeyValue> to keep compatibility with Android 6.
|
||||
@@ -555,7 +598,7 @@ public final class KeyboardData
|
||||
for (int i = 0; i < ks.length; i++)
|
||||
if (k.keys[i] != null)
|
||||
ks[i] = apply(k.keys[i], k.keyHasFlag(i, Key.F_LOC));
|
||||
return new Key(ks, k.anticircle, k.keysflags, k.width, k.shift, k.indication);
|
||||
return new Key(ks, k.anticircle, k.keysflags, k.width, k.shift, k.indication, k.role);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package juloo.keyboard2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class LayoutLandscapeModifier
|
||||
{
|
||||
/** Width added to the layout, in the key width unit of the layout. */
|
||||
public static final int ADDED_WIDTH = 5;
|
||||
|
||||
public static KeyboardData transform_to_landscape(KeyboardData kw)
|
||||
{
|
||||
ArrayList<KeyboardData.Row> new_rows = new ArrayList<KeyboardData.Row>();
|
||||
// Bottom row as index 0. Used by [add_middle_column] below.
|
||||
int row_index = kw.rows.size() - 1;
|
||||
for (KeyboardData.Row r : kw.rows)
|
||||
new_rows.add(split_row(r, row_index--));
|
||||
return kw.with_rows(new_rows);
|
||||
}
|
||||
|
||||
public static KeyboardData.Row transform_number_row(KeyboardData.Row r)
|
||||
{
|
||||
return split_row(r, -1);
|
||||
}
|
||||
|
||||
static KeyboardData.Row split_row(KeyboardData.Row r, int row_index)
|
||||
{
|
||||
if (r.keys.size() < 2)
|
||||
return r;
|
||||
// Split the row at the key that overlaps that mid region. If the mid
|
||||
// region is entirely covered by one key, it is duplicated.
|
||||
float mid_start = r.keysWidth / 2 - 0.25f;
|
||||
float mid_end = mid_start + 0.5f;
|
||||
float off = 0f;
|
||||
int i = 0;
|
||||
int end = r.keys.size() - 1; // Exclude the last key to force a split
|
||||
for (; true; i++)
|
||||
{
|
||||
KeyboardData.Key k = r.keys.get(i);
|
||||
off += k.shift + k.width;
|
||||
if (off > mid_start || i == end)
|
||||
{
|
||||
if (off > mid_end)
|
||||
return duplicate_at_index(r, i, off, row_index);
|
||||
return split_at_index(r, i + 1, row_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Insert [ADDED_WIDTH] empty space before the key at index [i]. */
|
||||
static KeyboardData.Row split_at_index(KeyboardData.Row r, int i,
|
||||
int row_index)
|
||||
{
|
||||
List<KeyboardData.Key> new_keys = new ArrayList<KeyboardData.Key>(r.keys);
|
||||
KeyboardData.Key k = new_keys.get(i);
|
||||
new_keys.set(i, k.withShift(k.shift + ADDED_WIDTH));
|
||||
add_middle_key(new_keys, i, row_index);
|
||||
return r.with_keys(new_keys);
|
||||
}
|
||||
|
||||
/** Duplicate the key at index [i] and insert [ADDED_WIDTH] empty space in
|
||||
between. */
|
||||
static KeyboardData.Row duplicate_at_index(KeyboardData.Row r, int i,
|
||||
float off, int row_index)
|
||||
{
|
||||
List<KeyboardData.Key> new_keys = new ArrayList<KeyboardData.Key>(r.keys);
|
||||
KeyboardData.Key k = new_keys.get(i);
|
||||
// Reduce the size of the duplicated keys if they would add more than 1 to
|
||||
// the width.
|
||||
float k_width = (k.width + 1.f) / 2;
|
||||
// Adjust the size on each sides when the key is not totally centered.
|
||||
float mid_d = Math.min(off - (r.keysWidth + k.width) / 2, k_width - 1);
|
||||
new_keys.add(i + 1, k.withWidthAndShift(k_width + mid_d, ADDED_WIDTH - 1));
|
||||
new_keys.set(i, k.withWidth(k_width - mid_d));
|
||||
add_middle_key(new_keys, i + 1, row_index);
|
||||
return r.with_keys(new_keys);
|
||||
}
|
||||
|
||||
/** Add the middle column defined in [split_middle_column.xml]. */
|
||||
static void add_middle_key(List<KeyboardData.Key> new_keys, int i,
|
||||
int row_index)
|
||||
{
|
||||
List<KeyboardData.Key> mid_keys = LayoutModifier.split_middle_column.keys;
|
||||
if (row_index >= mid_keys.size())
|
||||
return;
|
||||
KeyboardData.Key mid_key = mid_keys.get(row_index);
|
||||
KeyboardData.Key right_key = new_keys.get(i);
|
||||
float shift = (right_key.shift - mid_key.width) / 2.f;
|
||||
new_keys.set(i, right_key.withShift(shift));
|
||||
new_keys.add(i, mid_key.withShift(shift));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public final class LayoutModifier
|
||||
static KeyboardData.Row number_row_no_symbols;
|
||||
static KeyboardData.Row number_row_symbols;
|
||||
static KeyboardData num_pad;
|
||||
// Not used in this file but defined here for convenience.
|
||||
public static KeyboardData.Row split_middle_column;
|
||||
|
||||
/** Update the layout according to the configuration.
|
||||
* - Remove the switching key if it isn't needed
|
||||
@@ -46,11 +48,16 @@ public final class LayoutModifier
|
||||
else if (globalConfig.add_number_row && !kw.embedded_number_row) // The numpad removes the number row
|
||||
{
|
||||
added_number_row = modify_number_row(globalConfig.number_row_symbols ? number_row_symbols : number_row_no_symbols, kw);
|
||||
if (globalConfig.split_layout)
|
||||
added_number_row = LayoutLandscapeModifier.transform_number_row(added_number_row);
|
||||
remove_keys.addAll(added_number_row.getKeys(0).keySet());
|
||||
}
|
||||
// Add the bottom row before computing the extra keys
|
||||
if (kw.bottom_row)
|
||||
kw = kw.insert_row(bottom_row, kw.rows.size());
|
||||
// Split the layout in landscape orientation
|
||||
if (globalConfig.split_layout)
|
||||
kw = LayoutLandscapeModifier.transform_to_landscape(kw);
|
||||
// Compose keys to add to the layout
|
||||
// 'extra_keys_keyset' reflects changes made to 'extra_keys'
|
||||
Set<KeyValue> extra_keys_keyset = extra_keys.keySet();
|
||||
@@ -204,6 +211,7 @@ public final class LayoutModifier
|
||||
number_row_symbols = KeyboardData.load_row(res, R.xml.number_row);
|
||||
bottom_row = KeyboardData.load_row(res, R.xml.bottom_row);
|
||||
num_pad = KeyboardData.load_num_pad(res);
|
||||
split_middle_column = KeyboardData.load_row(res, R.xml.split_middle_column);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
package juloo.keyboard2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** The lights page (res/xml/lights.xml): one key per light, plus the way back.
|
||||
*
|
||||
* The page is opened by the switch_lights key (the lamp glyph at 0xE025, in the free bottom-right
|
||||
* corner of the Alt key) and left by lights_close, which fires the same Event.SWITCH_TEXT as
|
||||
* roku_close. Like the Roku page it is loaded as a plain layout (Keyboard2.loadLightsLayout), NOT
|
||||
* through LayoutModifier.modify_layout, so the forced config key and the user's extra keys never
|
||||
* land on it: this page is its own keys and nothing else.
|
||||
*
|
||||
* The skeleton - a row of three slots and the full-width 'Keyboard' key - lives in the XML. This
|
||||
* class turns that skeleton into the live page: one key per light the proxy reported, three to a
|
||||
* row, with a short last row stretched to the full width. Each key carries two values:
|
||||
*
|
||||
* key0 the light's name, exactly as the registry gave it (shortened only when it would run
|
||||
* over the key), coloured by the light's state;
|
||||
* key7 the state glyph, in the special font: the lit lamp (0xE025) for a light that is on, the
|
||||
* unlit one (0xE026) for everything else. The glyph is chosen when the key is *drawn*, not
|
||||
* when the page is built, because a press and a poll change the state under the key
|
||||
* without the page being rebuilt.
|
||||
*
|
||||
* Before the proxy has answered, the template's three slots stand with a dash and the unlit lamp in
|
||||
* the stale look: nobody has said which lights exist, and an unlit lamp never claims otherwise.
|
||||
*
|
||||
* [build], [displayName], [glyphFor] and [colorFor] are pure, so the unit tests drive the real page
|
||||
* logic.
|
||||
*/
|
||||
public final class LightsPage
|
||||
{
|
||||
/** The most lights the page can show: the page's events are LIGHT_1..LIGHT_12. A whitelist
|
||||
longer than this is reported on the last key rather than silently dropped. */
|
||||
public static final int MAX_LIGHTS = 12;
|
||||
/** The template's slot row holds three keys; the page repeats it. */
|
||||
public static final int SLOTS_PER_ROW = 3;
|
||||
/** The template's corner slot for the state glyph. */
|
||||
public static final int GLYPH_SUB_INDEX = 7;
|
||||
/** A key is a third of the keyboard wide; a longer name would run over its neighbours. The name
|
||||
itself is whatever the registry says, never a mapping kept here. */
|
||||
public static final int MAX_NAME_CHARS = 16;
|
||||
/** Drawn on a slot before the proxy has named a light for it. */
|
||||
public static final String PLACEHOLDER = "—";
|
||||
private static final String ELLIPSIS = "…";
|
||||
/** The two glyphs, as the Strings the draw path hands to [android.graphics.Canvas]: kept here so
|
||||
drawing a key allocates nothing. */
|
||||
private static final String LIT_GLYPH = String.valueOf((char)0xE025);
|
||||
private static final String UNLIT_GLYPH = String.valueOf((char)0xE026);
|
||||
|
||||
private LightsPage() {}
|
||||
|
||||
// ------------------------------------------------------------------ the page
|
||||
|
||||
/** The live page: the template's row of slots repeated once per row of lights, then the
|
||||
template's 'Keyboard' row, untouched. [lights] may be null or empty, in which case the slots
|
||||
stand as placeholders. Never mutates the template (KeyboardData.load caches it). */
|
||||
public static KeyboardData build(KeyboardData template, LightsProxy.Light[] lights)
|
||||
{
|
||||
if (template == null || template.rows.size() < 2)
|
||||
return template;
|
||||
LightsProxy.Light[] list = lights == null ? new LightsProxy.Light[0] : lights;
|
||||
int shown = Math.min(list.length, MAX_LIGHTS);
|
||||
List<KeyboardData.Row> rows = new ArrayList<KeyboardData.Row>();
|
||||
if (shown == 0)
|
||||
rows.add(slotRow(template, list, 0, 0));
|
||||
else
|
||||
for (int first = 0; first < shown; first += SLOTS_PER_ROW)
|
||||
rows.add(slotRow(template, list, first, shown));
|
||||
rows.add(template.rows.get(template.rows.size() - 1)); // the 'Keyboard' key
|
||||
return template.with_rows(rows);
|
||||
}
|
||||
|
||||
/** One row of up to three light keys, built from the template's slot keys so the geometry lives
|
||||
in the XML. A short row is stretched to the template row's width. */
|
||||
private static KeyboardData.Row slotRow(KeyboardData template,
|
||||
LightsProxy.Light[] lights, int first, int shown)
|
||||
{
|
||||
KeyboardData.Row tpl = template.rows.get(0);
|
||||
ArrayList<KeyboardData.Key> keys = new ArrayList<KeyboardData.Key>();
|
||||
for (int i = 0; i < tpl.keys.size(); i++)
|
||||
{
|
||||
int slot = first + i + 1; // 1-based: LIGHT_<slot>
|
||||
if (shown != 0 && slot > shown)
|
||||
break;
|
||||
String label = PLACEHOLDER;
|
||||
if (shown != 0)
|
||||
{
|
||||
LightsProxy.Light light = lights[slot - 1];
|
||||
label = displayName(light.name);
|
||||
if (slot == shown && lights.length > MAX_LIGHTS)
|
||||
{
|
||||
// Say what did not fit rather than dropping it silently, and make room for it: the count
|
||||
// is the last thing on the key and must never be the part that gets cut.
|
||||
String more = " +" + (lights.length - MAX_LIGHTS);
|
||||
label = ellipsize(label, MAX_NAME_CHARS - more.length()) + more;
|
||||
}
|
||||
}
|
||||
KeyValue.Event ev = eventFor(slot);
|
||||
keys.add(tpl.keys.get(i)
|
||||
.withKeyValue(0, KeyValue.lightKey(label, ev))
|
||||
.withKeyValue(GLYPH_SUB_INDEX, KeyValue.lightGlyphKey(ev)));
|
||||
}
|
||||
KeyboardData.Row row = new KeyboardData.Row(keys, tpl.height, tpl.shift);
|
||||
return keys.size() == tpl.keys.size() ? row : row.updateWidth(tpl.keysWidth);
|
||||
}
|
||||
|
||||
/** The name as it fits on a key. The label is the registry's own name - there is deliberately no
|
||||
mapping from a light to a shorter label anywhere in the keyboard - cut with a visible ellipsis
|
||||
only when it would run over the neighbouring keys. Pure. */
|
||||
public static String displayName(String name)
|
||||
{
|
||||
return ellipsize(name, MAX_NAME_CHARS);
|
||||
}
|
||||
|
||||
/** Cut a line to [max] characters, marking the cut. Pure. */
|
||||
public static String ellipsize(String text, int max)
|
||||
{
|
||||
if (text == null)
|
||||
return "";
|
||||
String s = text.trim();
|
||||
if (s.length() <= max)
|
||||
return s;
|
||||
return s.substring(0, max - 1).trim() + ELLIPSIS;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ the keys
|
||||
|
||||
/** True for a key of the lights page. [KeyValue.getEvent()] is only valid for its own kind, so
|
||||
the kind is checked first - the same guard RokuRemote.isLit uses. */
|
||||
public static boolean isLightKey(KeyValue k)
|
||||
{
|
||||
return k != null && k.getKind() == KeyValue.Kind.Event && slotOf(k.getEvent()) > 0;
|
||||
}
|
||||
|
||||
/** True for the state-glyph value of a lights key. It is the value drawn in the special font
|
||||
(FLAG_KEY_FONT), which is exactly what tells it apart from the light's name. */
|
||||
public static boolean isStateGlyph(KeyValue k)
|
||||
{
|
||||
return isLightKey(k) && k.hasFlagsAny(KeyValue.FLAG_KEY_FONT);
|
||||
}
|
||||
|
||||
/** The glyph for a state: the lamp with its beams for a light that is on, the unlit lamp for
|
||||
everything else - 'off', 'unavailable', 'unknown' and no data at all. Only ON is ever drawn
|
||||
lit, so an unreachable light cannot look switched on. Pure, and the returned Strings are
|
||||
shared, so the draw path allocates nothing. */
|
||||
public static String glyphFor(LightsProxy.State state)
|
||||
{
|
||||
return state == LightsProxy.State.ON ? LIT_GLYPH : UNLIT_GLYPH;
|
||||
}
|
||||
|
||||
/** 1..MAX_LIGHTS for a lights key's event, 0 for anything else. */
|
||||
public static int slotOf(KeyValue.Event ev)
|
||||
{
|
||||
if (ev == null)
|
||||
return 0;
|
||||
switch (ev)
|
||||
{
|
||||
case LIGHT_1: return 1;
|
||||
case LIGHT_2: return 2;
|
||||
case LIGHT_3: return 3;
|
||||
case LIGHT_4: return 4;
|
||||
case LIGHT_5: return 5;
|
||||
case LIGHT_6: return 6;
|
||||
case LIGHT_7: return 7;
|
||||
case LIGHT_8: return 8;
|
||||
case LIGHT_9: return 9;
|
||||
case LIGHT_10: return 10;
|
||||
case LIGHT_11: return 11;
|
||||
case LIGHT_12: return 12;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** The event of slot [slot] (1-based), or null when the page has no such slot. */
|
||||
public static KeyValue.Event eventFor(int slot)
|
||||
{
|
||||
switch (slot)
|
||||
{
|
||||
case 1: return KeyValue.Event.LIGHT_1;
|
||||
case 2: return KeyValue.Event.LIGHT_2;
|
||||
case 3: return KeyValue.Event.LIGHT_3;
|
||||
case 4: return KeyValue.Event.LIGHT_4;
|
||||
case 5: return KeyValue.Event.LIGHT_5;
|
||||
case 6: return KeyValue.Event.LIGHT_6;
|
||||
case 7: return KeyValue.Event.LIGHT_7;
|
||||
case 8: return KeyValue.Event.LIGHT_8;
|
||||
case 9: return KeyValue.Event.LIGHT_9;
|
||||
case 10: return KeyValue.Event.LIGHT_10;
|
||||
case 11: return KeyValue.Event.LIGHT_11;
|
||||
case 12: return KeyValue.Event.LIGHT_12;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** The colour a lights key's label and glyph are drawn in. The rule itself is in one place
|
||||
([LightsProxy.colorFor]); all this does is fetch the three theme colours and the state. */
|
||||
public static int colorFor(KeyValue k, Theme theme)
|
||||
{
|
||||
return LightsProxy.colorFor(LightsProxy.stateAt(slotOf(k.getEvent())), theme.lightOnColor,
|
||||
theme.lightOffColor, theme.lightStaleColor);
|
||||
}
|
||||
|
||||
/** What a lights key says: the answer to the last press on this light while that answer is still
|
||||
fresh (a refusal, or that the state could not be read back), and null otherwise - in which
|
||||
case the key shows the light's name in its state colour. */
|
||||
public static String noteFor(KeyValue k, long now)
|
||||
{
|
||||
if (!isLightKey(k))
|
||||
return null;
|
||||
LightsProxy.Light light = LightsProxy.lightAt(slotOf(k.getEvent()));
|
||||
return light == null ? null : light.noteOrNull(now);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,747 @@
|
||||
package juloo.keyboard2;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/** The lights page's data: the whitelisted lights, their states, and one press at a time.
|
||||
*
|
||||
* The endpoint is Harley's lights-proxy on this host's wg0 address - the same
|
||||
* 10.10.10.1 that RokuRemote uses, already allowed by res/xml/network_security_config.xml. It is
|
||||
* the only thing that talks to Home Assistant, so the whitelist, the polarity rules and the
|
||||
* honesty rules live there and this class only has to report what it was told.
|
||||
*
|
||||
* Three rules, and they are the whole design:
|
||||
* - every fetch happens on a worker thread with a short timeout, and failure is quiet: no VPN,
|
||||
* no proxy, a non-2xx or a junk payload all end as "no data", which the page draws as the
|
||||
* stale look. Never a crash, and never a guessed state.
|
||||
* - a light is 'on', 'off', 'unavailable' or 'unknown', and only the first two are states the
|
||||
* page may draw as a state. The other two - and no data at all - draw as stale, because a
|
||||
* light nobody can reach must never look like a light that is switched off.
|
||||
* - a toggle is sent once and never retried, and the answer is believed rather than a
|
||||
* prediction. The proxy reports what Home Assistant said after the light settled as 'state'
|
||||
* (null when it could not be read back) and what it expects as 'optimistic_state'; the
|
||||
* prediction is never displayed.
|
||||
*
|
||||
* A light changes rarely, so the page reads at most once per POLL_MS while it is open. That is
|
||||
* deliberately nothing like the usage gauge's 1 Hz: polling a lamp harder buys no truth.
|
||||
*/
|
||||
public final class LightsProxy
|
||||
{
|
||||
/** Harley's lights-proxy, on the WireGuard address. */
|
||||
static final String ENDPOINT = "http://10.10.10.1:8772";
|
||||
|
||||
/** A light changes rarely: how often the page re-reads while it is visible. */
|
||||
static final long POLL_MS = 15000L;
|
||||
/** Opening the page or pressing a light may ask sooner than the poll, but not twice in a moment. */
|
||||
static final long FORCE_FLOOR_MS = 2000L;
|
||||
/** A snapshot older than this is never drawn as a live state, however the fetch went. */
|
||||
static final long MAX_AGE_MS = 120000L;
|
||||
/** How long the answer to a press stays on its key: long enough to read, short enough that an
|
||||
old sentence cannot pass for the current state. */
|
||||
static final long NOTE_MS = 60000L;
|
||||
private static final int CONNECT_TIMEOUT_MS = 4000;
|
||||
private static final int READ_TIMEOUT_MS = 5000;
|
||||
/** A toggle waits for Home Assistant to settle (the proxy sleeps ~2.5 s, then reads back with
|
||||
its own 4 s timeout); timing out sooner would drop an answer that was still on its way. */
|
||||
private static final int TOGGLE_READ_TIMEOUT_MS = 12000;
|
||||
/** A burst of presses must not spawn unbounded threads. The same bound RokuRemote keeps. */
|
||||
private static final int MAX_IN_FLIGHT = 4;
|
||||
|
||||
/** What the page may show for a light. 'unavailable', 'unknown', a state we do not recognise
|
||||
and no data at all are all UNKNOWN: nobody can see this light. */
|
||||
public enum State { ON, OFF, UNKNOWN }
|
||||
|
||||
/** One light as the proxy last described it, with the answer to the last press on it. All of it
|
||||
is immutable, so the worker thread can publish a whole new array and the draw path needs no
|
||||
lock: it reads one volatile reference and some final fields. */
|
||||
public static final class Light
|
||||
{
|
||||
public final String id;
|
||||
public final String name;
|
||||
public final String entityId;
|
||||
public final State state;
|
||||
/** What the last press on this light said - a refusal code, or that the state could not be
|
||||
read back - or null. Drawn instead of the name while it is fresh. */
|
||||
public final String note;
|
||||
public final long noteAt;
|
||||
|
||||
Light(String id_, String name_, String entityId_, State state_, String note_, long noteAt_)
|
||||
{
|
||||
id = id_;
|
||||
name = name_;
|
||||
entityId = entityId_;
|
||||
state = state_;
|
||||
note = note_;
|
||||
noteAt = noteAt_;
|
||||
}
|
||||
|
||||
/** The note, or null when there is nothing to say or it has gone stale. */
|
||||
public String noteOrNull(long now)
|
||||
{
|
||||
if (note == null)
|
||||
return null;
|
||||
return (now - noteAt) < NOTE_MS ? note : null;
|
||||
}
|
||||
}
|
||||
|
||||
/** The object the proxy answers /lights with, reduced to what the page needs. */
|
||||
private static final Object _lock = new Object();
|
||||
private static volatile Light[] _lights = new Light[0];
|
||||
private static volatile long _fetchedAt = 0L;
|
||||
/** True only after a read that succeeded. A failed read says so at once instead of leaving the
|
||||
last numbers wearing a live face. */
|
||||
private static volatile boolean _fresh = false;
|
||||
/** Bumped when the *list* changes (a light added, removed or renamed), so the open page knows
|
||||
it has to be rebuilt. States changing never bump it: those are just a repaint. */
|
||||
private static volatile int _version = 0;
|
||||
private static boolean _inFlight = false;
|
||||
private static long _lastAttempt = 0L;
|
||||
/** Bit per slot with a toggle in flight: a second press before the answer would flip the light
|
||||
back, which is the same trap as a retry, so it is refused. */
|
||||
private static int _pendingSlots = 0;
|
||||
private static final AtomicInteger _inFlightCount = new AtomicInteger();
|
||||
|
||||
private LightsProxy() {}
|
||||
|
||||
// ------------------------------------------------------------------ what the page reads
|
||||
|
||||
/** The lights as last read. Never null; possibly empty, which means nobody has answered yet. */
|
||||
public static Light[] lights()
|
||||
{
|
||||
return _lights;
|
||||
}
|
||||
|
||||
/** The slot's light (LIGHT_<slot>), or null when the page has fewer lights than that. */
|
||||
public static Light lightAt(int slot)
|
||||
{
|
||||
Light[] lights = _lights;
|
||||
int i = slot - 1;
|
||||
return (i < 0 || i >= lights.length) ? null : lights[i];
|
||||
}
|
||||
|
||||
/** The state to draw for a slot: UNKNOWN whenever the page has no *current* answer, which is
|
||||
what makes 'unavailable' and a dead proxy look the same - not a state. */
|
||||
public static State stateAt(int slot)
|
||||
{
|
||||
Light light = lightAt(slot);
|
||||
if (light == null || isStaleNow())
|
||||
return State.UNKNOWN;
|
||||
return light.state;
|
||||
}
|
||||
|
||||
/** True when there is nothing to draw a state from: no read has succeeded, it failed, or what
|
||||
we have is too old to call current. */
|
||||
public static boolean isStaleNow()
|
||||
{
|
||||
return !_fresh || (System.currentTimeMillis() - _fetchedAt) >= MAX_AGE_MS;
|
||||
}
|
||||
|
||||
/** Changes whenever the light *list* does. The open page compares it to know when to rebuild. */
|
||||
public static int version()
|
||||
{
|
||||
return _version;
|
||||
}
|
||||
|
||||
/** THE colour rule, and the only place it is written: ON is blue, OFF is pink, and everything
|
||||
else - unavailable, unknown, no data - is the stale grey. The three colours themselves come
|
||||
from the theme (res/values/themes.xml), so swapping on and off later is a one-line change
|
||||
there and no key holds a colour of its own. */
|
||||
public static int colorFor(State state, int onColor, int offColor, int staleColor)
|
||||
{
|
||||
if (state == null)
|
||||
return staleColor; // no light at all: the same look as one nobody can see
|
||||
switch (state)
|
||||
{
|
||||
case ON: return onColor;
|
||||
case OFF: return offColor;
|
||||
default: return staleColor;
|
||||
}
|
||||
}
|
||||
|
||||
/** 'on' and 'off' are states; everything else - including 'unavailable', 'unknown', a missing
|
||||
field and anything we do not recognise - is UNKNOWN, never OFF. Pure, so it is tested. */
|
||||
public static State stateOf(String raw)
|
||||
{
|
||||
if (raw == null)
|
||||
return State.UNKNOWN;
|
||||
String text = raw.trim().toLowerCase(Locale.US);
|
||||
if (text.equals("on"))
|
||||
return State.ON;
|
||||
if (text.equals("off"))
|
||||
return State.OFF;
|
||||
return State.UNKNOWN;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ fetching
|
||||
|
||||
/** Read the lights, at most once per POLL_MS; [force] is for opening the page and for the press
|
||||
that follows, which are allowed to ask sooner but not in a burst. Never blocks the caller and
|
||||
never throws: when a read is actually made, [onDone] runs on that worker thread afterwards. */
|
||||
public static void fetchIfNeeded(boolean force, Runnable onDone)
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
synchronized (_lock)
|
||||
{
|
||||
long floor = force ? FORCE_FLOOR_MS : POLL_MS;
|
||||
if (_inFlight || (now - _lastAttempt) < floor)
|
||||
return;
|
||||
_inFlight = true;
|
||||
_lastAttempt = now;
|
||||
}
|
||||
Thread worker = new Thread(() -> {
|
||||
try
|
||||
{
|
||||
read(ENDPOINT + "/lights");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// One answer for every way a read can go wrong.
|
||||
fail();
|
||||
}
|
||||
finally
|
||||
{
|
||||
synchronized (_lock) { _inFlight = false; }
|
||||
runQuietly(onDone);
|
||||
}
|
||||
}, "lights-fetch");
|
||||
worker.setDaemon(true);
|
||||
worker.start();
|
||||
}
|
||||
|
||||
private static void read(String url)
|
||||
{
|
||||
HttpURLConnection connection = null;
|
||||
try
|
||||
{
|
||||
connection = (HttpURLConnection)new URL(url).openConnection();
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT_MS);
|
||||
connection.setReadTimeout(READ_TIMEOUT_MS);
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
StringBuilder body = new StringBuilder();
|
||||
try (InputStream input = connection.getInputStream();
|
||||
InputStreamReader reader = new InputStreamReader(input, "UTF-8"))
|
||||
{
|
||||
char[] buf = new char[4096];
|
||||
int n;
|
||||
while ((n = reader.read(buf)) > 0)
|
||||
body.append(buf, 0, n);
|
||||
}
|
||||
Light[] parsed = parseLights(body.toString());
|
||||
if (parsed == null)
|
||||
{
|
||||
fail(); // a payload we cannot read is no data at all
|
||||
return;
|
||||
}
|
||||
publish(parsed);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// No VPN, no route, proxy down, refused, a non-2xx like the no-token 200-with-nothing and
|
||||
// an unreadable stream: one answer for all of them.
|
||||
fail();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (connection != null)
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
private static void fail()
|
||||
{
|
||||
_fresh = false;
|
||||
}
|
||||
|
||||
private static void publish(Light[] lights)
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
if (!sameList(_lights, lights))
|
||||
_version++;
|
||||
/* The notes travel with the lights so a rebuild keeps them, but a real state from the box
|
||||
supersedes the answer to a press: once we know what the light is doing, the last
|
||||
sentence about it is no longer the best thing to show. */
|
||||
Light[] merged = new Light[lights.length];
|
||||
for (int i = 0; i < lights.length; i++)
|
||||
{
|
||||
merged[i] = mergeNote(lights[i], _lights);
|
||||
}
|
||||
_lights = merged;
|
||||
_fetchedAt = System.currentTimeMillis();
|
||||
_fresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** A fresh reading of the same light keeps a still-useful note; anything else replaces it. */
|
||||
static Light mergeNote(Light fresh, Light[] previous)
|
||||
{
|
||||
if (fresh.note != null || fresh.state != State.UNKNOWN)
|
||||
return fresh;
|
||||
for (int i = 0; i < previous.length; i++)
|
||||
{
|
||||
Light old = previous[i];
|
||||
if (old.id.equals(fresh.id) && old.note != null)
|
||||
return new Light(fresh.id, fresh.name, fresh.entityId, fresh.state, old.note, old.noteAt);
|
||||
}
|
||||
return fresh;
|
||||
}
|
||||
|
||||
private static boolean sameList(Light[] a, Light[] b)
|
||||
{
|
||||
if (a.length != b.length)
|
||||
return false;
|
||||
for (int i = 0; i < a.length; i++)
|
||||
if (!a[i].id.equals(b[i].id) || !a[i].name.equals(b[i].name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ pressing a light
|
||||
|
||||
/** Toggle one light (1-based slot). Sent once, never retried: a retried toggle on a light that
|
||||
did change flips it straight back. [onDone] runs on the worker thread, twice at most - once
|
||||
with the answer to this press, once when the follow-up read lands. */
|
||||
public static void toggle(int slot, Runnable onDone)
|
||||
{
|
||||
Light light = lightAt(slot);
|
||||
if (light == null || !claimSlot(slot))
|
||||
return;
|
||||
final String id = light.id;
|
||||
Thread worker = new Thread(() -> {
|
||||
ToggleResult result = null;
|
||||
try
|
||||
{
|
||||
result = sendToggle(id);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
releaseSlot(slot);
|
||||
/* What the press said, painted at once: a refusal or an unreadable read-back is the
|
||||
honest thing to show, and waiting for a poll would hide it for seconds. */
|
||||
reply(slot, result);
|
||||
runQuietly(onDone);
|
||||
/* And then a read: the answer above is about this one light and the page should not keep
|
||||
a stale view of the rest. Floored like a page open, so a burst of presses cannot become
|
||||
a burst of reads, and the proxy caches reads for 9 s anyway. */
|
||||
fetchIfNeeded(true, onDone);
|
||||
}
|
||||
}, "lights-toggle");
|
||||
worker.setDaemon(true);
|
||||
worker.start();
|
||||
}
|
||||
|
||||
/** Reserves the slot and one in-flight allowance, or refuses. Bounded like RokuRemote, and one
|
||||
press per light at a time: a second press before the answer would flip it back. */
|
||||
private static boolean claimSlot(int slot)
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
int bit = 1 << (slot - 1);
|
||||
if ((_pendingSlots & bit) != 0)
|
||||
return false;
|
||||
if (_inFlightCount.incrementAndGet() > MAX_IN_FLIGHT)
|
||||
{
|
||||
_inFlightCount.decrementAndGet();
|
||||
return false;
|
||||
}
|
||||
_pendingSlots |= bit;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void releaseSlot(int slot)
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
_pendingSlots &= ~(1 << (slot - 1));
|
||||
}
|
||||
_inFlightCount.decrementAndGet();
|
||||
}
|
||||
|
||||
private static ToggleResult sendToggle(String id) throws Exception
|
||||
{
|
||||
HttpURLConnection connection = null;
|
||||
try
|
||||
{
|
||||
String url = ENDPOINT + "/lights/" + URLEncoder.encode(id, "UTF-8") + "/toggle";
|
||||
connection = (HttpURLConnection)new URL(url).openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT_MS);
|
||||
connection.setReadTimeout(TOGGLE_READ_TIMEOUT_MS);
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setDoOutput(true);
|
||||
connection.setFixedLengthStreamingMode(0); // a POST with no body: the proxy ignores it
|
||||
int code = connection.getResponseCode();
|
||||
boolean ok = code >= 200 && code < 300;
|
||||
String body = readAll(ok ? connection.getInputStream() : connection.getErrorStream());
|
||||
/* Both halves matter: a 503 carries the reason (no token yet, a light Home Assistant cannot
|
||||
read) and a 200 carries the read-back. An unreadable body is still an answer. */
|
||||
ToggleResult result = parseToggle(body);
|
||||
return result != null ? result : ToggleResult.unreadable();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (connection != null)
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
private static String readAll(InputStream input) throws Exception
|
||||
{
|
||||
if (input == null)
|
||||
return null;
|
||||
StringBuilder body = new StringBuilder();
|
||||
try (InputStreamReader reader = new InputStreamReader(input, "UTF-8"))
|
||||
{
|
||||
char[] buf = new char[2048];
|
||||
int n;
|
||||
while ((n = reader.read(buf)) > 0)
|
||||
body.append(buf, 0, n);
|
||||
}
|
||||
return body.toString();
|
||||
}
|
||||
|
||||
/** What the press did to the light: the read-back, which is the only thing shown, and what the
|
||||
proxy said when it could not give one. */
|
||||
static void reply(int slot, ToggleResult result)
|
||||
{
|
||||
if (result == null)
|
||||
result = ToggleResult.unreadable();
|
||||
synchronized (_lock)
|
||||
{
|
||||
Light[] current = _lights;
|
||||
int i = slot - 1;
|
||||
if (i < 0 || i >= current.length)
|
||||
return;
|
||||
Light old = current[i];
|
||||
State state = old.state;
|
||||
if (result.accepted)
|
||||
state = result.state == null ? State.UNKNOWN : stateOf(result.state);
|
||||
String note = result.note();
|
||||
if (note != null)
|
||||
note = LightsPage.ellipsize(note, LightsPage.MAX_NAME_CHARS);
|
||||
Light[] next = current.clone();
|
||||
next[i] = new Light(old.id, old.name, old.entityId, state, note,
|
||||
System.currentTimeMillis());
|
||||
_lights = next; // the list itself is unchanged: no rebuild, the view just repaints
|
||||
}
|
||||
}
|
||||
|
||||
private static void runQuietly(Runnable r)
|
||||
{
|
||||
if (r == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
r.run();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// A repaint request must never take the keyboard down.
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ parsing
|
||||
|
||||
/** The lights of a GET /lights payload, or null when it cannot be read: a page that invents an
|
||||
empty list would be claiming there are no lights. Pure, so it is tested. */
|
||||
public static Light[] parseLights(String json)
|
||||
{
|
||||
Object root = Json.parse(json);
|
||||
if (!(root instanceof Map))
|
||||
return null;
|
||||
Object raw = ((Map<?, ?>)root).get("lights");
|
||||
if (!(raw instanceof List))
|
||||
return null;
|
||||
ArrayList<Light> out = new ArrayList<Light>();
|
||||
for (Object item : (List<?>)raw)
|
||||
{
|
||||
if (!(item instanceof Map))
|
||||
continue;
|
||||
Map<?, ?> m = (Map<?, ?>)item;
|
||||
String id = asString(m.get("id"));
|
||||
String name = asString(m.get("name"));
|
||||
if (id == null || name == null || name.trim().isEmpty())
|
||||
continue; // a light with no name has no key on the page
|
||||
String entity = asString(m.get("entity_id"));
|
||||
out.add(new Light(id, name, entity == null ? "" : entity,
|
||||
stateOf(asString(m.get("state"))), null, 0L));
|
||||
}
|
||||
return out.toArray(new Light[out.size()]);
|
||||
}
|
||||
|
||||
/** What one toggle said. [state] is Home Assistant's read-back after the light settled, and the
|
||||
only field the page may display as a state; [optimisticState] is the proxy's prediction and
|
||||
is deliberately not kept here. Pure, so it is tested. */
|
||||
public static final class ToggleResult
|
||||
{
|
||||
public final boolean accepted;
|
||||
public final String state;
|
||||
public final boolean confirmed;
|
||||
public final Boolean changed;
|
||||
public final String warning;
|
||||
public final String code;
|
||||
|
||||
ToggleResult(boolean accepted_, String state_, boolean confirmed_, Boolean changed_,
|
||||
String warning_, String code_)
|
||||
{
|
||||
accepted = accepted_;
|
||||
state = state_;
|
||||
confirmed = confirmed_;
|
||||
changed = changed_;
|
||||
warning = warning_;
|
||||
code = code_;
|
||||
}
|
||||
|
||||
static ToggleResult unreadable()
|
||||
{
|
||||
return new ToggleResult(false, null, false, null, null, "no_answer");
|
||||
}
|
||||
|
||||
/** The one short line the key shows instead of the name, or null when the answer was a state
|
||||
the page can show. It is the proxy's own vocabulary - its error code - or the fact that
|
||||
the state could not be read back; the long prose warning does not fit a key. */
|
||||
public String note()
|
||||
{
|
||||
if (!accepted)
|
||||
return code == null ? "refused" : code;
|
||||
if (state == null || !confirmed)
|
||||
return "unconfirmed";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** What a POST /lights/<id>/toggle answered, or null when the body cannot be read. Pure. */
|
||||
public static ToggleResult parseToggle(String json)
|
||||
{
|
||||
Object root = Json.parse(json);
|
||||
if (!(root instanceof Map))
|
||||
return null;
|
||||
Map<?, ?> m = (Map<?, ?>)root;
|
||||
Object accepted = m.get("accepted");
|
||||
String state = asString(m.get("state"));
|
||||
String code = error_code(m);
|
||||
if (accepted == null && state == null && code == null)
|
||||
return null; // a body that says neither yes, nor no, nor what it saw is no answer
|
||||
return new ToggleResult(asBool(accepted), state, asBool(m.get("confirmed")),
|
||||
asBoolean(m.get("changed")), asString(m.get("warning")), code);
|
||||
}
|
||||
|
||||
/** Why a toggle was refused: the service's own error code - from the nested error object its
|
||||
toggle answer documents, or the flat "code" a refusal carries - and only the prose when there
|
||||
is no code at all. A key has room for the vocabulary, not for a sentence. Null when the
|
||||
service did not refuse. */
|
||||
private static String error_code(Map<?, ?> m)
|
||||
{
|
||||
Object err = m.get("error");
|
||||
if (err instanceof Map)
|
||||
{
|
||||
String nested = asString(((Map<?, ?>)err).get("code"));
|
||||
if (nested != null)
|
||||
return nested;
|
||||
}
|
||||
String code = asString(m.get("code"));
|
||||
return code != null ? code : asString(err);
|
||||
}
|
||||
|
||||
static String asString(Object v)
|
||||
{
|
||||
return (v instanceof String) ? (String)v : null;
|
||||
}
|
||||
|
||||
static boolean asBool(Object v)
|
||||
{
|
||||
return (v instanceof Boolean) && ((Boolean)v).booleanValue();
|
||||
}
|
||||
|
||||
static Boolean asBoolean(Object v)
|
||||
{
|
||||
return (v instanceof Boolean) ? (Boolean)v : null;
|
||||
}
|
||||
|
||||
/** A deliberately small JSON reader: objects, arrays, strings, numbers, booleans and null.
|
||||
*
|
||||
* Android's org.json is a stub under the local JVM test runner, which is why HostGraph and this
|
||||
* class parse their own payloads: pure Java, so the tests can drive the real parser over the
|
||||
* real payloads. Only what the lights endpoints answer with is supported, and anything it
|
||||
* cannot read becomes "no data" rather than a guess. */
|
||||
static final class Json
|
||||
{
|
||||
private final String _s;
|
||||
private int _i = 0;
|
||||
|
||||
private Json(String s) { _s = s; }
|
||||
|
||||
/** Map/List/String/Double/Boolean/null, or null when the text cannot be read. */
|
||||
static Object parse(String text)
|
||||
{
|
||||
if (text == null)
|
||||
return null;
|
||||
Json p = new Json(text);
|
||||
try
|
||||
{
|
||||
Object v = p.value();
|
||||
p.ws();
|
||||
return p._i == p._s.length() ? v : null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ws()
|
||||
{
|
||||
while (_i < _s.length() && Character.isWhitespace(_s.charAt(_i)))
|
||||
_i++;
|
||||
}
|
||||
|
||||
private Object value() throws Exception
|
||||
{
|
||||
ws();
|
||||
if (_i >= _s.length())
|
||||
throw new Exception("eof");
|
||||
char c = _s.charAt(_i);
|
||||
switch (c)
|
||||
{
|
||||
case '{': return object();
|
||||
case '[': return array();
|
||||
case '"': return string();
|
||||
case 't': expect("true"); return Boolean.TRUE;
|
||||
case 'f': expect("false"); return Boolean.FALSE;
|
||||
case 'n': expect("null"); return null;
|
||||
default: return number();
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> object() throws Exception
|
||||
{
|
||||
Map<String, Object> out = new java.util.LinkedHashMap<String, Object>();
|
||||
_i++; // '{'
|
||||
ws();
|
||||
if (peek() == '}')
|
||||
{
|
||||
_i++;
|
||||
return out;
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
ws();
|
||||
if (peek() != '"')
|
||||
throw new Exception("object key");
|
||||
String key = string();
|
||||
ws();
|
||||
if (peek() != ':')
|
||||
throw new Exception("object colon");
|
||||
_i++;
|
||||
out.put(key, value());
|
||||
ws();
|
||||
char c = peek();
|
||||
_i++;
|
||||
if (c == '}')
|
||||
return out;
|
||||
if (c != ',')
|
||||
throw new Exception("object comma");
|
||||
}
|
||||
}
|
||||
|
||||
private List<Object> array() throws Exception
|
||||
{
|
||||
List<Object> out = new ArrayList<Object>();
|
||||
_i++; // '['
|
||||
ws();
|
||||
if (peek() == ']')
|
||||
{
|
||||
_i++;
|
||||
return out;
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
out.add(value());
|
||||
ws();
|
||||
char c = peek();
|
||||
_i++;
|
||||
if (c == ']')
|
||||
return out;
|
||||
if (c != ',')
|
||||
throw new Exception("array comma");
|
||||
}
|
||||
}
|
||||
|
||||
private String string() throws Exception
|
||||
{
|
||||
StringBuilder b = new StringBuilder();
|
||||
_i++; // '"'
|
||||
while (true)
|
||||
{
|
||||
if (_i >= _s.length())
|
||||
throw new Exception("string eof");
|
||||
char c = _s.charAt(_i++);
|
||||
if (c == '"')
|
||||
return b.toString();
|
||||
if (c != '\\')
|
||||
{
|
||||
b.append(c);
|
||||
continue;
|
||||
}
|
||||
if (_i >= _s.length())
|
||||
throw new Exception("escape eof");
|
||||
char e = _s.charAt(_i++);
|
||||
switch (e)
|
||||
{
|
||||
case '"': b.append('"'); break;
|
||||
case '\\': b.append('\\'); break;
|
||||
case '/': b.append('/'); break;
|
||||
case 'b': b.append('\b'); break;
|
||||
case 'f': b.append('\f'); break;
|
||||
case 'n': b.append('\n'); break;
|
||||
case 'r': b.append('\r'); break;
|
||||
case 't': b.append('\t'); break;
|
||||
case 'u':
|
||||
if (_i + 4 > _s.length())
|
||||
throw new Exception("unicode escape eof");
|
||||
b.append((char)Integer.parseInt(_s.substring(_i, _i + 4), 16));
|
||||
_i += 4;
|
||||
break;
|
||||
default: throw new Exception("escape");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Double number() throws Exception
|
||||
{
|
||||
int start = _i;
|
||||
while (_i < _s.length() && "+-.eE0123456789".indexOf(_s.charAt(_i)) >= 0)
|
||||
_i++;
|
||||
if (_i == start)
|
||||
throw new Exception("number");
|
||||
return Double.valueOf(_s.substring(start, _i));
|
||||
}
|
||||
|
||||
private char peek() throws Exception
|
||||
{
|
||||
if (_i >= _s.length())
|
||||
throw new Exception("eof");
|
||||
return _s.charAt(_i);
|
||||
}
|
||||
|
||||
private void expect(String word) throws Exception
|
||||
{
|
||||
if (!_s.startsWith(word, _i))
|
||||
throw new Exception("expected " + word);
|
||||
_i += word.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,10 @@ public final class Pointers implements Handler.Callback
|
||||
if (ptr.hasFlagsAny(FLAG_P_SLIDING))
|
||||
{
|
||||
clearLatched();
|
||||
ptr.sliding.onTouchUp(ptr);
|
||||
if (ptr.joypad != null)
|
||||
ptr.joypad.onTouchUp(ptr);
|
||||
else
|
||||
ptr.sliding.onTouchUp(ptr);
|
||||
return;
|
||||
}
|
||||
stopLongPress(ptr);
|
||||
@@ -211,7 +214,13 @@ public final class Pointers implements Handler.Callback
|
||||
KeyValue value = _handler.modifyKey(key.keys[0], mods);
|
||||
Pointer ptr = make_pointer(pointerId, key, value, x, y, mods);
|
||||
_ptrs.add(ptr);
|
||||
startLongPress(ptr);
|
||||
// Space bar gets a slightly shorter long-press (500ms) so the joypad
|
||||
// activates quickly when holding space
|
||||
if (value != null && value.getKind() == KeyValue.Kind.Editing
|
||||
&& value.getEditing() == KeyValue.Editing.SPACE_BAR)
|
||||
startLongPress(ptr, 500);
|
||||
else
|
||||
startLongPress(ptr);
|
||||
_handler.onPointerDown(value, false);
|
||||
}
|
||||
|
||||
@@ -267,7 +276,14 @@ public final class Pointers implements Handler.Callback
|
||||
return;
|
||||
if (ptr.hasFlagsAny(FLAG_P_SLIDING))
|
||||
{
|
||||
ptr.sliding.onTouchMove(ptr, x, y);
|
||||
if (ptr.joypad != null)
|
||||
{
|
||||
ptr.joypad.onTouchMove(ptr, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr.sliding.onTouchMove(ptr, x, y);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -312,6 +328,13 @@ public final class Pointers implements Handler.Callback
|
||||
startSliding(ptr, x, y, dx, dy, new_value);
|
||||
_handler.onPointerDown(new_value, true);
|
||||
}
|
||||
else if (ptr.value != null
|
||||
&& ptr.value.getKind() == KeyValue.Kind.Slider
|
||||
&& ptr.value.getSlider().isJoystick())
|
||||
{
|
||||
// Joystick: swipe in any direction activates it
|
||||
startSliding(ptr, x, y, dx, dy, ptr.value);
|
||||
}
|
||||
|
||||
}
|
||||
else if (ptr.gesture.changed_direction(direction))
|
||||
@@ -401,7 +424,15 @@ public final class Pointers implements Handler.Callback
|
||||
{
|
||||
if (ptr.timeoutWhat == msg.what)
|
||||
{
|
||||
handleLongPress(ptr);
|
||||
// Joypad auto-repeat takes priority over long-press/hold
|
||||
if (ptr.joypad != null && ptr.hasFlagsAny(FLAG_P_SLIDING))
|
||||
{
|
||||
ptr.joypad.doRepeat(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
handleLongPress(ptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -417,6 +448,14 @@ public final class Pointers implements Handler.Callback
|
||||
_longpress_handler.sendEmptyMessageDelayed(what, _config.longPressTimeout);
|
||||
}
|
||||
|
||||
/** Start long-press timer with a custom timeout override (ms). */
|
||||
private void startLongPress(Pointer ptr, long timeoutMs)
|
||||
{
|
||||
int what = (uniqueTimeoutWhat++);
|
||||
ptr.timeoutWhat = what;
|
||||
_longpress_handler.sendEmptyMessageDelayed(what, timeoutMs);
|
||||
}
|
||||
|
||||
private void stopLongPress(Pointer ptr)
|
||||
{
|
||||
_longpress_handler.removeMessages(ptr.timeoutWhat);
|
||||
@@ -449,6 +488,16 @@ public final class Pointers implements Handler.Callback
|
||||
_handler.onPointerDown(kv, true);
|
||||
return;
|
||||
}
|
||||
// Space bar long-press: enter joypad cursor mode
|
||||
if (ptr.value.getKind() == KeyValue.Kind.Editing
|
||||
&& ptr.value.getEditing() == KeyValue.Editing.SPACE_BAR)
|
||||
{
|
||||
stopLongPress(ptr);
|
||||
ptr.flags |= FLAG_P_SLIDING;
|
||||
ptr.joypad = new Joypad(ptr.downX, ptr.downY,
|
||||
KeyValue.Slider.Cursor_joystick);
|
||||
return;
|
||||
}
|
||||
// Special keys
|
||||
if (kv.hasFlagsAny(KeyValue.FLAG_SPECIAL))
|
||||
return;
|
||||
@@ -472,7 +521,15 @@ public final class Pointers implements Handler.Callback
|
||||
int diry = dy < 0 ? -r : r;
|
||||
stopLongPress(ptr);
|
||||
ptr.flags |= FLAG_P_SLIDING;
|
||||
ptr.sliding = new Sliding(x, y, dirx, diry, kv.getSlider());
|
||||
KeyValue.Slider s = kv.getSlider();
|
||||
if (s.isJoystick())
|
||||
{
|
||||
ptr.joypad = new Joypad(x, y, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr.sliding = new Sliding(x, y, dirx, diry, s);
|
||||
}
|
||||
}
|
||||
|
||||
/** Return the [FLAG_P_*] flags that correspond to pressing [kv]. */
|
||||
@@ -556,6 +613,8 @@ public final class Pointers implements Handler.Callback
|
||||
public int timeoutWhat;
|
||||
/** [null] when not in sliding mode. */
|
||||
public Sliding sliding;
|
||||
/** [null] when not in joypad mode. */
|
||||
public Joypad joypad;
|
||||
|
||||
public Pointer(int p, KeyboardData.Key k, KeyValue v, float x, float y, Modifiers m, int f)
|
||||
{
|
||||
@@ -569,6 +628,7 @@ public final class Pointers implements Handler.Callback
|
||||
flags = f;
|
||||
timeoutWhat = -1;
|
||||
sliding = null;
|
||||
joypad = null;
|
||||
}
|
||||
|
||||
public boolean hasFlagsAny(int has)
|
||||
@@ -672,6 +732,122 @@ public final class Pointers implements Handler.Callback
|
||||
}
|
||||
}
|
||||
|
||||
/** Joypad: direction-lock + auto-repeat cursor control with speed curve.
|
||||
Designed for the space bar (limited room for finger travel).
|
||||
|
||||
Once the finger moves past the dead zone, the dominant direction is
|
||||
locked and cursor events auto-repeat at a rate and step count that
|
||||
increase with finger distance from origin (farther = faster). */
|
||||
public final class Joypad
|
||||
{
|
||||
/** The last locked direction, or null if inactive. */
|
||||
KeyValue.Slider _activeDir = null;
|
||||
/** Position of the finger when joypad was activated (down point). */
|
||||
float _originX;
|
||||
float _originY;
|
||||
/** The slider this joypad delegates to. */
|
||||
KeyValue.Slider slider;
|
||||
/** Current speed: steps per auto-repeat tick [1..5]. */
|
||||
int _stepsPerTick = 1;
|
||||
/** Current interval between ticks (ms). */
|
||||
int _repeatMs;
|
||||
|
||||
public Joypad(float x, float y, KeyValue.Slider s)
|
||||
{
|
||||
_originX = x;
|
||||
_originY = y;
|
||||
slider = s;
|
||||
_repeatMs = (int)_config.longPressInterval;
|
||||
}
|
||||
|
||||
/** Pick the dominant direction from a finger offset deltas. */
|
||||
KeyValue.Slider pickDirection(float dx, float dy)
|
||||
{
|
||||
if (Math.abs(dx) >= Math.abs(dy))
|
||||
return (dx > 0) ? KeyValue.Slider.Cursor_right
|
||||
: KeyValue.Slider.Cursor_left;
|
||||
else
|
||||
return (dy > 0) ? KeyValue.Slider.Cursor_down
|
||||
: KeyValue.Slider.Cursor_up;
|
||||
}
|
||||
|
||||
/** Compute speed curve from finger displacement.
|
||||
[dist] = Manhattan distance from origin.
|
||||
Returns [stepsPerTick, repeatIntervalMs]. */
|
||||
void computeSpeed(float dist)
|
||||
{
|
||||
float d = dist - _config.swipe_dist_px; // distance beyond dead zone
|
||||
if (d < 1f) d = 1f;
|
||||
float maxD = _config.swipe_dist_px * 6f; // ~6x dead zone = max speed
|
||||
float t = Math.min(d / maxD, 1f); // 0..1
|
||||
// Quadratic curve: gentle near center, faster at extremes
|
||||
float curve = t * t;
|
||||
_stepsPerTick = 1 + (int)(curve * 4f); // 1..5 steps/tick
|
||||
int base = (int)_config.longPressInterval;
|
||||
_repeatMs = Math.max(30, base - (int)((base - 30) * curve));
|
||||
}
|
||||
|
||||
public void onTouchMove(Pointer ptr, float x, float y)
|
||||
{
|
||||
float dx = x - _originX;
|
||||
float dy = y - _originY;
|
||||
float dist = Math.abs(dx) + Math.abs(dy);
|
||||
|
||||
// Dead zone: finger hasn't moved far enough from origin
|
||||
if (dist < _config.swipe_dist_px)
|
||||
{
|
||||
if (_activeDir != null)
|
||||
{
|
||||
// Returned to center → stop auto-repeat
|
||||
_activeDir = null;
|
||||
_longpress_handler.removeMessages(ptr.timeoutWhat);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Update speed curve from current distance
|
||||
computeSpeed(dist);
|
||||
|
||||
KeyValue.Slider newDir = pickDirection(dx, dy);
|
||||
|
||||
if (newDir != _activeDir)
|
||||
{
|
||||
// Direction changed (or first lock) → fire and start/restart auto-repeat
|
||||
_activeDir = newDir;
|
||||
_longpress_handler.removeMessages(ptr.timeoutWhat);
|
||||
_handler.onPointerHold(
|
||||
KeyValue.sliderKey(newDir, _stepsPerTick), ptr.modifiers);
|
||||
// Schedule next repeat with computed interval
|
||||
_longpress_handler.sendEmptyMessageDelayed(
|
||||
ptr.timeoutWhat, _repeatMs);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Same direction: don't reschedule timer (touch events come faster
|
||||
// than the timer, which would keep pushing it out). The pending
|
||||
// doRepeat tick will pick up the updated _stepsPerTick / _repeatMs.
|
||||
}
|
||||
}
|
||||
|
||||
/** Called by Pointers.handleMessage for auto-repeat ticks. */
|
||||
public void doRepeat(Pointer ptr)
|
||||
{
|
||||
if (_activeDir == null) return;
|
||||
_handler.onPointerHold(
|
||||
KeyValue.sliderKey(_activeDir, _stepsPerTick), ptr.modifiers);
|
||||
_longpress_handler.sendEmptyMessageDelayed(
|
||||
ptr.timeoutWhat, _repeatMs);
|
||||
}
|
||||
|
||||
public void onTouchUp(Pointer ptr)
|
||||
{
|
||||
_activeDir = null;
|
||||
_longpress_handler.removeMessages(ptr.timeoutWhat);
|
||||
removePtr(ptr);
|
||||
_handler.onPointerFlagsChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** Represent modifiers currently activated.
|
||||
Sorted in the order they should be evaluated. */
|
||||
public static final class Modifiers
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
package juloo.keyboard2;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/** Sends Roku remote commands from the keyboard.
|
||||
*
|
||||
* Three rules, and they are the whole design:
|
||||
* - the request happens on a worker thread. [Keyboard2.Receiver.handle_event_key] runs
|
||||
* on the main thread, so it must return immediately: doing the network work inline
|
||||
* would freeze the keyboard for as long as the TV takes to answer.
|
||||
* - failure is quiet, exactly like [HostGraph]. No TV, no VPN, a refused connection, a
|
||||
* non-2xx from the proxy or a timeout all end as "nothing happened" - never a crash
|
||||
* and never a wedged key.
|
||||
* - the pressed key stays lit for a moment, from two plain fields that only the draw
|
||||
* path reads. A command against a sleeping Roku legitimately takes ~5 s to be
|
||||
* answered (202 Accepted), and a key that looks dead gets pressed twice.
|
||||
*
|
||||
* The endpoint is Harley's proxy on this host's wg0 address: it passes
|
||||
* /roku/keypress/<Key> straight through to the TV's ECP listener on port 8060.
|
||||
* Cleartext for 10.10.10.1 is already allowed by res/xml/network_security_config.xml.
|
||||
*/
|
||||
public final class RokuRemote
|
||||
{
|
||||
private static final String ENDPOINT = "http://10.10.10.1:7777/roku/keypress/";
|
||||
/** The proxy gives the TV 15 s before it gives up; timing out sooner than the
|
||||
proxy would drop an answer that was still on its way. */
|
||||
private static final int CONNECT_TIMEOUT_MS = 15000;
|
||||
private static final int READ_TIMEOUT_MS = 15000;
|
||||
/** How long the key is lit from the press until an answer arrives. */
|
||||
private static final long PRESSED_MS = 700L;
|
||||
/** ... and how long an accepted command keeps it lit. */
|
||||
private static final long SENT_MS = 1300L;
|
||||
/** A burst of presses must not spawn unbounded threads; past this a press is dropped. */
|
||||
private static final int MAX_IN_FLIGHT = 8;
|
||||
|
||||
/** Which key is lit, and when its light goes out. Plain fields, written by the
|
||||
worker thread and read by the draw path, which allocates nothing for them. */
|
||||
private static volatile KeyValue.Event _litEvent = null;
|
||||
private static volatile long _litUntil = 0L;
|
||||
private static final AtomicInteger _inFlight = new AtomicInteger();
|
||||
|
||||
private RokuRemote() {}
|
||||
|
||||
/** True while [ev] should be drawn as just-pressed. Safe on the draw path. */
|
||||
public static boolean isLit(KeyValue.Event ev, long now)
|
||||
{
|
||||
return ev != null && ev == _litEvent && now < _litUntil;
|
||||
}
|
||||
|
||||
/** The same test for a whole key. [KeyValue.getEvent()] is only valid for its own
|
||||
kind, so this is the single place that reads a key's value and it checks the kind
|
||||
first. Allocates nothing: one enum reference and one long. */
|
||||
public static boolean isLit(KeyValue kv, long now)
|
||||
{
|
||||
return kv != null && kv.getKind() == KeyValue.Kind.Event && isLit(kv.getEvent(), now);
|
||||
}
|
||||
|
||||
/** Send one command. Never blocks the caller and never throws. */
|
||||
public static void press(KeyValue.Event ev)
|
||||
{
|
||||
final String key = ecpKey(ev);
|
||||
if (key == null)
|
||||
return;
|
||||
if (_inFlight.incrementAndGet() > MAX_IN_FLIGHT)
|
||||
{
|
||||
_inFlight.decrementAndGet();
|
||||
return; // fail-soft: a dropped press beats unbounded threads
|
||||
}
|
||||
_litEvent = ev;
|
||||
_litUntil = System.currentTimeMillis() + PRESSED_MS;
|
||||
Thread worker = new Thread(() -> send(ev, key), "roku-remote");
|
||||
worker.setDaemon(true);
|
||||
worker.start();
|
||||
}
|
||||
|
||||
private static void send(KeyValue.Event ev, String key)
|
||||
{
|
||||
boolean accepted = false;
|
||||
HttpURLConnection connection = null;
|
||||
try
|
||||
{
|
||||
connection = (HttpURLConnection)new URL(ENDPOINT + key).openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT_MS);
|
||||
connection.setReadTimeout(READ_TIMEOUT_MS);
|
||||
int code = connection.getResponseCode();
|
||||
accepted = code >= 200 && code < 300; // 202 once the TV has taken the keypress
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// No VPN, no route, TV off, proxy down, unreadable: one answer for all of them.
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (connection != null)
|
||||
connection.disconnect();
|
||||
_inFlight.decrementAndGet();
|
||||
// Only light up if this key is still the one on screen: the user may have moved on.
|
||||
if (accepted && ev == _litEvent)
|
||||
_litUntil = System.currentTimeMillis() + SENT_MS;
|
||||
}
|
||||
}
|
||||
|
||||
/** The ECP key names, i.e. what goes after /keypress/. */
|
||||
private static String ecpKey(KeyValue.Event ev)
|
||||
{
|
||||
switch (ev)
|
||||
{
|
||||
case ROKU_HOME: return "Home";
|
||||
case ROKU_BACK: return "Back";
|
||||
case ROKU_UP: return "Up";
|
||||
case ROKU_DOWN: return "Down";
|
||||
case ROKU_LEFT: return "Left";
|
||||
case ROKU_RIGHT: return "Right";
|
||||
case ROKU_SELECT: return "Select";
|
||||
case ROKU_PLAY: return "Play";
|
||||
case ROKU_REWIND: return "Rev"; // the ECP's name for rewind
|
||||
case ROKU_FORWARD: return "Fwd"; // ... and for fast forward
|
||||
case ROKU_POWER: return "Power"; // the ECP's power toggle
|
||||
/* Volume: the same names Harley's own web remote posts to /keypress/. They only
|
||||
do something on a Roku TV (the TV's volume keys), which is what this is. */
|
||||
case ROKU_VOLUP: return "VolumeUp";
|
||||
case ROKU_VOLDOWN: return "VolumeDown";
|
||||
case ROKU_VOLMUTE: return "VolumeMute";
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ public class Theme
|
||||
// Key colors
|
||||
public final int colorKey;
|
||||
public final int colorKeyActivated;
|
||||
public final int colorKeyAction;
|
||||
public final int colorKeySpaceBar;
|
||||
|
||||
// Label colors
|
||||
public final int lockedColor;
|
||||
@@ -21,11 +23,22 @@ public class Theme
|
||||
public final int subLabelColor;
|
||||
public final int secondaryLabelColor;
|
||||
public final int greyedLabelColor;
|
||||
/** Label colour for the Roku page's direction keys (res/values/themes.xml). */
|
||||
public final int rokuArrowColor;
|
||||
/** The lights page's three colours (res/values/themes.xml): blue for a light that is on, pink
|
||||
for one that is off, and the grey that stands for a light nobody can see. The rule that maps
|
||||
a state to one of them is a single function, [LightsProxy.colorFor]; these are the values it
|
||||
is handed. */
|
||||
public final int lightOnColor;
|
||||
public final int lightOffColor;
|
||||
public final int lightStaleColor;
|
||||
|
||||
// Key borders
|
||||
public final float keyBorderRadius;
|
||||
public final float keyBorderWidth;
|
||||
public final float keyBorderWidthActivated;
|
||||
public final float keyBorderWidthAction;
|
||||
public final float keyBorderWidthSpaceBar;
|
||||
public final int keyBorderColorLeft;
|
||||
public final int keyBorderColorTop;
|
||||
public final int keyBorderColorRight;
|
||||
@@ -40,6 +53,8 @@ public class Theme
|
||||
TypedArray s = context.getTheme().obtainStyledAttributes(attrs, R.styleable.keyboard, 0, 0);
|
||||
colorKey = s.getColor(R.styleable.keyboard_colorKey, 0);
|
||||
colorKeyActivated = s.getColor(R.styleable.keyboard_colorKeyActivated, 0);
|
||||
colorKeyAction = s.getColor(R.styleable.keyboard_colorKeyAction, colorKey);
|
||||
colorKeySpaceBar = s.getColor(R.styleable.keyboard_colorKeySpaceBar, colorKey);
|
||||
// colorKeyboard = s.getColor(R.styleable.keyboard_colorKeyboard, 0);
|
||||
colorNavBar = s.getColor(R.styleable.keyboard_navigationBarColor, 0);
|
||||
isLightNavBar = s.getBoolean(R.styleable.keyboard_windowLightNavigationBar, false);
|
||||
@@ -52,9 +67,15 @@ public class Theme
|
||||
s.getFloat(R.styleable.keyboard_secondaryDimming, 0.25f));
|
||||
greyedLabelColor = adjustLight(labelColor,
|
||||
s.getFloat(R.styleable.keyboard_greyedDimming, 0.5f));
|
||||
rokuArrowColor = s.getColor(R.styleable.keyboard_colorRokuArrow, labelColor);
|
||||
lightOnColor = s.getColor(R.styleable.keyboard_colorLightOn, rokuArrowColor);
|
||||
lightOffColor = s.getColor(R.styleable.keyboard_colorLightOff, 0xFFFF2D95);
|
||||
lightStaleColor = s.getColor(R.styleable.keyboard_colorLightStale, greyedLabelColor);
|
||||
keyBorderRadius = s.getDimension(R.styleable.keyboard_keyBorderRadius, 0);
|
||||
keyBorderWidth = s.getDimension(R.styleable.keyboard_keyBorderWidth, 0);
|
||||
keyBorderWidthActivated = s.getDimension(R.styleable.keyboard_keyBorderWidthActivated, 0);
|
||||
keyBorderWidthAction = s.getDimension(R.styleable.keyboard_keyBorderWidthAction, 0);
|
||||
keyBorderWidthSpaceBar = s.getDimension(R.styleable.keyboard_keyBorderWidthSpaceBar, 0);
|
||||
keyBorderColorLeft = s.getColor(R.styleable.keyboard_keyBorderColorLeft, colorKey);
|
||||
keyBorderColorTop = s.getColor(R.styleable.keyboard_keyBorderColorTop, colorKey);
|
||||
keyBorderColorRight = s.getColor(R.styleable.keyboard_keyBorderColorRight, colorKey);
|
||||
@@ -63,7 +84,7 @@ public class Theme
|
||||
}
|
||||
|
||||
/** Interpolate the 'value' component toward its opposite by 'alpha'. */
|
||||
int adjustLight(int color, float alpha)
|
||||
static int adjustLight(int color, float alpha)
|
||||
{
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
@@ -101,6 +122,9 @@ public class Theme
|
||||
|
||||
public final Key key;
|
||||
public final Key key_activated;
|
||||
public final Key key_action;
|
||||
public final Key key_space_bar;
|
||||
public final Key key_suggestion;
|
||||
|
||||
public Computed(Theme theme, Config config, float keyWidth, KeyboardData layout)
|
||||
{
|
||||
@@ -114,8 +138,11 @@ public class Theme
|
||||
// added on the right and on the bottom of every keys.
|
||||
margin_top = config.marginTop + vertical_margin / 2;
|
||||
margin_left = horizontal_margin / 2;
|
||||
key = new Key(theme, config, keyWidth, false);
|
||||
key_activated = new Key(theme, config, keyWidth, true);
|
||||
key = new Key(theme, config, keyWidth, false, KeyboardData.Key.Role.Normal);
|
||||
key_action = new Key(theme, config, keyWidth, false, KeyboardData.Key.Role.Action);
|
||||
key_space_bar = new Key(theme, config, keyWidth, false, KeyboardData.Key.Role.Space_bar);
|
||||
key_activated = new Key(theme, config, keyWidth, true, KeyboardData.Key.Role.Normal);
|
||||
key_suggestion = new Key(theme, config, keyWidth, false, KeyboardData.Key.Role.Suggestion);
|
||||
indication_paint = init_label_paint(config, null);
|
||||
indication_paint.setColor(theme.subLabelColor);
|
||||
}
|
||||
@@ -135,20 +162,41 @@ public class Theme
|
||||
final Paint _special_sublabel_paint;
|
||||
final int _label_alpha_bits;
|
||||
|
||||
public Key(Theme theme, Config config, float keyWidth, boolean activated)
|
||||
public Key(Theme theme, Config config, float keyWidth, boolean activated,
|
||||
KeyboardData.Key.Role role)
|
||||
{
|
||||
bg_paint.setColor(activated ? theme.colorKeyActivated : theme.colorKey);
|
||||
if (config.borderConfig)
|
||||
border_radius = config.borderConfig ? config.customBorderRadius * keyWidth : theme.keyBorderRadius;
|
||||
int bg_color;
|
||||
if (activated)
|
||||
{
|
||||
border_radius = config.customBorderRadius * keyWidth;
|
||||
border_width = config.customBorderLineWidth;
|
||||
bg_color = theme.colorKeyActivated;
|
||||
border_width = theme.keyBorderWidthActivated;
|
||||
bg_paint.setAlpha(config.keyActivatedOpacity);
|
||||
}
|
||||
else
|
||||
{
|
||||
border_radius = theme.keyBorderRadius;
|
||||
border_width = activated ? theme.keyBorderWidthActivated : theme.keyBorderWidth;
|
||||
switch (role)
|
||||
{
|
||||
case Action:
|
||||
bg_color = theme.colorKeyAction;
|
||||
border_width = theme.keyBorderWidthAction;
|
||||
break;
|
||||
case Space_bar:
|
||||
bg_color = theme.colorKeySpaceBar;
|
||||
border_width = theme.keyBorderWidthSpaceBar;
|
||||
break;
|
||||
case Suggestion:
|
||||
bg_color = 0;
|
||||
border_width = 0;
|
||||
break;
|
||||
default:
|
||||
bg_color = theme.colorKey;
|
||||
border_width = config.borderConfig ? config.customBorderLineWidth : theme.keyBorderWidth;
|
||||
break;
|
||||
}
|
||||
bg_paint.setAlpha(config.keyOpacity);
|
||||
}
|
||||
bg_paint.setAlpha(activated ? config.keyActivatedOpacity : config.keyOpacity);
|
||||
bg_paint.setColor(bg_color);
|
||||
border_left_paint = init_border_paint(config, border_width, theme.keyBorderColorLeft);
|
||||
border_top_paint = init_border_paint(config, border_width, theme.keyBorderColorTop);
|
||||
border_right_paint = init_border_paint(config, border_width, theme.keyBorderColorRight);
|
||||
|
||||
@@ -0,0 +1,316 @@
|
||||
package juloo.keyboard2;
|
||||
|
||||
import android.graphics.Color;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/** Data and rendering logic for the display-only usage gauge. */
|
||||
public final class UsageGauge
|
||||
{
|
||||
// The layout stores this marker in 'indication', so it identifies the key
|
||||
// without adding a character to the generated compose table.
|
||||
public static final String KEY_MARKER = "usage_gauge";
|
||||
/** Long-pressing the gauge key opens this in the browser. */
|
||||
public static final String USAGE_PAGE_URL = "https://platform.deepseek.com/usage";
|
||||
public static final long REFRESH_AFTER_MS = 5 * 60 * 1000L;
|
||||
// The sampler publishes every 15 minutes, so one missed tick must not read as stale: three
|
||||
// do. A threshold equal to the interval makes the gauge blink to '--' on every cycle.
|
||||
public static final long STALE_AFTER_MS = 45 * 60 * 1000L;
|
||||
|
||||
public static final class Reading
|
||||
{
|
||||
public final double h5Pct;
|
||||
public final double weeklyPct;
|
||||
public final double spentTodayUsd;
|
||||
public final double balance;
|
||||
/** True when the server's spend window opened mid-day: the total is a floor, not the day. */
|
||||
public final boolean partial;
|
||||
/** True when the server says the reading it sent is too old to present as current. */
|
||||
public final boolean serverStale;
|
||||
|
||||
Reading(double h5, double weekly, double spent, double balance_)
|
||||
{
|
||||
this(h5, weekly, spent, balance_, false, false);
|
||||
}
|
||||
|
||||
Reading(double h5, double weekly, double spent, double balance_, boolean partial_,
|
||||
boolean serverStale_)
|
||||
{
|
||||
h5Pct = h5;
|
||||
weeklyPct = weekly;
|
||||
spentTodayUsd = spent;
|
||||
balance = balance_;
|
||||
partial = partial_;
|
||||
serverStale = serverStale_;
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile Reading _cached;
|
||||
private static volatile long _cachedAt;
|
||||
private static volatile boolean _failed;
|
||||
private static boolean _inFlight;
|
||||
|
||||
private UsageGauge() {}
|
||||
|
||||
public static boolean isGaugeKey(KeyboardData.Key key)
|
||||
{
|
||||
return key != null && KEY_MARKER.equals(key.indication);
|
||||
}
|
||||
|
||||
/** Returns null when any value needed for a trustworthy display is absent or invalid. */
|
||||
public static Reading parse(String json)
|
||||
{
|
||||
try
|
||||
{
|
||||
JSONObject root = new JSONObject(json);
|
||||
JSONObject codex = root.getJSONObject("codex");
|
||||
JSONObject deepseek = root.getJSONObject("deepseek");
|
||||
double h5 = requiredNumber(codex.getJSONObject("h5"), "pct");
|
||||
double weekly = requiredNumber(codex.getJSONObject("weekly"), "pct");
|
||||
double spent = requiredNumber(deepseek, "spent_today_usd");
|
||||
double balance = requiredNumber(deepseek, "balance");
|
||||
if (!finite(h5) || !finite(weekly) || !finite(spent) || !finite(balance)
|
||||
|| h5 < 0 || weekly < 0 || spent < 0)
|
||||
return null;
|
||||
boolean partial = deepseek.optBoolean("partial", false);
|
||||
boolean serverStale = codex.optBoolean("stale", false)
|
||||
|| deepseek.optBoolean("stale", false);
|
||||
return new Reading(h5, weekly, spent, balance, partial, serverStale);
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
// The local JVM test runner replaces Android's org.json methods with
|
||||
// throwing stubs. Keep the same defensive behavior testable there.
|
||||
return parseJsonFallback(json);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Reading parseJsonFallback(String json)
|
||||
{
|
||||
try
|
||||
{
|
||||
String codex = objectForKey(json, "codex");
|
||||
String deepseek = objectForKey(json, "deepseek");
|
||||
double h5 = numberForKey(objectForKey(codex, "h5"), "pct");
|
||||
double weekly = numberForKey(objectForKey(codex, "weekly"), "pct");
|
||||
double spent = numberForKey(deepseek, "spent_today_usd");
|
||||
double balance = numberForKey(deepseek, "balance");
|
||||
if (!finite(h5) || !finite(weekly) || !finite(spent) || !finite(balance)
|
||||
|| h5 < 0 || weekly < 0 || spent < 0)
|
||||
return null;
|
||||
boolean partial = booleanForKey(deepseek, "partial");
|
||||
boolean serverStale = booleanForKey(codex, "stale") || booleanForKey(deepseek, "stale");
|
||||
return new Reading(h5, weekly, spent, balance, partial, serverStale);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String objectForKey(String json, String key) throws Exception
|
||||
{
|
||||
Matcher matcher = Pattern.compile("\\\"" + Pattern.quote(key)
|
||||
+ "\\\"\\s*:\\s*\\{").matcher(json);
|
||||
if (!matcher.find())
|
||||
throw new Exception("Missing object " + key);
|
||||
int start = matcher.end() - 1;
|
||||
int depth = 0;
|
||||
boolean quoted = false;
|
||||
boolean escaped = false;
|
||||
for (int i = start; i < json.length(); i++)
|
||||
{
|
||||
char c = json.charAt(i);
|
||||
if (quoted)
|
||||
{
|
||||
if (escaped) escaped = false;
|
||||
else if (c == '\\') escaped = true;
|
||||
else if (c == '"') quoted = false;
|
||||
}
|
||||
else if (c == '"') quoted = true;
|
||||
else if (c == '{') depth++;
|
||||
else if (c == '}' && --depth == 0)
|
||||
return json.substring(start, i + 1);
|
||||
}
|
||||
throw new Exception("Unclosed object " + key);
|
||||
}
|
||||
|
||||
private static double numberForKey(String json, String key) throws Exception
|
||||
{
|
||||
Matcher matcher = Pattern.compile("\\\"" + Pattern.quote(key)
|
||||
+ "\\\"\\s*:\\s*(-?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][+-]?[0-9]+)?)")
|
||||
.matcher(json);
|
||||
if (!matcher.find())
|
||||
throw new Exception("Missing numeric field " + key);
|
||||
return Double.parseDouble(matcher.group(1));
|
||||
}
|
||||
|
||||
/** Only a literal true counts: an absent or malformed flag must never claim confidence. */
|
||||
private static boolean booleanForKey(String json, String key)
|
||||
{
|
||||
try
|
||||
{
|
||||
int at = json.indexOf("\"" + key + "\"");
|
||||
if (at < 0)
|
||||
return false;
|
||||
int colon = json.indexOf(':', at);
|
||||
if (colon < 0)
|
||||
return false;
|
||||
int i = colon + 1;
|
||||
while (i < json.length() && Character.isWhitespace(json.charAt(i)))
|
||||
i++;
|
||||
return json.startsWith("true", i);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static double requiredNumber(JSONObject object, String key) throws Exception
|
||||
{
|
||||
Object value = object.get(key);
|
||||
if (!(value instanceof Number))
|
||||
throw new Exception("Missing numeric field " + key);
|
||||
return ((Number)value).doubleValue();
|
||||
}
|
||||
|
||||
private static boolean finite(double value)
|
||||
{
|
||||
return !Double.isNaN(value) && !Double.isInfinite(value);
|
||||
}
|
||||
|
||||
public static float fillFraction(Reading reading)
|
||||
{
|
||||
if (reading == null)
|
||||
return 0;
|
||||
return (float)(Math.max(0, Math.min(100,
|
||||
Math.max(reading.h5Pct, reading.weeklyPct))) / 100.0);
|
||||
}
|
||||
|
||||
public static boolean isStale(long fetchedAt, long now, boolean failed,
|
||||
String token)
|
||||
{
|
||||
return token == null || token.trim().isEmpty() || failed || fetchedAt <= 0
|
||||
|| now < fetchedAt || now - fetchedAt > STALE_AFTER_MS;
|
||||
}
|
||||
|
||||
public static boolean isLowBalance(Reading reading)
|
||||
{
|
||||
// $1.00 or less is low: the balance sitting exactly on the threshold is
|
||||
// already worth flagging, and the API reports it to two decimals so a
|
||||
// strict < would make "1.00" indistinguishable from "just topped up"
|
||||
// for as long as the balance happens to rest on the dollar.
|
||||
return reading == null || reading.balance <= 1.00;
|
||||
}
|
||||
|
||||
public static synchronized void fetchIfNeeded(String url, String token,
|
||||
Runnable onComplete)
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
if (token == null || token.trim().isEmpty() || _inFlight
|
||||
|| (_cached != null && now - _cachedAt <= REFRESH_AFTER_MS))
|
||||
return;
|
||||
_inFlight = true;
|
||||
Thread worker = new Thread(() -> {
|
||||
Reading reading = fetch(url, token);
|
||||
synchronized (UsageGauge.class)
|
||||
{
|
||||
// A reading the server itself flags as too old is as unusable as a failed fetch:
|
||||
// presenting it as current is the exact lie the gauge is built to avoid.
|
||||
if (reading == null || reading.serverStale)
|
||||
_failed = true;
|
||||
else
|
||||
{
|
||||
_cached = reading;
|
||||
_cachedAt = System.currentTimeMillis();
|
||||
_failed = false;
|
||||
}
|
||||
_inFlight = false;
|
||||
}
|
||||
if (onComplete != null)
|
||||
onComplete.run();
|
||||
}, "UsageGauge");
|
||||
worker.setDaemon(true);
|
||||
worker.start();
|
||||
}
|
||||
|
||||
private static Reading fetch(String url, String token)
|
||||
{
|
||||
HttpURLConnection connection = null;
|
||||
try
|
||||
{
|
||||
connection = (HttpURLConnection)new URL(url).openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setConnectTimeout(3000);
|
||||
connection.setReadTimeout(5000);
|
||||
connection.setRequestProperty("Authorization", "Bearer " + token);
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK)
|
||||
return null;
|
||||
try (InputStream input = connection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(input,
|
||||
StandardCharsets.UTF_8)))
|
||||
{
|
||||
StringBuilder body = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
body.append(line);
|
||||
return parse(body.toString());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (connection != null)
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public static Reading cachedReading()
|
||||
{
|
||||
return _cached;
|
||||
}
|
||||
|
||||
public static boolean isStaleNow(String token)
|
||||
{
|
||||
return isStale(_cachedAt, System.currentTimeMillis(), _failed, token);
|
||||
}
|
||||
|
||||
public static long cachedAt()
|
||||
{
|
||||
return _cachedAt;
|
||||
}
|
||||
|
||||
public static int hueColor(float fraction)
|
||||
{
|
||||
float level = Math.max(0, Math.min(1, fraction));
|
||||
if (level < 0.5f)
|
||||
// Low usage borrows the space bar button's own colour rather than a hand-matched shade, so
|
||||
// the gauge and the button can never drift apart. Amber and red still mark high usage: the
|
||||
// height carries the level, the colour carries the alarm.
|
||||
return blend(DeepSeekPeak.colorFor(System.currentTimeMillis()), Color.rgb(245, 178, 45), level * 2);
|
||||
return blend(Color.rgb(245, 178, 45), Color.rgb(235, 55, 55), (level - 0.5f) * 2);
|
||||
}
|
||||
|
||||
private static int blend(int a, int b, float t)
|
||||
{
|
||||
return Color.rgb((int)(Color.red(a) + (Color.red(b) - Color.red(a)) * t),
|
||||
(int)(Color.green(a) + (Color.green(b) - Color.green(a)) * t),
|
||||
(int)(Color.blue(a) + (Color.blue(b) - Color.blue(a)) * t));
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class CandidatesView extends LinearLayout
|
||||
}
|
||||
}
|
||||
|
||||
public void clear_candidates()
|
||||
void clear_candidates()
|
||||
{
|
||||
for (int i = 0; i < _item_views.length; i++)
|
||||
{
|
||||
@@ -101,10 +101,10 @@ public class CandidatesView extends LinearLayout
|
||||
float row_height = config.keyboard_rows_height_pixels * (1 - config.key_vertical_margin);
|
||||
ViewGroup.MarginLayoutParams p =
|
||||
(ViewGroup.MarginLayoutParams)getLayoutParams();
|
||||
p.height = (int)row_height;
|
||||
p.height = (int)(row_height * 0.637f);
|
||||
setLayoutParams(p);
|
||||
// Match the size of labels on the keyboard.
|
||||
float text_size = row_height * config.characterSize * config.labelTextSize;
|
||||
float text_size = row_height * config.characterSize * config.labelTextSize * 0.85f;
|
||||
for (int i = 0; i < NUM_CANDIDATES; i++)
|
||||
{
|
||||
TextView v = _item_views[i];
|
||||
|
||||
@@ -45,13 +45,14 @@ public final class Suggestions
|
||||
clear();
|
||||
else
|
||||
query_suggestions(word);
|
||||
set_suggestions();
|
||||
_callback.set_suggestions(this);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
count = 0;
|
||||
suggestions[0] = null;
|
||||
for (int i = 0; i < MAX_COUNT; i++)
|
||||
suggestions[i] = null;
|
||||
emoji_suggestion = null;
|
||||
}
|
||||
|
||||
@@ -120,11 +121,6 @@ public final class Suggestions
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
void set_suggestions()
|
||||
{
|
||||
_callback.set_suggestions(this);
|
||||
}
|
||||
|
||||
static final int[] NO_RESULTS = new int[0];
|
||||
|
||||
public static interface Callback
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
<key key0="ز" key3="."/>
|
||||
<key key0="ظ" key3="؟"/>
|
||||
<key key0="د"/>
|
||||
<key width="1.0" key0="backspace" key2="delete"/>
|
||||
<key width="1.0" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -37,6 +37,6 @@
|
||||
<key key0="و" key1="ۋ" key4="ۊ"/>
|
||||
<key key0="چ"/>
|
||||
<key key0="ٚ" key1="ٛ"/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -39,6 +39,6 @@
|
||||
<key key0="و" key1=","/>
|
||||
<key key0="ز" key1="."/>
|
||||
<key key0="ظ" key1="؟"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -34,6 +34,6 @@
|
||||
<key key0="ب" key1="ٮ" />
|
||||
<key key0="ن" key2="،" key3="؛"/>
|
||||
<key key0="م" key2="." key3=":" />
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -39,6 +39,6 @@
|
||||
<key key0="و" key1=","/>
|
||||
<key key0="ز" key1="."/>
|
||||
<key key0="ظ" key1="؟"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -36,6 +36,6 @@
|
||||
<key key0="پ" key2="؟"/>
|
||||
<key key0="و"/>
|
||||
<key key0="چ"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<key key0="պ" key4=":"/>
|
||||
</row>
|
||||
<row>
|
||||
<key key0="shift" key2="loc capslock"/>
|
||||
<key role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="դ"/>
|
||||
<key key0="չ"/>
|
||||
<key key0="յ"/>
|
||||
@@ -46,6 +46,6 @@
|
||||
<key key0="ք"/>
|
||||
<key key0="խ"/>
|
||||
<key key0="շ" key4="."/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<key key0="ե" key2="և" key4=":"/>
|
||||
</row>
|
||||
<row>
|
||||
<key key0="shift" key2="loc capslock"/>
|
||||
<key role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="ց"/>
|
||||
<key key0="զ"/>
|
||||
<key key0="չ"/>
|
||||
@@ -46,6 +46,6 @@
|
||||
<key key0="ն"/>
|
||||
<key key0="մ"/>
|
||||
<key key0="շ" key4="."/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
</keyboard>
|
||||
|
||||
@@ -35,6 +35,6 @@
|
||||
<key c="," sw="ষ" ne="("/>
|
||||
<key c="." sw="।" ne=")"/>
|
||||
<key c="য়" sw="য"/>
|
||||
<key width="1.5" c="backspace" ne="delete"/>
|
||||
<key role="action" width="1.5" c="backspace" ne="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<key key0="দ" key1="_" key2="ধ" key3="(" key4=")"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.4" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.4" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key shift="0.1" key0="্র" key2="্য" key3="\#" key4="*"/>
|
||||
<key key0="ো" key1="ৌ" key2="ও" key3="ঔ" key4="\@"/>
|
||||
<key key0="ে" key1="ৈ" key2="এ" key3="ঐ" key4="%"/>
|
||||
@@ -32,6 +32,6 @@
|
||||
<key key0="ন" key1="৳" key2="ণ" key3=";" key4="."/>
|
||||
<key key0="স" key1=""" key2="ষ" key3="!" key4=","/>
|
||||
<key key0="ম" key1="'" key2="শ" key3="\?" key4="।"/>
|
||||
<key shift="0.1" width="1.4" key0="backspace" key2="delete"/>
|
||||
<key shift="0.1" width="1.4" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<key key0="ল" key1="ং" key2="॥" key3="halfspace" />
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" />
|
||||
<key width="1.5" role="action" key0="shift" />
|
||||
<key key0="য়" key1="য" />
|
||||
<key key0="শ" key1="ঢ়" />
|
||||
<key key0="চ" key1="ছ" key2="ৃ" key3="," />
|
||||
@@ -32,6 +32,6 @@
|
||||
<key key0="ব" key1="ভ" key2="\?" key3="্" />
|
||||
<key key0="ন" key1="ণ" key2=":" key3=";" />
|
||||
<key key0="ম" key1="ঙ" key2=""" key3="'" />
|
||||
<key width="1.5" key0="backspace" key2="delete" />
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete" />
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key key0="п" key2="|" key3="\\"/>
|
||||
</row>
|
||||
<row>
|
||||
<key key0="shift" key2="loc capslock"/>
|
||||
<key role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="я"/>
|
||||
<key key0="ч"/>
|
||||
<key key0="ё" key1="е"/>
|
||||
@@ -37,6 +37,6 @@
|
||||
<key key0="т" key1="₮" key2="\?" key3="/"/>
|
||||
<key key0="ь" key1="ъ" key2=":" key3=";"/>
|
||||
<key key0="в" key1="ю" key2=""" key3="'"/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key key0="ѣ" key1="ԑ" key2="/" key3="\\" key4="|" />
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.18" key0="shift" key2="loc capslock" key3="loc tab" key4="loc esc"
|
||||
<key role="action" width="1.18" key0="shift" key2="loc capslock" key3="loc tab" key4="loc esc"
|
||||
/>
|
||||
<key width="0.96" key0="я" key1="ꙗ" key2="ꙝ" key4="combining_titlo" />
|
||||
<key width="0.96" key0="ч" key1="ћ" key2="ќ" key4="combining_breve" />
|
||||
@@ -38,6 +38,6 @@
|
||||
<key width="0.96" key0="ь" key1="ѧ" key2="<" key3="⁙" />
|
||||
<key width="0.96" key0="б" key1="ђ" key2=">" key3="⁘" />
|
||||
<key width="0.96" key0="ю" key1="ꙛ" key2="·" key3="⁖"/>
|
||||
<key width="1.18" key0="backspace" key2="delete"/>
|
||||
<key role="action" width="1.18" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<key key0="э" key2="|" key3="\\"/>
|
||||
</row>
|
||||
<row>
|
||||
<key key0="shift" key2="loc capslock"/>
|
||||
<key role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="я"/>
|
||||
<key key0="ч"/>
|
||||
<key key0="с"/>
|
||||
@@ -50,6 +50,6 @@
|
||||
<key key0="ь" key2="\?" key3="/"/>
|
||||
<key key0="б" key2=":" key3=";"/>
|
||||
<key key0="ю" key2=""" key3="'"/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key key0="э" key2="|" key3="\\"/>
|
||||
</row>
|
||||
<row scale="11">
|
||||
<key width="1.22" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.22" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="я"/>
|
||||
<key key0="ч"/>
|
||||
<key key0="с"/>
|
||||
@@ -37,6 +37,6 @@
|
||||
<key key0="ь" key1="ъ" key2="\?" key3="/"/>
|
||||
<key key0="б" key2=":" key3=";"/>
|
||||
<key key0="ю" key2=""" key3="'"/>
|
||||
<key width="1.22" key0="backspace" key2="delete"/>
|
||||
<key width="1.22" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key key0="є" key2="|" key3="\\"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.1" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.1" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="я"/>
|
||||
<key key0="ч" />
|
||||
<key key0="с" />
|
||||
@@ -37,6 +37,6 @@
|
||||
<key key0="ь" key2=":" key3=";"/>
|
||||
<key key0="б" key2=""" key3="'"/>
|
||||
<key key0="ю" key1="«" key2="»"/>
|
||||
<key width="1.1" key0="backspace" key2="delete"/>
|
||||
<key width="1.1" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<key key0="ж" key2=")" key3="("/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key role="action" width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key key0="я"/>
|
||||
<key key0="ч"/>
|
||||
<key key0="ѣ"/>
|
||||
@@ -40,6 +40,6 @@
|
||||
<key key0="ь"/>
|
||||
<key key0="б" key2="«"/>
|
||||
<key key0="ю" key2="»"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key role="action" width="1.5" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key key0="ќ" key2="=" key3="+"/>
|
||||
</row>
|
||||
<row scale="11">
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key role="action" width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key key0="з"/>
|
||||
<key key0="џ"/>
|
||||
<key key0="ц"/>
|
||||
@@ -37,7 +37,7 @@
|
||||
<key key0="м" key2=":" key3=";"/>
|
||||
<key key0="ѓ" key2="`" key3="'"/>
|
||||
<key key0="ж" key2="“" key3="„"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key role="action" width="1.5" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<key key0="ћ" ne="`" sw="|"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" nw="loc superscript" ne="loc capslock" sw="loc subscript"/>
|
||||
<key width="1.5" role="action" key0="shift" nw="loc superscript" ne="loc capslock" sw="loc subscript"/>
|
||||
<key key0="ж" nw="loc undo" ne="loc redo" sw="<" se=">"/>
|
||||
<key key0="џ" ne="loc cut"/>
|
||||
<key key0="ц" ne="loc copy"/>
|
||||
@@ -71,6 +71,6 @@
|
||||
<key key0="н" nw="!" ne="\?" sw="/"/>
|
||||
<key key0="м" ne=";" sw=","/>
|
||||
<key key0="ђ" ne=":" sw="."/>
|
||||
<key width="1.5" key0="backspace" ne="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" ne="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key key0="ч" key1="„" key2="“"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.5" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="ю"/>
|
||||
<key key0="й"/>
|
||||
<key key0="ъ" key1="loc accent_cedille" key2="<" key4=">"/>
|
||||
@@ -36,6 +36,6 @@
|
||||
<key key0="п" key2=""" key3="'"/>
|
||||
<key key0="р" key3=","/>
|
||||
<key key0="л" key3="."/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<key key0="л" key1="щ" key2="|" key3="\\" key4="ю"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.5" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="з"/>
|
||||
<key key0="ь" key3="ѝ"/>
|
||||
<key key0="ц" key2="<" key3="."/>
|
||||
@@ -32,6 +32,6 @@
|
||||
<key key0="б" key2="\?" key3="/"/>
|
||||
<key key0="н" key2=":" key3=";"/>
|
||||
<key key0="м" key2=""" key3="'"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<key key0="щ" key2="/" key3="\\"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="2" key0="shift" key2="loc capslock"/>
|
||||
<key role="action" width="2" key0="shift" key2="loc capslock"/>
|
||||
<key key0="э"/>
|
||||
<key key0="з"/>
|
||||
<key key0="ь" key1="ъ"/>
|
||||
@@ -37,6 +37,6 @@
|
||||
<key key0="б"/>
|
||||
<key key0="н" key2="«" key3=","/>
|
||||
<key key0="м" key2="»" key3="."/>
|
||||
<key width="2" key0="backspace" key2="delete"/>
|
||||
<key role="action" width="2" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key key0="э" key7="\?" key3="/" />
|
||||
</row>
|
||||
<row scale="11">
|
||||
<key width="1.22" key0="shift" key2="loc capslock" />
|
||||
<key width="1.22" role="action" key0="shift" key2="loc capslock" />
|
||||
<key key0="я" key7="`" key8=";" />
|
||||
<key key0="ч" key7="*" key8=":" />
|
||||
<key key0="с" key7="&" key8="\#" />
|
||||
@@ -37,6 +37,6 @@
|
||||
<key key0="ӣ" key3="<" key2=">" />
|
||||
<key key0="б" key7="ъ" key8="ы" />
|
||||
<key key0="ю" key7=""" key8="'"/>
|
||||
<key width="1.22" key0="." key7="," />
|
||||
<key width="1.22" role="action" key0="." key7="," />
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<key key0="э" key7="/" key8="|" />
|
||||
</row>
|
||||
<row scale="11">
|
||||
<key width="1.22" key0="shift" />
|
||||
<key width="1.22" role="action" key0="shift" />
|
||||
<key key0="ꙗ" key7="combining_breve" key8=";" />
|
||||
<key key0="ч" key7="combining_pokrytie" key8=":" />
|
||||
<key key0="с" key7="combining_inverted_breve" key8="`" />
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
<key c="ं" nw="ॐ" ne="।" sw="ः" se=""" anticircle="१" indication="१"/>
|
||||
<key c="्" nw="," ne=";" sw="!" se="\?" anticircle="२" indication="२"/>
|
||||
<key c="़" nw="॰" sw="-" se="॒" anticircle="३" indication="३"/>
|
||||
<key width="2" c="backspace" ne="delete"/>
|
||||
<key width="2" role="action" c="backspace" ne="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<key key0="त" key1="थ" key2="ख़" key3="(" key4=")"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.4" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.4" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key shift="0.1" key0="ट" key1="ठ" key2="ड़" key3="\#" key4="*"/>
|
||||
<key key0="ं" key1="ँ" key3="ॐ" key4="\@"/>
|
||||
<key key0="म" key1="ण" key2="य" key3="य़" key4="%"/>
|
||||
@@ -32,6 +32,6 @@
|
||||
<key key0="व" key2="ढ़" key3=";" key4="."/>
|
||||
<key key0="ल" key1="ळ" key2="फ़" key3="!" key4=","/>
|
||||
<key key0="स" key1="श" key2="ष" key3="\?"/>
|
||||
<key shift="0.1" width="1.4" key0="backspace" key2="delete"/>
|
||||
<key shift="0.1" width="1.4" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<key key0="ल" key1="ऌ" key2="।" key3 ="ॢ" key4="॥"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.5" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="ज्ञ" key2="|" key3="\\" key4="ऍ"/>
|
||||
<key key0="ष" key1="क्ष" key3 ="ॅ" key4="ॉ"/>
|
||||
<key key0="च" key2="<" key3=","/>
|
||||
@@ -37,6 +37,6 @@
|
||||
<key key0="ब" key2="\?" key3="/"/>
|
||||
<key key0="न" key1="ङ" key2=":" key3=";" key4="ऽ"/>
|
||||
<key key0="म" key1="ॐ" key2=""" key3="'" key4="ँ"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<key key0="ჩ" key1="ჭ"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.5" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="ზ" key1="ჵ"/>
|
||||
<key key0="ხ" key1="ჴ" key2="loc †"/>
|
||||
<key key0="ც" key2="<" key3="."/>
|
||||
@@ -38,6 +38,6 @@
|
||||
<key key0="მ" key2=""" key3="'"/>
|
||||
<key key0="ძ"/>
|
||||
<key key0="ჟ"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<key key0="ლ" key1="₾" key2="|" key3="\\"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.5" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="ზ" key1="ძ" key2="ჵ"/>
|
||||
<key key0="ხ" key2="ჴ" key3="loc †"/>
|
||||
<key key0="ც" key1="ჩ" key3="<" key4="."/>
|
||||
@@ -32,7 +32,7 @@
|
||||
<key key0="ბ" key2="\?" key3="/"/>
|
||||
<key key0="ნ" key1="ჼ" key2="`" key3=":" key4=";"/>
|
||||
<key key0="მ" key2=""" key3="'"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<key key0="accent_aigu" key1="accent_trema" key3="accent_grave"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.5" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="ζ"/>
|
||||
<key key0="χ"/>
|
||||
<key key0="ψ" key2="<" key3="."/>
|
||||
@@ -33,6 +33,6 @@
|
||||
<key key0="β" key2="\?" key3="/"/>
|
||||
<key key0="ν" key2=":"/>
|
||||
<key key0="μ" key2=""" key3="'"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<key key0="લ" key1="।" key2="|" key3="\\" key4="॥"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.5" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="ઞ" key1="જ્ઞ" key2="ૅ" key3="ઙ" key4="ઍ"/>
|
||||
<key key0="ષ" key1="ક્ષ" key2="ૉ" key3="઼" key4="ઑ"/>
|
||||
<key key0="ચ" key2="<" key3="."/>
|
||||
@@ -32,6 +32,6 @@
|
||||
<key key0="બ" key2="\?" key3="/"/>
|
||||
<key key0="ન" key2=":" key3=";"/>
|
||||
<key key0="મ" key1="ૐ" key2=""" key3="'" key4="॑" key6="ઽ"/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<key key0="ㅣ" key2="|" key3="\\"/>
|
||||
</row>
|
||||
<row>
|
||||
<key width="1.5" key0="shift" key2="loc capslock"/>
|
||||
<key width="1.5" role="action" key0="shift" key2="loc capslock"/>
|
||||
<key key0="ㅋ"/>
|
||||
<key key0="ㅌ" key1="ㄾ" key3="<" key4=">"/>
|
||||
<key key0="ㅊ" key3="."/>
|
||||
@@ -32,6 +32,6 @@
|
||||
<key key0="ㅠ" key1="ㅞ" key2="ㅝ" key3="/" key4="\?"/>
|
||||
<key key0="ㅜ" key2="ㅟ" key3=";" key4=":"/>
|
||||
<key key0="ㅡ" key2="ㅢ" key3="'" key4="""/>
|
||||
<key width="1.5" key0="backspace" key2="delete"/>
|
||||
<key width="1.5" role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<key key0="ן" key2="8" key3="*"/>
|
||||
<key key0="ם" key2="9" key3="b(" key4="lrm"/>
|
||||
<key key0="פ" key2="0" key3="b)" key4="rlm"/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
<row scale="11">
|
||||
<key key0="ש" key2="`" key1="loc tab" key3="sindot_placeholder" key4="shindot_placeholder" width="1.30"/>
|
||||
|
||||
@@ -35,6 +35,6 @@
|
||||
<key key0="מ" key1="blt" key2=","/>
|
||||
<key key0="צ" key1="bgt" key2="."/>
|
||||
<key key0="/" key1="\?"/>
|
||||
<key key0="backspace" key2="delete" width="1.333"/>
|
||||
<key role="action" key0="backspace" key2="delete" width="1.333"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
<key key0="।" key1="'" key2=""" key3="." key4="," key6="॥"/>
|
||||
<key key0="೦" key1=":" key2=";" key3="-" key4="_"/>
|
||||
<key key0="೫" key1="೧" key2="೩" key3="೭" key4="೯" key5="೪" key6="೬" key7="೨" key8="೮"/>
|
||||
<key key0="backspace" key2="delete"/>
|
||||
<key role="action" key0="backspace" key2="delete"/>
|
||||
</row>
|
||||
</keyboard>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user