Add keyboard-input button to the phone home screen

This commit is contained in:
James Babcock committed 2026-09-03 16:06:46 -07:00
1 parent 00dd546b1c
commit aef6194687
12 files changed
+574 -85

No files matched your search

+32 -2
View File
@@ -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<TextField>('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<TextField>('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) {