From aef6194687a3a8870cfcd24141cbd66e21957b5d Mon Sep 17 00:00:00 2001 From: James Babcock Date: Thu, 3 Sep 2026 16:06:46 -0700 Subject: [PATCH] Add keyboard-input button to the phone home screen --- .../src/main/res/drawable/ic_tab_keyboard.xml | 13 ++ CHANGELOG | 1 + app/app.css | 15 +- app/g2/dashboard-controller.ts | 50 ++++++ app/phone-ui/main-page.ts | 34 +++- app/phone-ui/main-page.xml | 26 +++ app/phone-ui/main-view-model.ts | 102 ++++++++++- app/phone-ui/remote-controls.xml | 21 ++- app/ui/shell/input-dialog.ts | 90 ++++++++++ app/ui/shell/keyboard-input.ts | 159 ++++++++++++++++++ app/ui/shell/shell.ts | 78 ++++++++- app/ui/shell/voice-input.ts | 70 ++------ 12 files changed, 574 insertions(+), 85 deletions(-) create mode 100644 App_Resources/Android/src/main/res/drawable/ic_tab_keyboard.xml create mode 100644 app/ui/shell/input-dialog.ts create mode 100644 app/ui/shell/keyboard-input.ts diff --git a/App_Resources/Android/src/main/res/drawable/ic_tab_keyboard.xml b/App_Resources/Android/src/main/res/drawable/ic_tab_keyboard.xml new file mode 100644 index 00000000..4e531df8 --- /dev/null +++ b/App_Resources/Android/src/main/res/drawable/ic_tab_keyboard.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/CHANGELOG b/CHANGELOG index 7c3535de..3ed1b5b0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ * Move some items from app context menus to the system context menu * Long-press now opens the system context menu and tap-then-hold the app context menu (games keep long-press as a move while playing) * Content beneath an open context menu is dimmed +* Add a keyboard-input button to the phone home screen * Navigate app: Location indicator rotates based on the compass * Navigate app: Darken the map background color diff --git a/app/app.css b/app/app.css index dd7b3f05..1d96f325 100644 --- a/app/app.css +++ b/app/app.css @@ -182,11 +182,12 @@ Button.-primary { background-color: #424242; color: #ffffff; } -/* The wakeword button at the tab bar's right edge: icon-only, narrower than - * the tabs, and never in the selected state (it isn't a tab). It is a - * button-styled GridLayout (Buttons can't hold images), so it borrows the - * .tab-button look and adds the elevation MaterialButtons get for free. */ -.tab-mic-button { +/* The wakeword and keyboard buttons at the tab bar's right edge: icon-only, + * narrower than the tabs, and never in the selected state (they aren't tabs). + * Each is a button-styled GridLayout (Buttons can't hold images), so it + * borrows the .tab-button look and adds the elevation MaterialButtons get for + * free. */ +.tab-icon-button { width: 56; /* The real MaterialButtons render 48dp tall inside a 60dp layout box (6dp * insets top and bottom); the margins and explicit height reproduce that. @@ -196,11 +197,11 @@ Button.-primary { margin: 6 2; android-elevation: 2; } -.tab-mic-icon { +.tab-icon { height: 20; tint-color: #333333; } -.ns-dark .tab-mic-icon { +.ns-dark .tab-icon { tint-color: #cccccc; } .ns-dark .tab-button { diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index cfddeca8..2028fde6 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -64,6 +64,7 @@ import { type InProcessAppOptions, type InProcessWindow } from "../ui/shell/in-p import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-apps-persistence"; import { appViewportRect, SIDEBAR_WIDTH, sidebarStripVisible, type WindowHeightMode } from "../ui/shell/geometry"; import { type LayerActions, type TextSettingsEditToggle } from "../ui/layers"; +import { type KeyboardInputSession } from "../ui/shell/keyboard-input"; import { assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, brightnessSetting, brightnessSettingToLevel, displayModeSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, verticalPositionSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings"; import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization"; import { @@ -102,6 +103,13 @@ export type DashboardSnapshot = { activeTextEditorToggleLabel: string; activeTextEditorToggleValue: boolean; activeTextEditorToggleVisible: boolean; + /** + * The keyboard dialog is up on the glasses (opened by the phone's keyboard + * button): the phone shows its typing panel, with a send button per + * destination in the glasses menu's row order. + */ + keyboardInputActive: boolean; + keyboardInputTargets: ReadonlyArray<{ id: string; label: string }>; evenAppConflictMessage: string; evenAppConflictWarningVisible: boolean; firmwareWarningMessage: string; @@ -274,6 +282,9 @@ class DashboardController { // The window hosting the on-glasses text-setting editor (the Settings app // registers itself); edit flows from the phone UI reach it through this. private textEditorHost: TextEditorHost | null = null; + // The open keyboard dialog's session (see Shell.startKeyboardInput); the + // phone's typing panel feeds it. + private keyboardInput: KeyboardInputSession | null = null; // Other in-process singleton apps, keyed by windowId. private readonly inProcessApps = new Map(); private sharedActions!: Omit; @@ -333,6 +344,10 @@ class DashboardController { getScreenTimeoutMs: () => screenTimeoutSettingToMs(screenTimeoutSetting.get()), requestShellRender: () => this.requestShellRender(), prepareVoiceCapture: () => this.prepareVoiceCapture(), + onKeyboardInputChanged: (session) => { + this.keyboardInput = session; + this.emit(); + }, onWindowsChanged: () => { this.persistOpenApps(); // The foreground title is mirrored on both remote-control faces. @@ -909,6 +924,8 @@ class DashboardController { activeTextEditorToggleLabel: this.activeTextEditorToggle?.label ?? "", activeTextEditorToggleValue: this.activeTextEditorToggle?.setting.get() ?? false, activeTextEditorToggleVisible: this.activeTextEditorToggle !== null, + keyboardInputActive: this.keyboardInput !== null, + keyboardInputTargets: this.keyboardInput?.targets ?? [], evenAppConflictMessage: this.evenAppConflictMessage, evenAppConflictWarningVisible: this.evenAppConflictMessage.length > 0, firmwareWarningMessage: this.firmwareWarningMessage, @@ -1045,6 +1062,39 @@ class DashboardController { this.previewOrRenderAfterTextSettingChange(); } + /** + * The phone's keyboard button: open the keyboard dialog on the glasses + * (the typed twin of the mic button's wakeword). Needs a display to draw + * on and, like ring input, does nothing while the glasses are locked. + */ + startKeyboardInput(): void { + if (this.phase !== "connected" && this.phase !== "charging" && !this.isPreviewDisplayActive()) return; + if (this.glassesLocked) { + this.appendLog("keyboard input ignored while the glasses are locked"); + return; + } + shell.startKeyboardInput(); + } + + /** The phone's typing panel changed: mirror the text on the glasses. */ + setKeyboardInputText(text: string): void { + shell.noteUserActivity(); + this.keyboardInput?.setText(text); + } + + /** Send to one destination, or (no id: the IME's send key) the one highlighted on the glasses. */ + sendKeyboardInput(targetId?: string): void { + if (targetId) { + this.keyboardInput?.sendTo(targetId); + } else { + this.keyboardInput?.send(); + } + } + + discardKeyboardInput(): void { + this.keyboardInput?.discard(); + } + setActiveTextEditorToggleValue(value: boolean): void { if (!this.activeTextEditorToggle || this.activeTextEditorToggle.setting.get() === value) return; this.activeTextEditorToggle.setting.set(value); diff --git a/app/phone-ui/main-page.ts b/app/phone-ui/main-page.ts index 4298a5e7..01ed68fe 100644 --- a/app/phone-ui/main-page.ts +++ b/app/phone-ui/main-page.ts @@ -39,7 +39,12 @@ function cleanupPage(page: Page): void { setPageState(page, undefined) } -function applySettingsTextFieldContrast(textField: TextField): void { +/** + * Readable colours for the light editor panels in both themes. selectAllOnFocus + * suits replacing an existing setting value; a message being composed keeps + * its caret where the user taps. + */ +function applySettingsTextFieldContrast(textField: TextField, selectAllOnFocus = true): void { textField.color = SETTINGS_TEXT_COLOR textField.backgroundColor = SETTINGS_BACKGROUND_COLOR textField.placeholderColor = SETTINGS_PLACEHOLDER_COLOR @@ -57,7 +62,7 @@ function applySettingsTextFieldContrast(textField: TextField): void { nativeTextField.setHintTextColor(android.graphics.Color.rgb(102, 102, 102)) // Editing an existing value usually means replacing it: select all on focus // so typing starts fresh but the current value stays visible. - nativeTextField.setSelectAllOnFocus(true) + nativeTextField.setSelectAllOnFocus(selectAllOnFocus) } /** @@ -83,6 +88,22 @@ function focusTextEditor(page: Page): void { }, 0) } +/** The keyboard dialog closed on the glasses (sent, discarded, or screen off). */ +function dismissKeyboardInputKeyboard(page: Page): void { + page.getViewById('keyboardInputField')?.dismissSoftInput() +} + +/** The keyboard dialog opened: bring up the IME on its field right away. */ +function focusKeyboardInput(page: Page): void { + setTimeout(() => { + const textField = page.getViewById('keyboardInputField') + if (textField) { + applySettingsTextFieldContrast(textField, false) + textField.focus() + } + }, 0) +} + export function loaded(args: EventData) { const page = args.object as Page cleanupPage(page) @@ -121,6 +142,12 @@ export function loaded(args: EventData) { } else { dismissTextEditorKeyboard(page) } + } else if (propertyArgs.propertyName === 'keyboardInputActive') { + if (model.keyboardInputActive) { + focusKeyboardInput(page) + } else { + dismissKeyboardInputKeyboard(page) + } } }, } @@ -131,6 +158,9 @@ export function loaded(args: EventData) { if (model.isTextSettingEditorActive) { focusTextEditor(page) } + if (model.keyboardInputActive) { + focusKeyboardInput(page) + } } export function unloaded(args: EventData) { diff --git a/app/phone-ui/main-page.xml b/app/phone-ui/main-page.xml index 9b8584fe..7ce43171 100644 --- a/app/phone-ui/main-page.xml +++ b/app/phone-ui/main-page.xml @@ -146,5 +146,31 @@ checkedChange="{{ onTextSettingToggleChange }}" /> + + +