forked from Blendman974/faceclaw
Make iOS app main screen match the Android UI
This commit is contained in:
1 parent
9f53847bb7
commit
6c3144cc31
30 files changed
+1013
-439
No files matched your search
+2
-134
@@ -1,5 +1,6 @@
|
||||
@import '@nativescript/theme/css/core.css';
|
||||
@import '@nativescript/theme/css/core.css';
|
||||
@import '@nativescript/theme/css/default.css';
|
||||
@import './phone-ui/remote-controls.css';
|
||||
|
||||
Page {
|
||||
background-color: #ffffff;
|
||||
@@ -171,139 +172,6 @@ Button.-primary {
|
||||
margin-bottom: 12;
|
||||
}
|
||||
|
||||
/* The phone's controller for the glasses (phone-ui/remote-controls.xml). */
|
||||
.remote-controls {
|
||||
margin: 0 8 0 8;
|
||||
}
|
||||
/* The Settings / Watch / Ring tab bar above the controls. */
|
||||
.controls-tab-bar {
|
||||
margin-bottom: 8;
|
||||
}
|
||||
.tab-button {
|
||||
font-size: 14;
|
||||
padding: 8 0;
|
||||
margin: 0 2;
|
||||
border-radius: 6;
|
||||
background-color: #e2e2e2;
|
||||
color: #333333;
|
||||
}
|
||||
.tab-button-selected {
|
||||
background-color: #424242;
|
||||
color: #ffffff;
|
||||
}
|
||||
/* 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.
|
||||
* The height also bounds the tile's measure, without which its star row
|
||||
* would collapse to content and pin the icon to the top. */
|
||||
height: 48;
|
||||
margin: 6 2;
|
||||
android-elevation: 2;
|
||||
}
|
||||
.tab-icon {
|
||||
height: 20;
|
||||
tint-color: #333333;
|
||||
}
|
||||
/* Landscape uses the full page height and a shared left edge for tabs/pad. */
|
||||
.landscape-layout .remote-controls {
|
||||
margin: 0;
|
||||
}
|
||||
.landscape-layout .controls-tab-bar {
|
||||
margin-bottom: 2;
|
||||
}
|
||||
.landscape-layout .tab-button {
|
||||
margin-left: 1;
|
||||
margin-right: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.landscape-layout .tab-button[col="0"] {
|
||||
margin-left: 0;
|
||||
}
|
||||
.landscape-layout .tab-icon-button {
|
||||
width: 48;
|
||||
}
|
||||
.landscape-layout .tab-icon-button[col="4"] {
|
||||
margin-right: 0;
|
||||
}
|
||||
.ns-dark .tab-icon {
|
||||
tint-color: #cccccc;
|
||||
}
|
||||
.ns-dark .tab-button {
|
||||
background-color: #333333;
|
||||
color: #cccccc;
|
||||
}
|
||||
.ns-dark .tab-button-selected {
|
||||
background-color: #e2e2e2;
|
||||
color: #222222;
|
||||
}
|
||||
/* Settings tab rows. */
|
||||
.settings-row {
|
||||
margin-bottom: 8;
|
||||
}
|
||||
.settings-row-label {
|
||||
font-size: 14;
|
||||
margin-right: 10;
|
||||
}
|
||||
.mode-button {
|
||||
font-size: 13;
|
||||
padding: 6 10;
|
||||
margin-right: 6;
|
||||
}
|
||||
.brightness-icon {
|
||||
font-size: 16;
|
||||
margin: 0 4 0 4;
|
||||
color: #444444;
|
||||
}
|
||||
.auto-toggle Label {
|
||||
font-size: 13;
|
||||
margin-right: 2;
|
||||
}
|
||||
.touchpad {
|
||||
height: 230;
|
||||
background-color: #1f1f1f;
|
||||
border-radius: 14;
|
||||
border-width: 1;
|
||||
border-color: #3a3a3a;
|
||||
color: #f0f0f0;
|
||||
margin-top: 2;
|
||||
}
|
||||
.pad-focus {
|
||||
font-size: 20;
|
||||
color: #ffffff;
|
||||
}
|
||||
.pad-legend {
|
||||
font-size: 11;
|
||||
color: #8a8a8a;
|
||||
margin-bottom: 8;
|
||||
}
|
||||
.action-row {
|
||||
margin-top: 6;
|
||||
}
|
||||
.action-button {
|
||||
margin: 2;
|
||||
font-size: 14;
|
||||
}
|
||||
/* Ring tab: the same touchpad, but portrait like the ring's own pad. */
|
||||
.ring-touchpad {
|
||||
width: 150;
|
||||
height: 250;
|
||||
}
|
||||
/* Cosmetic marks mirroring the six rectangles on the physical ring's touch
|
||||
strip; barely lighter than the pad so they read as texture, not buttons. */
|
||||
.ring-pad-marking {
|
||||
width: 18;
|
||||
height: 5;
|
||||
border-radius: 2;
|
||||
background-color: #2a2a2a;
|
||||
horizontal-align: center;
|
||||
vertical-align: center;
|
||||
}
|
||||
/*
|
||||
* Pairing scan list (phone-ui/pairing-page). Rows are Repeater items: product
|
||||
* art (or a colourway swatch) on the left, decoded SKU + proximity + serial in
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@import '@nativescript/theme/css/core.css';
|
||||
@import './phone-ui/remote-controls.css';
|
||||
|
||||
.pairing-instructions {
|
||||
color: #555555;
|
||||
@@ -159,3 +160,47 @@ Button {
|
||||
margin-right: 4;
|
||||
font-size: 15;
|
||||
}
|
||||
|
||||
|
||||
Page.main-page {
|
||||
background-color: #ffffff;
|
||||
color: #222222;
|
||||
}
|
||||
.main-page .main-header {
|
||||
background-color: #424242;
|
||||
color: #ffffff;
|
||||
padding: 0 0 0 16;
|
||||
height: 56;
|
||||
}
|
||||
.main-page .action-bar-title { font-size: 18; font-weight: bold; color: #ffffff; }
|
||||
.main-page .action-bar-status { font-size: 14; color: #ffffff; margin-right: 12; }
|
||||
.main-page .overflow-button {
|
||||
background-color: transparent;
|
||||
color: #ffffff;
|
||||
font-size: 24;
|
||||
width: 44;
|
||||
height: 48;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
/* Match Android's button layout boxes, including the inset around each tile. */
|
||||
.main-page Button.tab-button { height: 48; margin-top: 6; margin-bottom: 6; }
|
||||
.main-page .mode-button { background-color: #e2e2e2; color: #333333; border-radius: 6; }
|
||||
.main-page .ble-bandwidth-indicator { color: #777777; font-size: 12; padding: 2 8; }
|
||||
|
||||
.main-page .system-name-modal {
|
||||
background-color: #eeeeee;
|
||||
color: #222222;
|
||||
padding: 16;
|
||||
}
|
||||
.main-page .system-name-modal TextView {
|
||||
margin: 0;
|
||||
padding: 4;
|
||||
background-color: #ffffff;
|
||||
color: #222222;
|
||||
placeholder-color: #666666;
|
||||
}
|
||||
|
||||
.main-landscape .system-name-modal { padding: 6 12; }
|
||||
.main-landscape .system-name-modal .h2 { visibility: collapse; }
|
||||
.main-landscape .system-name-modal Button { padding: 6 8; margin-top: 0; margin-bottom: 0; }
|
||||
@@ -0,0 +1,8 @@
|
||||
import { bytes, concat, integer } from './ble-protocol'
|
||||
|
||||
/** Same G2SettingPackage as Kotlin BleProtocol.buildSetBrightness. */
|
||||
export function setBrightness(magic: number, level: number | null): Uint8Array {
|
||||
const fields = level === null ? integer(1, 1)
|
||||
: concat(integer(1, 0), integer(2, Math.max(0, Math.min(100, Math.round(level)))))
|
||||
return concat(integer(1, 1), integer(2, magic), bytes(3, bytes(1, fields)))
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { setBrightness } from './brightness-protocol'
|
||||
import { AncsClient, ANCS_FIRMWARE_VERSION } from './ancs-client'
|
||||
import { type CompassEvent } from '../native/compass-types'
|
||||
import * as protocol from './ble-protocol'
|
||||
@@ -423,6 +424,10 @@ export class GlassesSession {
|
||||
this.check(generation)
|
||||
await this.send('left', protocol.SID.settings, 0x20, queryWearState())
|
||||
}
|
||||
async setBrightness(level: number | null): Promise<void> {
|
||||
if (this.state.phase !== 'connected') return
|
||||
await this.request('right', protocol.SID.settings, magic => setBrightness(magic, level), 'Brightness')
|
||||
}
|
||||
setFrame(gray: Uint8Array): void {
|
||||
if (this.state.phase !== 'connected') return
|
||||
this.latest = protocol.packGray4(gray, 640, 480); this.schedule(0)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { KeyboardInputSession } from '../ui/shell/keyboard-input'
|
||||
import { acceptInput, resetRingInputFilter } from "../ui/input-monitor";
|
||||
import { bindIosNotifications, iosNotificationsChanged, onIosNotificationPopup } from '../native/notification-icons.ios'
|
||||
import { shouldShowNotificationOnGlasses } from '../native/notification-sources'
|
||||
@@ -42,7 +43,7 @@ import { TextViewerLayer } from '../apps/files/text-viewer'
|
||||
import { shell, rawInputEventToInputEvent, type ShellWindow } from '../ui/shell/shell'
|
||||
import { appViewportRect, SIDEBAR_WIDTH, sidebarStripVisible } from '../ui/shell/geometry'
|
||||
import { DISPLAY_MODE_VALUES, displayModeLabel, displayModeSetting, onAnySettingChanged,
|
||||
previewColorSetting, lockScreenEnabledSetting } from '../ui/dashboard-settings'
|
||||
previewColorSetting, lockScreenEnabledSetting, brightnessSetting, brightnessSettingToLevel } from '../ui/dashboard-settings'
|
||||
import type { PhoneGesture } from '../phone-ui/phone-gestures'
|
||||
import { isWelcomeSoundPending, setWelcomeSoundPending } from '../phone-ui/onboarding-state'
|
||||
import { findSoundEffect, playSoundEffect } from '../ui/sound-effects'
|
||||
@@ -83,13 +84,13 @@ export class IosPreviewController {
|
||||
private renderTimer: ReturnType<typeof setTimeout> | null = null
|
||||
private clockTimer: ReturnType<typeof setInterval> | null = null
|
||||
private offSettings: (() => void) | null = null
|
||||
private lastBrightness: string | null = null
|
||||
private active = false
|
||||
private runtimeRunning = false
|
||||
private clockMinute = -1
|
||||
private shellDirty = true
|
||||
private inputQueue: Promise<void> = Promise.resolve()
|
||||
private lastLayout = ''
|
||||
private prompting = false
|
||||
private readonly appHosts = new Map<string, WorkerAppHost>()
|
||||
private readonly inProcessApps = new Map<string, InProcessWindow>()
|
||||
private readonly batteryObservers: any[] = []
|
||||
@@ -124,7 +125,8 @@ export class IosPreviewController {
|
||||
|
||||
constructor(private readonly onFrame: (image: ImageSource, focus: string) => void,
|
||||
private readonly onError: (message: string) => void,
|
||||
private readonly onConnectionState: (state: SessionState) => void = () => {}) {
|
||||
private readonly onConnectionState: (state: SessionState) => void = () => {},
|
||||
private readonly onKeyboardInputChanged: (session: KeyboardInputSession | null) => void = () => {}) {
|
||||
this.compositor.configureSurface('shell', { x: 0, y: 0, width: 640, height: 480, zOrder: 1, transparency: 'color-key' })
|
||||
this.compositor.configureSurface(LOCK_SCREEN_SURFACE_ID, {
|
||||
x: 0, y: 0, width: G2_LENS_WIDTH, height: G2_LENS_HEIGHT, zOrder: 1000, transparency: 'opaque',
|
||||
@@ -133,6 +135,13 @@ export class IosPreviewController {
|
||||
shell.configure({
|
||||
actions: this.actions,
|
||||
voiceInputEnabled: true,
|
||||
onKeyboardInputChanged: session => this.onKeyboardInputChanged(session ? {
|
||||
targets: session.targets,
|
||||
setText: text => { if (this.active && !this.glassesLocked) session.setText(text) },
|
||||
send: () => { if (this.active && !this.glassesLocked) session.send() },
|
||||
sendTo: id => { if (this.active && !this.glassesLocked) session.sendTo(id) },
|
||||
discard: () => session.discard(),
|
||||
} : null),
|
||||
prepareVoiceCapture: () => this.prepareVoiceCapture(),
|
||||
getScreenTimeoutMs: () => null,
|
||||
requestShellRender: () => this.requestShellRender(),
|
||||
@@ -184,6 +193,7 @@ export class IosPreviewController {
|
||||
pause(): void {
|
||||
if (!this.active) return
|
||||
this.active = false
|
||||
iosVoiceInput.stopPhoneCapture()
|
||||
// The phone preview is hidden; the glasses still own their screen and input.
|
||||
this.syncRuntime()
|
||||
this.logBluetooth(`Phone background; glasses ${this.session?.state.phase ?? 'disconnected'}`)
|
||||
@@ -230,12 +240,24 @@ export class IosPreviewController {
|
||||
this.logBluetooth(`Phone battery ${phone.battery ?? "unknown"}% charging=${phone.charging}`)
|
||||
this.offSettings = onAnySettingChanged(() => {
|
||||
this.syncLockSetting()
|
||||
this.pushBrightness()
|
||||
this.relayout()
|
||||
shell.foregroundWindow()?.requestRender()
|
||||
this.requestShellRender()
|
||||
})
|
||||
this.clockTimer = setInterval(() => this.refreshClock(), 60_000)
|
||||
}
|
||||
private pushBrightness(): void {
|
||||
const session = this.session
|
||||
if (session?.state.phase !== 'connected') { this.lastBrightness = null; return }
|
||||
const value = brightnessSetting.get()
|
||||
if (value === this.lastBrightness) return
|
||||
this.lastBrightness = value
|
||||
void session.setBrightness(brightnessSettingToLevel(value)).catch(error => {
|
||||
this.lastBrightness = null
|
||||
this.logBluetooth(`Brightness: ${String(error)}`)
|
||||
})
|
||||
}
|
||||
private syncLockSetting(): void {
|
||||
const enabled = lockScreenEnabledSetting.get()
|
||||
if (enabled === this.lockEnabled) return
|
||||
@@ -500,6 +522,7 @@ export class IosPreviewController {
|
||||
if (!this.session) {
|
||||
this.session = new GlassesSession(iosBluetooth(), state => {
|
||||
if (state.phase !== "connected") resetRingInputFilter()
|
||||
this.pushBrightness()
|
||||
this.maybePlayWelcomeSound(state)
|
||||
if (state.phase !== 'connected' && state.phase !== 'connecting') this.glassesWorn = null
|
||||
if (state.phase !== 'connected') iosVoiceInput.handleSessionEnded()
|
||||
@@ -540,17 +563,22 @@ export class IosPreviewController {
|
||||
startVoiceInput(): void { if (!this.glassesLocked) shell.startVoiceInput() }
|
||||
private async prepareVoiceCapture(): Promise<boolean> {
|
||||
if (this.glassesLocked) return false
|
||||
if (this.session?.state.phase !== 'connected') {
|
||||
if (this.active) this.onError('Connect the glasses to use their microphone.')
|
||||
return false
|
||||
}
|
||||
const ready = await iosVoiceInput.prepare(this.active)
|
||||
const usePhoneMic = this.session?.state.phase !== 'connected'
|
||||
if (usePhoneMic && !this.active) return false
|
||||
const ready = await iosVoiceInput.prepare(this.active, usePhoneMic)
|
||||
if (!ready && this.active) this.onError(iosVoiceInput.statusText)
|
||||
return ready && !this.glassesLocked && this.session?.state.phase === 'connected'
|
||||
return ready && !this.glassesLocked && (this.session?.state.phase === 'connected' || this.active)
|
||||
}
|
||||
private async startVoiceCapture(endpointing = false): Promise<void> {
|
||||
if (this.glassesLocked || !this.session || this.session.state.phase !== 'connected') return
|
||||
await iosVoiceInput.startGlassesCapture(this.session, message => this.logBluetooth(message), endpointing)
|
||||
if (this.glassesLocked) return
|
||||
const log = (message: string) => this.logBluetooth(message)
|
||||
if (this.session?.state.phase === 'connected') {
|
||||
await iosVoiceInput.startGlassesCapture(this.session, log, endpointing)
|
||||
} else if (this.active) {
|
||||
// Recheck microphone permission if the glasses disconnected after prepare.
|
||||
if (!await iosVoiceInput.prepare(this.active, true) || !this.active || this.glassesLocked) return
|
||||
await iosVoiceInput.startPhoneCapture(log, endpointing)
|
||||
}
|
||||
}
|
||||
private logBluetooth(message: string): void {
|
||||
const line = `${new Date().toISOString()} [${this.active ? 'foreground' : 'background'}${UIApplication.sharedApplication.protectedDataAvailable ? '' : ',protected-data-unavailable'}] ${message}`
|
||||
@@ -568,17 +596,9 @@ export class IosPreviewController {
|
||||
try { File.fromPath(path.join(knownFolders.documents().path, 'bluetooth.log')).writeTextSync(this.logLines.join('\n')) }
|
||||
catch (error) { console.warn(`Bluetooth log: ${error}`) }
|
||||
}
|
||||
async typeIntoApp(): Promise<void> {
|
||||
if (this.glassesLocked) return
|
||||
if (!this.active) { this.logBluetooth('Text input requires opening Faceclaw on the phone'); return }
|
||||
if (this.prompting || !shell.foregroundWindow()?.receiveTextInput) return
|
||||
this.prompting = true
|
||||
try {
|
||||
const result = await Dialogs.prompt({ title: 'Type into ' + shell.foregroundWindow()?.title,
|
||||
message: 'Enter text to send to this app.', okButtonText: 'Send', cancelButtonText: 'Cancel' })
|
||||
if (result.result && !this.glassesLocked) shell.sendTextToForegroundWindow(result.text)
|
||||
} catch (error) { this.fail(error) }
|
||||
finally { this.prompting = false }
|
||||
typeIntoApp(): void {
|
||||
if (this.glassesLocked || !this.active) return
|
||||
shell.startKeyboardInput()
|
||||
}
|
||||
private async editSetting(setting: { editorTitle: string; inputKind?: string; get(): string; set(value: string): void }): Promise<boolean> {
|
||||
if (!this.active) { this.logBluetooth('Editing text settings requires opening Faceclaw on the phone'); return false }
|
||||
|
||||
@@ -6,7 +6,7 @@ export type IosMicrophoneSession = {
|
||||
}
|
||||
|
||||
/** iOS implementation of the shared voice dialog's event bridge. Audio comes
|
||||
* exclusively from the connected glasses, never from the phone microphone.
|
||||
* from the glasses when connected, or the default phone input in preview mode.
|
||||
*/
|
||||
export class IosVoiceControlBridge {
|
||||
private native: any = null
|
||||
@@ -16,6 +16,7 @@ export class IosVoiceControlBridge {
|
||||
private status = 'Voice input ready.'
|
||||
private generation = 0
|
||||
private session: IosMicrophoneSession | null = null
|
||||
private source: 'glasses' | 'phone' | null = null
|
||||
private capturing = false
|
||||
private finalizing = false
|
||||
private completion: Promise<void> = Promise.resolve()
|
||||
@@ -40,20 +41,28 @@ export class IosVoiceControlBridge {
|
||||
}
|
||||
return this.native
|
||||
}
|
||||
async prepare(foreground: boolean): Promise<boolean> {
|
||||
async prepare(foreground: boolean, usePhoneMic = false): Promise<boolean> {
|
||||
let status = FaceclawSpeech.authorizationStatus()
|
||||
if (status === 0) {
|
||||
if (!foreground) { this.setStatus('Open Faceclaw on the phone once to allow Speech Recognition.'); return false }
|
||||
status = await new Promise<number>(resolve => FaceclawSpeech.requestAuthorization(resolve))
|
||||
}
|
||||
if (status !== 3) { this.setStatus('Allow Speech Recognition for Faceclaw in iPhone Settings.'); return false }
|
||||
if (usePhoneMic) {
|
||||
let microphoneStatus = FaceclawSpeech.microphoneAuthorizationStatus()
|
||||
if (microphoneStatus === 0) {
|
||||
if (!foreground) { this.setStatus('Open Faceclaw on the phone to allow microphone access.'); return false }
|
||||
microphoneStatus = await new Promise<number>(resolve => FaceclawSpeech.requestMicrophoneAuthorization(resolve))
|
||||
}
|
||||
if (microphoneStatus !== 3) { this.setStatus('Allow Microphone access for Faceclaw in iPhone Settings.'); return false }
|
||||
}
|
||||
return true
|
||||
}
|
||||
get statusText(): string { return this.status }
|
||||
async startGlassesCapture(session: IosMicrophoneSession, log: (message: string) => void, endpointing = false): Promise<void> {
|
||||
this.stop()
|
||||
const generation = ++this.generation
|
||||
this.log = log; this.session = session; this.packets = 0; this.capturing = true
|
||||
this.log = log; this.source = 'glasses'; this.session = session; this.packets = 0; this.capturing = true
|
||||
this.completion = new Promise(resolve => { this.resolveCompletion = resolve })
|
||||
const error = String(this.ensureNative().startWithEndpointing(endpointing) ?? '')
|
||||
if (error) { this.stop(); this.setStatus(error); this.emitEnd(); return }
|
||||
@@ -77,6 +86,18 @@ export class IosVoiceControlBridge {
|
||||
this.stop(); this.setStatus(error instanceof Error ? error.message : String(error)); this.emitEnd()
|
||||
}
|
||||
}
|
||||
async startPhoneCapture(log: (message: string) => void, endpointing = false): Promise<void> {
|
||||
this.stop()
|
||||
this.log = log; this.source = 'phone'; this.capturing = true
|
||||
this.completion = new Promise(resolve => { this.resolveCompletion = resolve })
|
||||
const error = String(this.ensureNative().startPhoneWithEndpointing(endpointing) ?? '')
|
||||
if (error) { this.stop(); this.setStatus(error); this.emitEnd(); return }
|
||||
log('Voice: phone default microphone enabled; using on-device recognition')
|
||||
}
|
||||
stopPhoneCapture(): void {
|
||||
if (this.source !== 'phone') return
|
||||
this.stop(); this.setStatus('Phone voice input stopped.'); this.emitEnd()
|
||||
}
|
||||
stopPushToTalk(): Promise<void> {
|
||||
const completion = this.completion
|
||||
if (!this.capturing) return completion
|
||||
@@ -88,11 +109,12 @@ export class IosVoiceControlBridge {
|
||||
stop(): void {
|
||||
++this.generation
|
||||
this.capturing = this.finalizing = false
|
||||
this.source = null
|
||||
this.clearAudioTimer(); this.releaseMicrophone(); this.native?.cancel()
|
||||
this.finishCompletion()
|
||||
}
|
||||
handleSessionEnded(message = 'Glasses disconnected. Start voice input again after reconnecting.'): void {
|
||||
if (!this.capturing && !this.finalizing) return
|
||||
if (this.source !== 'glasses' || !this.capturing && !this.finalizing) return
|
||||
this.stop(); this.setStatus(message); this.emitEnd()
|
||||
}
|
||||
private clearAudioTimer(): void { if (this.audioTimer !== null) clearTimeout(this.audioTimer); this.audioTimer = null }
|
||||
@@ -112,10 +134,11 @@ export class IosVoiceControlBridge {
|
||||
} else if (event.kind === 'status') this.setStatus(event.message ?? '')
|
||||
else if (event.kind === 'audio') {
|
||||
this.log(`Voice audio: ${event.seconds?.toFixed(1)}s, packets=${event.packets}, RMS=${event.rms?.toFixed(4)}, missing=${event.missing}, errors=${event.errors}`)
|
||||
if (this.capturing) this.setStatus(`Listening on glasses… ${event.seconds?.toFixed(0)}s`)
|
||||
if (this.capturing) this.setStatus(`Listening on ${this.source === 'phone' ? 'phone' : 'glasses'}… ${event.seconds?.toFixed(0)}s`)
|
||||
} else if (event.kind === 'finishing') {
|
||||
this.stopPushToTalk(); this.emitEnd()
|
||||
} else if (event.kind === 'ended') {
|
||||
this.source = null
|
||||
this.capturing = this.finalizing = false
|
||||
this.clearAudioTimer(); this.releaseMicrophone()
|
||||
this.finishCompletion()
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# Main-screen UI
|
||||
|
||||
Android and iOS share `remote-controls.xml`, `remote-controls.css`, and
|
||||
`RemoteControlsViewModel`: tab order and selection, screen-size choices,
|
||||
brightness/Auto settings, watch labels, ring markings, and microphone/keyboard
|
||||
buttons. Import the stylesheet at the top of each platform's application CSS
|
||||
(before any rules), so the NativeScript CSS pipeline includes it.
|
||||
|
||||
Android's `MainViewModel` extends that shared model and connects it to
|
||||
`dashboardController`. iOS loads the same XML with `Builder.load` and connects
|
||||
it to `IosPreviewController`. Keep platform-specific transport, page lifecycle,
|
||||
and navigation in those adapters. Android uses NativeScript gesture events;
|
||||
iOS feeds raw touches to `PhoneGestureRecognizer`, so the discrete pad gesture
|
||||
bindings in the XML are Android-only to avoid delivering each gesture twice.
|
||||
|
||||
The iOS shell uses the same portrait preview-above-controls layout and 345-DIP
|
||||
landscape controls column. It respects safe areas, uses the same overflow menu
|
||||
labels/order, and retains device diagnostics under the connection status.
|
||||
Conversations and Record screen are disabled on iOS because their storage and
|
||||
recording services are currently Android-only. Take screenshot opens the iOS
|
||||
share sheet. Text settings still use native dialogs. Keyboard input uses the
|
||||
shared `keyboard-input-panel.xml` multiline editor and shell keyboard session,
|
||||
with separate Agent and App destinations when available. iOS keeps the editor
|
||||
above the software keyboard in both orientations.
|
||||
|
||||
Voice input uses the glasses microphone when connected and the phone's default
|
||||
audio input in preview mode. The phone path requires both Speech Recognition
|
||||
and Microphone permissions and stops when Faceclaw leaves the foreground;
|
||||
connected-glasses capture retains its existing background behavior.
|
||||
|
||||
The iOS microphone and keyboard image assets are 3x rasterizations of the
|
||||
Android vector drawables with the same names; regenerate them from those
|
||||
vectors if the icon designs change.
|
||||
@@ -0,0 +1,18 @@
|
||||
<GridLayout rows="auto,*,auto" maxHeight="280" xmlns="http://schemas.nativescript.org/tns.xsd"
|
||||
class="system-name-modal"
|
||||
visibility="{{ keyboardInputVisibility }}"
|
||||
horizontalAlignment="stretch"
|
||||
verticalAlignment="bottom">
|
||||
<Label row="0" text="Keyboard input" class="h2" />
|
||||
<TextView row="1"
|
||||
id="keyboardInputField"
|
||||
text="{{ keyboardInputText }}"
|
||||
hint="Type a message"
|
||||
textChange="{{ onKeyboardInputTextChange }}" />
|
||||
<!-- Wraps onto a second line when the labels don't fit side by side. -->
|
||||
<FlexboxLayout row="2" flexWrap="wrap" class="m-t-8">
|
||||
<Button text="{{ keyboardInputPrimaryTargetLabel }}" tap="{{ onKeyboardInputPrimarySendTap }}" visibility="{{ keyboardInputPrimaryTargetVisibility }}" flexGrow="1" class="-primary" />
|
||||
<Button text="{{ keyboardInputSecondaryTargetLabel }}" tap="{{ onKeyboardInputSecondarySendTap }}" visibility="{{ keyboardInputSecondaryTargetVisibility }}" flexGrow="1" />
|
||||
<Button text="Discard" tap="{{ onKeyboardInputDiscardTap }}" flexGrow="1" />
|
||||
</FlexboxLayout>
|
||||
</GridLayout>
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Observable } from '@nativescript/core'
|
||||
import type { KeyboardInputSession } from '../ui/shell/keyboard-input'
|
||||
|
||||
/** Phone editor for the shell's keyboard session, using the shared XML panel. */
|
||||
export class KeyboardInputViewModel extends Observable {
|
||||
private session: KeyboardInputSession | null = null
|
||||
private text = ''
|
||||
|
||||
setSession(session: KeyboardInputSession | null): void {
|
||||
if (session === this.session) return
|
||||
this.session = session
|
||||
this.text = ''
|
||||
for (const property of ['keyboardInputText', 'keyboardInputVisibility', 'keyboardInputPrimaryTargetLabel',
|
||||
'keyboardInputPrimaryTargetVisibility', 'keyboardInputSecondaryTargetLabel', 'keyboardInputSecondaryTargetVisibility']) {
|
||||
this.notifyPropertyChange(property, this.get(property))
|
||||
}
|
||||
}
|
||||
get keyboardInputVisibility(): 'visible' | 'collapse' { return this.session ? 'visible' : 'collapse' }
|
||||
get keyboardInputText(): string { return this.text }
|
||||
set keyboardInputText(text: string) { this.text = text; this.session?.setText(text) }
|
||||
private targetLabel(index: number): string {
|
||||
const target = this.session?.targets[index]
|
||||
return target?.id === 'assistant' ? 'Send to Agent' : target?.id === 'app' ? 'Type into App' : target?.label ?? ''
|
||||
}
|
||||
get keyboardInputPrimaryTargetLabel(): string { return this.targetLabel(0) }
|
||||
get keyboardInputSecondaryTargetLabel(): string { return this.targetLabel(1) }
|
||||
get keyboardInputPrimaryTargetVisibility(): 'visible' | 'collapse' { return this.session?.targets[0] ? 'visible' : 'collapse' }
|
||||
get keyboardInputSecondaryTargetVisibility(): 'visible' | 'collapse' { return this.session?.targets[1] ? 'visible' : 'collapse' }
|
||||
onKeyboardInputTextChange(args: { value?: string; object?: { text?: string } }): void {
|
||||
this.keyboardInputText = args.object?.text ?? args.value ?? ''
|
||||
}
|
||||
onKeyboardInputPrimarySendTap(): void { this.send(0) }
|
||||
onKeyboardInputSecondarySendTap(): void { this.send(1) }
|
||||
private send(index: number): void {
|
||||
const target = this.session?.targets[index]
|
||||
if (!target) return
|
||||
this.session.setText(this.text)
|
||||
this.session.sendTo(target.id)
|
||||
}
|
||||
onKeyboardInputDiscardTap(): void { this.session?.discard() }
|
||||
}
|
||||
+144
-103
@@ -1,75 +1,122 @@
|
||||
import { Application, Button, Color, Dialogs, Frame, GridLayout, Image, Label, Page, StackLayout, type TouchGestureEventData } from '@nativescript/core'
|
||||
import { KeyboardInputViewModel } from './keyboard-input-view-model'
|
||||
import { Application, Builder, Button, Color, Dialogs, Frame, GridLayout, Image, Label, Page, TextView, type PropertyChangeData, type TouchGestureEventData, type View } from '@nativescript/core'
|
||||
import { isPreviewOnlyMode } from './onboarding-state'
|
||||
import { isAutoReconnectSuppressed, resumeAutoReconnect, suppressAutoReconnect } from '../g2/reconnect-policy'
|
||||
import { launcherEntries } from '../apps/launcher'
|
||||
import { ALL_APPS } from '../apps/all-apps'
|
||||
import { RemoteControlsViewModel } from './remote-controls-view-model'
|
||||
import { IosPreviewController } from '../g2/ios-preview-controller'
|
||||
import { PhoneGestureRecognizer } from './phone-gestures'
|
||||
import { BleBandwidthMeter } from './ble-bandwidth-meter'
|
||||
import { sampleBleTraffic } from '../native/ble-traffic'
|
||||
import { onAnySettingChanged, previewColorSetting, showBleBandwidthSetting } from '../ui/dashboard-settings'
|
||||
import { onAnySettingChanged, mirrorTouchSetting, showBleBandwidthSetting } from '../ui/dashboard-settings'
|
||||
import { loadDeviceAddresses } from '../g2/device-addresses'
|
||||
import { deviceAddressError } from '../g2/ios-peripheral-identity'
|
||||
|
||||
export function createMainPage(): Page {
|
||||
const page = new Page()
|
||||
page.actionBarHidden = true
|
||||
page.className = 'main-page'
|
||||
page.iosOverflowSafeAreaEnabled = false
|
||||
const root = new GridLayout()
|
||||
root.rows = 'auto,*,auto'
|
||||
root.rows = 'auto,*'
|
||||
page.content = root
|
||||
const header = new GridLayout()
|
||||
header.columns = '*,auto'; header.padding = '12 20'
|
||||
header.columns = '*,auto,auto'; header.className = 'main-header'
|
||||
const title = new Label()
|
||||
title.text = 'Faceclaw'; title.fontSize = 25; title.fontWeight = 'bold'
|
||||
const heading = new StackLayout(); heading.addChild(title); header.addChild(heading)
|
||||
title.text = 'Faceclaw'; title.className = 'action-bar-title'
|
||||
header.addChild(title)
|
||||
const state = new Label()
|
||||
state.text = 'Preview only'; state.fontSize = 12; heading.addChild(state)
|
||||
const devices = new Button()
|
||||
devices.text = 'Devices'; devices.accessibilityLabel = 'Configure devices'; devices.fontSize = 14; devices.padding = '10 12'
|
||||
devices.on('tap', () => { void openDevices() })
|
||||
GridLayout.setColumn(devices, 1); header.addChild(devices); root.addChild(header)
|
||||
state.text = 'Preview'; state.className = 'action-bar-status'
|
||||
state.verticalAlignment = 'middle'
|
||||
state.on('tap', () => { void openDevices() })
|
||||
GridLayout.setColumn(state, 1); header.addChild(state)
|
||||
const overflow = new Button()
|
||||
overflow.text = '⋮'; overflow.accessibilityLabel = 'More options'; overflow.className = 'overflow-button'
|
||||
overflow.on('tap', () => openMenu())
|
||||
GridLayout.setColumn(overflow, 2); header.addChild(overflow); root.addChild(header)
|
||||
const body = new GridLayout()
|
||||
GridLayout.setRow(body, 1); root.addChild(body)
|
||||
const mirror = new Image()
|
||||
mirror.stretch = 'fill'; mirror.backgroundColor = new Color('black')
|
||||
mirror.accessibilityIdentifier = 'glasses-preview'
|
||||
mirror.accessibilityLabel = 'Interactive glasses screen preview'
|
||||
mirror.verticalAlignment = 'middle'; body.addChild(mirror)
|
||||
mirror.horizontalAlignment = 'left'; mirror.verticalAlignment = 'middle'; body.addChild(mirror)
|
||||
// Load exactly the same XML and binding model as Android. Only input dispatch
|
||||
// and the surrounding platform navigation/runtime remain iOS-specific.
|
||||
const model = new RemoteControlsViewModel()
|
||||
const controls = new GridLayout()
|
||||
controls.rows = 'auto,*,auto'; controls.padding = 16; body.addChild(controls)
|
||||
const tabs = new GridLayout()
|
||||
tabs.columns = '*,*,*'; controls.addChild(tabs)
|
||||
const pad = new GridLayout()
|
||||
pad.borderRadius = 18; pad.backgroundColor = new Color('#202522')
|
||||
pad.verticalAlignment = 'middle'; pad.horizontalAlignment = 'center'
|
||||
pad.accessibilityIdentifier = 'gesture-pad'
|
||||
GridLayout.setRow(pad, 1); controls.addChild(pad)
|
||||
const focus = new Label()
|
||||
focus.color = new Color('#ffffff'); focus.fontSize = 22; focus.textWrap = true
|
||||
focus.textAlignment = 'center'; focus.margin = 18; focus.verticalAlignment = 'middle'
|
||||
focus.isUserInteractionEnabled = false; pad.addChild(focus)
|
||||
const legend = new Label()
|
||||
legend.color = new Color('#b8c1bb'); legend.fontSize = 12; legend.textAlignment = 'center'
|
||||
legend.textWrap = true; legend.margin = 12; legend.verticalAlignment = 'bottom'
|
||||
legend.isUserInteractionEnabled = false; pad.addChild(legend)
|
||||
const settings = new StackLayout()
|
||||
settings.verticalAlignment = 'middle'
|
||||
GridLayout.setRow(settings, 1); controls.addChild(settings)
|
||||
const errorLabel = new Label()
|
||||
errorLabel.textWrap = true; errorLabel.color = new Color('#a02d2d'); errorLabel.visibility = 'collapse'
|
||||
settings.addChild(errorLabel)
|
||||
let selectedTab: 'watch' | 'ring' | 'settings' = 'watch'
|
||||
const remote = Builder.load('~/phone-ui/remote-controls')
|
||||
remote.bindingContext = model
|
||||
controls.addChild(remote); body.addChild(controls)
|
||||
const keyboardModel = new KeyboardInputViewModel()
|
||||
const keyboardPanel = Builder.load('~/phone-ui/keyboard-input-panel')
|
||||
keyboardPanel.bindingContext = keyboardModel
|
||||
GridLayout.setRow(keyboardPanel, 1); root.addChild(keyboardPanel)
|
||||
let focusTimer: ReturnType<typeof setTimeout> | null = null
|
||||
const keyboardField = () => keyboardPanel.getViewById<TextView>('keyboardInputField')
|
||||
const controller = new IosPreviewController((image, label) => {
|
||||
mirror.imageSource = image; focus.text = selectedTab === 'ring' ? 'Ring' : label
|
||||
mirror.imageSource = image; model.set('padFocusLine', label)
|
||||
}, message => {
|
||||
errorLabel.text = message; errorLabel.visibility = 'visible'; selectTab('settings')
|
||||
void Dialogs.alert({ title: 'Faceclaw', message, okButtonText: 'OK' })
|
||||
}, connection => {
|
||||
state.text = connection.phase === 'connected' ? `Connected${connection.battery !== null ? ` · ${connection.battery}%` : ''}${connection.ring ? ' · R1' : ''}`
|
||||
: ({ disconnected: 'Preview only', connecting: 'Connecting…', retrying: 'Reconnecting…', disconnecting: 'Disconnecting…', error: 'Connection failed · Devices for details' })[connection.phase] || connection.phase
|
||||
state.text = ({ connected: 'Connected', disconnected: 'Preview', connecting: 'Connecting',
|
||||
retrying: 'Reconnecting', disconnecting: 'Disconnecting', error: 'Failed' })[connection.phase]
|
||||
}, session => {
|
||||
keyboardModel.setSession(session)
|
||||
controls.visibility = session ? 'collapse' : 'visible'
|
||||
if (focusTimer !== null) clearTimeout(focusTimer)
|
||||
focusTimer = null
|
||||
if (session) {
|
||||
focusTimer = setTimeout(() => { focusTimer = null; keyboardField()?.focus() }, 0)
|
||||
} else keyboardField()?.dismissSoftInput()
|
||||
})
|
||||
async function navigateDevicePage(moduleName: string, context?: object): Promise<void> {
|
||||
suppressAutoReconnect()
|
||||
await controller.disconnect()
|
||||
Frame.topmost()?.navigate({ moduleName, context })
|
||||
}
|
||||
function openMenu(): void {
|
||||
const connected = ['connected', 'connecting', 'retrying'].includes(controller.connectionState?.phase ?? '')
|
||||
const configured = !deviceAddressError(loadDeviceAddresses())
|
||||
const menu = UIAlertController.alertControllerWithTitleMessagePreferredStyle(null, null, UIAlertControllerStyle.ActionSheet)
|
||||
const add = (label: string, action: (() => void) | null) => {
|
||||
const item = UIAlertAction.actionWithTitleStyleHandler(label, UIAlertActionStyle.Default, () => {
|
||||
// Finish dismissal before presenting a share sheet or another page.
|
||||
menu.dismissViewControllerAnimatedCompletion(true, () => action?.())
|
||||
})
|
||||
item.enabled = action !== null
|
||||
menu.addAction(item)
|
||||
}
|
||||
if (configured) add(connected ? 'Disconnect' : 'Connect', () => {
|
||||
if (connected) { suppressAutoReconnect(); void controller.disconnect() }
|
||||
else { resumeAutoReconnect(); void controller.connect() }
|
||||
})
|
||||
add('Pair glasses', () => { void navigateDevicePage('phone-ui/onboarding-unpair-page') })
|
||||
add('Permissions', () => Frame.topmost()?.navigate({ moduleName: 'phone-ui/permissions-page' }))
|
||||
// Keep Android's menu order/text. These services still require Android;
|
||||
// disabled items make the platform limitation visible without dead actions.
|
||||
add('Conversations', null)
|
||||
add('Take screenshot', mirror.imageSource ? () => {
|
||||
const share = UIActivityViewController.alloc().initWithActivityItemsApplicationActivities([mirror.imageSource.ios], null)
|
||||
if (share.popoverPresentationController) {
|
||||
share.popoverPresentationController.sourceView = overflow.ios
|
||||
share.popoverPresentationController.sourceRect = overflow.ios.bounds
|
||||
}
|
||||
page.ios.presentViewControllerAnimatedCompletion(share, true, null)
|
||||
} : null)
|
||||
add('Record screen', null)
|
||||
if (configured) add('Uninstall custom firmware', () => {
|
||||
void navigateDevicePage('phone-ui/onboarding-flash-page', { mode: 'uninstall', fromOnboarding: false })
|
||||
})
|
||||
menu.addAction(UIAlertAction.actionWithTitleStyleHandler('Cancel', UIAlertActionStyle.Cancel, null))
|
||||
if (menu.popoverPresentationController) {
|
||||
menu.popoverPresentationController.sourceView = overflow.ios
|
||||
menu.popoverPresentationController.sourceRect = overflow.ios.bounds
|
||||
}
|
||||
page.ios.presentViewControllerAnimatedCompletion(menu, true, null)
|
||||
}
|
||||
async function openDevices(): Promise<void> {
|
||||
const connected = ['connected', 'connecting', 'retrying'].includes(controller.connectionState?.phase ?? '')
|
||||
const choice = await Dialogs.action({ title: 'Devices', message: controller.connectionState?.status ?? 'Preview only', cancelButtonText: 'Cancel',
|
||||
const choice = await Dialogs.action({ title: 'Connection status', message: controller.connectionState?.status ?? 'Preview only', cancelButtonText: 'Cancel',
|
||||
actions: ['Pair glasses', 'Configure devices', connected ? 'Disconnect' : 'Connect', 'Check firmware', 'Install custom firmware', 'Uninstall custom firmware', 'Connection details'] })
|
||||
if (['Pair glasses', 'Configure devices', 'Check firmware', 'Install custom firmware', 'Uninstall custom firmware'].includes(choice)) {
|
||||
suppressAutoReconnect()
|
||||
@@ -87,8 +134,10 @@ export function createMainPage(): Page {
|
||||
else if (choice === 'Disconnect') { suppressAutoReconnect(); await controller.disconnect() }
|
||||
else if (choice === 'Connection details') await Dialogs.alert({ title: 'Connection details', message: controller.connectionDetails, okButtonText: 'OK' })
|
||||
}
|
||||
const padInput = new PhoneGestureRecognizer(gesture => controller.gesture(gesture, selectedTab === 'ring' ? 'ring' : 'watch'))
|
||||
const watchInput = new PhoneGestureRecognizer(gesture => controller.gesture(gesture, 'watch'))
|
||||
const ringInput = new PhoneGestureRecognizer(gesture => controller.gesture(gesture, 'ring'))
|
||||
const mirrorInput = new PhoneGestureRecognizer((gesture, x, y) => {
|
||||
if (!mirrorTouchSetting.get()) return
|
||||
const size = mirror.getActualSize()
|
||||
if (size.width > 0 && size.height > 0) controller.gesture(gesture, 'mirror', x / size.width, y / size.height)
|
||||
})
|
||||
@@ -96,56 +145,33 @@ export function createMainPage(): Page {
|
||||
if (!['down', 'move', 'up', 'cancel'].includes(event.action)) return
|
||||
recognizer.touch({ action: event.action as 'down' | 'move' | 'up' | 'cancel', x: event.getX(), y: event.getY(), pointers: event.getPointerCount() })
|
||||
}
|
||||
pad.on('touch', touch(padInput)); mirror.on('touch', touch(mirrorInput))
|
||||
function button(text: string, action: () => void): Button {
|
||||
const view = new Button()
|
||||
view.text = text; view.fontSize = 15; view.margin = 3; view.on('tap', action)
|
||||
return view
|
||||
}
|
||||
const tabButtons: Button[] = []
|
||||
function selectTab(tab: typeof selectedTab): void {
|
||||
padInput.cancel(); selectedTab = tab
|
||||
pad.visibility = tab === 'settings' ? 'collapse' : 'visible'
|
||||
settings.visibility = tab === 'settings' ? 'visible' : 'collapse'
|
||||
for (let i = 0; i < tabButtons.length; i++) tabButtons[i].opacity = ['settings', 'watch', 'ring'][i] === tab ? 1 : 0.5
|
||||
focus.text = tab === 'ring' ? 'Ring' : 'Watch controls'
|
||||
legend.text = tab === 'ring' ? 'Swipe up/down · Tap to select\nDouble-tap: back · Hold: menu' : 'Swipe to navigate · Tap to select\nDouble-tap / two fingers: back · Hold: menu'
|
||||
layout()
|
||||
}
|
||||
for (const [index, tab] of (['settings', 'watch', 'ring'] as const).entries()) {
|
||||
const view = button(tab[0].toUpperCase() + tab.slice(1), () => selectTab(tab))
|
||||
GridLayout.setColumn(view, index); tabs.addChild(view); tabButtons.push(view)
|
||||
}
|
||||
const sizeButton = button(controller.displayModeLabel, () => controller.cycleDisplayMode())
|
||||
settings.addChild(button('Open app', () => { void (async () => {
|
||||
const apps = launcherEntries(ALL_APPS).sort((a, b) => a.label.localeCompare(b.label))
|
||||
const title = await Dialogs.action({ title: 'Open app', cancelButtonText: 'Cancel', actions: apps.map(app => app.label) })
|
||||
const app = apps.find(app => app.label === title)
|
||||
if (app) { await controller.launchApp(app.appId); selectTab('watch') }
|
||||
})() }))
|
||||
settings.addChild(sizeButton)
|
||||
settings.addChild(button('Toggle green / grayscale', () => previewColorSetting.set(previewColorSetting.get() === 'green' ? 'white' : 'green')))
|
||||
const help = new Label()
|
||||
help.text = 'Tap preview icons to open apps.\nHold: system menu\nTap then hold: app menu'
|
||||
help.fontSize = 13; help.textWrap = true; help.margin = 6; settings.addChild(help)
|
||||
const footer = new GridLayout()
|
||||
footer.columns = '*,*,*,*'; GridLayout.setRow(footer, 2); controls.addChild(footer)
|
||||
const back = button('Back', () => controller.gesture('double-tap', 'watch'))
|
||||
const menu = button('Menu', () => {
|
||||
controller.gesture('long-press', 'watch'); controller.gesture('long-press-release', 'watch')
|
||||
model.set('onPadTouch', touch(watchInput))
|
||||
model.set('onRingPadTouch', touch(ringInput))
|
||||
model.set('onSyntheticMicTap', () => controller.startVoiceInput())
|
||||
model.set('onKeyboardTap', () => { void controller.typeIntoApp() })
|
||||
mirror.on('touch', touch(mirrorInput))
|
||||
const cancelGestures = () => { watchInput.cancel(); ringInput.cancel(); mirrorInput.cancel() }
|
||||
model.on('propertyChange', (args: PropertyChangeData) => {
|
||||
if (args.propertyName === 'watchTabVisibility') cancelGestures()
|
||||
})
|
||||
let controlsLayoutTimer: ReturnType<typeof setTimeout> | null = null
|
||||
model.set('onControlsContentLayoutChanged', (args: { object: View }) => {
|
||||
if (controlsLayoutTimer !== null) clearTimeout(controlsLayoutTimer)
|
||||
// Defer binding updates out of UIKit's layout pass.
|
||||
controlsLayoutTimer = setTimeout(() => {
|
||||
controlsLayoutTimer = null
|
||||
const { width, height } = args.object.getActualSize()
|
||||
model.set('watchFaceWidth', Math.min(345, Math.max(0, width)))
|
||||
model.set('watchFaceHeight', Math.min(230, Math.max(0, height - 2)))
|
||||
model.set('ringTouchpadHeight', Math.min(250, Math.max(0, height - 2)))
|
||||
}, 0)
|
||||
})
|
||||
const keyboard = button('Keyboard', () => { void controller.typeIntoApp() })
|
||||
const voice = button('Voice', () => controller.startVoiceInput())
|
||||
for (const [index, view] of [back, menu, voice, keyboard].entries()) {
|
||||
view.padding = '16 8'; view.fontSize = 14
|
||||
GridLayout.setColumn(view, index); footer.addChild(view)
|
||||
}
|
||||
const bandwidth = new Label()
|
||||
bandwidth.accessibilityIdentifier = 'ble-bandwidth-indicator'
|
||||
bandwidth.fontSize = 10; bandwidth.textWrap = true; bandwidth.padding = '2 8 4'
|
||||
bandwidth.color = new Color('#68756c'); bandwidth.isUserInteractionEnabled = false
|
||||
bandwidth.className = 'ble-bandwidth-indicator'; bandwidth.isUserInteractionEnabled = false
|
||||
bandwidth.horizontalAlignment = 'center'; bandwidth.verticalAlignment = 'bottom'
|
||||
bandwidth.visibility = 'collapse'
|
||||
GridLayout.setRow(bandwidth, 2); root.addChild(bandwidth)
|
||||
GridLayout.setRow(bandwidth, 1); root.addChild(bandwidth)
|
||||
const bandwidthMeter = new BleBandwidthMeter()
|
||||
let bandwidthTimer: ReturnType<typeof setInterval> | null = null
|
||||
let foreground = false
|
||||
@@ -164,25 +190,24 @@ export function createMainPage(): Page {
|
||||
}
|
||||
let lastLayout = ''
|
||||
function layout(): void {
|
||||
const size = root.getActualSize()
|
||||
const size = body.getActualSize()
|
||||
if (size.width <= 0 || size.height <= 0) return
|
||||
const metricsHeight = bandwidth.visibility === 'visible' ? bandwidth.getActualSize().height : 0
|
||||
const availableHeight = size.height - metricsHeight
|
||||
const key = `${size.width}:${availableHeight}:${selectedTab}`
|
||||
const landscape = root.getActualSize().width > root.getActualSize().height
|
||||
const key = `${size.width}:${size.height}:${landscape}`
|
||||
if (key === lastLayout) return
|
||||
lastLayout = key; padInput.cancel(); mirrorInput.cancel()
|
||||
const landscape = size.width > size.height
|
||||
body.rows = landscape ? '*' : 'auto,*'; body.columns = landscape ? '*,320' : '*'
|
||||
lastLayout = key; cancelGestures()
|
||||
body.className = landscape ? 'landscape-layout' : ''
|
||||
root.className = landscape ? 'main-landscape' : ''
|
||||
body.rows = landscape ? '*' : 'auto,*'; body.columns = landscape ? '*,345' : '*'
|
||||
controls.padding = landscape ? 0 : 20
|
||||
GridLayout.setRow(controls, landscape ? 0 : 1); GridLayout.setColumn(controls, landscape ? 1 : 0)
|
||||
const width = landscape ? Math.min(size.width - 320, (availableHeight - 64) * 4 / 3) : size.width
|
||||
const width = landscape ? Math.max(0, Math.min(size.width - 345, size.height * 4 / 3)) : size.width
|
||||
mirror.width = width; mirror.height = width * 3 / 4
|
||||
pad.width = selectedTab === 'ring' ? 150 : Math.min(360, (landscape ? 320 : size.width) - 32)
|
||||
pad.height = Math.max(120, Math.min(250, availableHeight - (landscape ? 180 : width * 3 / 4 + 200)))
|
||||
}
|
||||
// iOS emits layoutChanged inside its layout pass. Defer mutations so
|
||||
// NativeScript does not clear our new layout request at the end of that pass.
|
||||
let layoutTimer: ReturnType<typeof setTimeout> | null = null
|
||||
root.on('layoutChanged', () => {
|
||||
body.on('layoutChanged', () => {
|
||||
if (layoutTimer !== null) return
|
||||
layoutTimer = setTimeout(() => { layoutTimer = null; layout() }, 0)
|
||||
})
|
||||
@@ -190,17 +215,33 @@ export function createMainPage(): Page {
|
||||
foreground = false; stopBandwidth()
|
||||
if (layoutTimer !== null) clearTimeout(layoutTimer)
|
||||
layoutTimer = null
|
||||
padInput.cancel(); mirrorInput.cancel(); controller.pause()
|
||||
if (controlsLayoutTimer !== null) clearTimeout(controlsLayoutTimer)
|
||||
controlsLayoutTimer = null
|
||||
if (focusTimer !== null) clearTimeout(focusTimer)
|
||||
focusTimer = null
|
||||
keyboardField()?.dismissSoftInput()
|
||||
cancelGestures(); controller.pause()
|
||||
}
|
||||
const resume = () => { foreground = true; controller.resume(); syncBandwidth() }
|
||||
let keyboardObserver: any = null
|
||||
let offSettings: (() => void) | null = null
|
||||
page.on('loaded', () => {
|
||||
if (!keyboardObserver) keyboardObserver = NSNotificationCenter.defaultCenter.addObserverForNameObjectQueueUsingBlock(
|
||||
UIKeyboardWillChangeFrameNotification, null, NSOperationQueue.mainQueue, notification => {
|
||||
const frame = notification.userInfo.objectForKey(UIKeyboardFrameEndUserInfoKey).CGRectValue
|
||||
const view = page.ios.view
|
||||
const local = view.convertRectFromView(frame, null)
|
||||
root.paddingBottom = Math.max(0, view.bounds.size.height - local.origin.y - view.safeAreaInsets.bottom)
|
||||
})
|
||||
Application.on(Application.suspendEvent, pause); Application.on(Application.resumeEvent, resume)
|
||||
offSettings?.(); offSettings = onAnySettingChanged(() => { sizeButton.text = controller.displayModeLabel; syncBandwidth() })
|
||||
selectTab(selectedTab); resume()
|
||||
offSettings?.(); offSettings = onAnySettingChanged(() => { model.refreshDisplayControls(); syncBandwidth() })
|
||||
model.refreshDisplayControls(); resume()
|
||||
if (!isPreviewOnlyMode() && !isAutoReconnectSuppressed() && !deviceAddressError(loadDeviceAddresses())) void controller.connect()
|
||||
})
|
||||
page.on('unloaded', () => {
|
||||
if (keyboardObserver) NSNotificationCenter.defaultCenter.removeObserver(keyboardObserver)
|
||||
keyboardObserver = null
|
||||
root.paddingBottom = 0
|
||||
pause(); offSettings?.(); offSettings = null
|
||||
Application.off(Application.suspendEvent, pause); Application.off(Application.resumeEvent, resume)
|
||||
})
|
||||
|
||||
@@ -155,24 +155,6 @@
|
||||
(ui/shell/keyboard-input.ts). Same placement and collapsing rules
|
||||
as the setting editor above. Enter inserts a newline; the send
|
||||
buttons pick a destination directly. -->
|
||||
<StackLayout
|
||||
class="system-name-modal"
|
||||
visibility="{{ keyboardInputVisibility }}"
|
||||
horizontalAlignment="stretch"
|
||||
verticalAlignment="bottom">
|
||||
<Label text="Keyboard input" class="h2" />
|
||||
<TextView
|
||||
id="keyboardInputField"
|
||||
text="{{ keyboardInputText }}"
|
||||
hint="Type a message"
|
||||
textChange="{{ onKeyboardInputTextChange }}"
|
||||
height="120" />
|
||||
<!-- Wraps onto a second line when the labels don't fit side by side. -->
|
||||
<FlexboxLayout flexWrap="wrap" class="m-t-8">
|
||||
<Button text="{{ keyboardInputPrimaryTargetLabel }}" tap="{{ onKeyboardInputPrimarySendTap }}" visibility="{{ keyboardInputPrimaryTargetVisibility }}" flexGrow="1" class="-primary" />
|
||||
<Button text="{{ keyboardInputSecondaryTargetLabel }}" tap="{{ onKeyboardInputSecondarySendTap }}" visibility="{{ keyboardInputSecondaryTargetVisibility }}" flexGrow="1" />
|
||||
<Button text="Discard" tap="{{ onKeyboardInputDiscardTap }}" flexGrow="1" />
|
||||
</FlexboxLayout>
|
||||
</StackLayout>
|
||||
<rc:keyboard-input-panel />
|
||||
</GridLayout>
|
||||
</Page>
|
||||
@@ -1,10 +1,10 @@
|
||||
import { RemoteControlsViewModel } from './remote-controls-view-model';
|
||||
import { BleBandwidthMeter } from "./ble-bandwidth-meter";
|
||||
import {
|
||||
Application,
|
||||
Dialogs,
|
||||
Frame,
|
||||
ImageSource,
|
||||
Observable,
|
||||
Screen,
|
||||
SwipeDirection,
|
||||
type GestureEventData,
|
||||
@@ -14,15 +14,9 @@ import {
|
||||
} from "@nativescript/core";
|
||||
import { dashboardController, type MirrorTouchKind } from "../g2/dashboard-controller";
|
||||
import {
|
||||
brightnessSetting,
|
||||
DISPLAY_MODE_VALUES,
|
||||
displayModeLabel,
|
||||
displayModeSetting,
|
||||
mirrorTouchSetting,
|
||||
onAnySettingChanged,
|
||||
showBleBandwidthSetting,
|
||||
type BrightnessSetting,
|
||||
type DisplayModeSetting,
|
||||
} from "../ui/dashboard-settings";
|
||||
import { sampleBleTraffic } from "../native/ble-traffic";
|
||||
import { isValidMacAddress, loadDeviceAddresses } from "../g2/device-addresses";
|
||||
@@ -35,13 +29,7 @@ const LENS_ASPECT_RATIO = G2_LENS_WIDTH / G2_LENS_HEIGHT;
|
||||
|
||||
type LayoutOrientation = "portrait" | "landscape";
|
||||
|
||||
type ControlsTab = "settings" | "watch" | "ring";
|
||||
|
||||
// Survives navigation round-trips (a fresh view model is built per visit) but
|
||||
// not process restarts.
|
||||
let lastControlsTab: ControlsTab = "watch";
|
||||
|
||||
export class MainViewModel extends Observable {
|
||||
export class MainViewModel extends RemoteControlsViewModel {
|
||||
private _status = "Disconnected.";
|
||||
private _displayPreview: ImageSource | null = null;
|
||||
private _displayPreviewMessage = "";
|
||||
@@ -1193,128 +1181,10 @@ export class MainViewModel extends Observable {
|
||||
// watch face), Ring (simulated R1 inputs). The whole area collapses while a
|
||||
// text setting is being edited so the editor gets the space instead.
|
||||
|
||||
private _controlsTab: ControlsTab = lastControlsTab;
|
||||
|
||||
get controlsVisibility(): "visible" | "collapse" {
|
||||
return this.isTextSettingEditorActive || this._keyboardInputActive ? "collapse" : "visible";
|
||||
}
|
||||
|
||||
get settingsTabVisibility(): "visible" | "collapse" {
|
||||
return this._controlsTab === "settings" ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get watchTabVisibility(): "visible" | "collapse" {
|
||||
return this._controlsTab === "watch" ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get ringTabVisibility(): "visible" | "collapse" {
|
||||
return this._controlsTab === "ring" ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get settingsTabClass(): string {
|
||||
return this._controlsTab === "settings" ? "tab-button tab-button-selected" : "tab-button";
|
||||
}
|
||||
|
||||
get watchTabClass(): string {
|
||||
return this._controlsTab === "watch" ? "tab-button tab-button-selected" : "tab-button";
|
||||
}
|
||||
|
||||
get ringTabClass(): string {
|
||||
return this._controlsTab === "ring" ? "tab-button tab-button-selected" : "tab-button";
|
||||
}
|
||||
|
||||
onSettingsTabTap(): void {
|
||||
this.setControlsTab("settings");
|
||||
}
|
||||
|
||||
onWatchTabTap(): void {
|
||||
this.setControlsTab("watch");
|
||||
}
|
||||
|
||||
onRingTabTap(): void {
|
||||
this.setControlsTab("ring");
|
||||
}
|
||||
|
||||
private setControlsTab(tab: ControlsTab): void {
|
||||
if (this._controlsTab === tab) return;
|
||||
this._controlsTab = tab;
|
||||
// Remembered across navigations (module-level) so the page comes back on
|
||||
// the tab it left on; deliberately not persisted to disk.
|
||||
lastControlsTab = tab;
|
||||
this.notifyPropertyChange("settingsTabVisibility", this.settingsTabVisibility);
|
||||
this.notifyPropertyChange("watchTabVisibility", this.watchTabVisibility);
|
||||
this.notifyPropertyChange("ringTabVisibility", this.ringTabVisibility);
|
||||
this.notifyPropertyChange("settingsTabClass", this.settingsTabClass);
|
||||
this.notifyPropertyChange("watchTabClass", this.watchTabClass);
|
||||
this.notifyPropertyChange("ringTabClass", this.ringTabClass);
|
||||
}
|
||||
|
||||
// ---- display mode and brightness, on the Settings tab ----
|
||||
|
||||
get displayModeLabel(): string {
|
||||
return displayModeLabel(displayModeSetting.get()) + " ▾";
|
||||
}
|
||||
|
||||
async onDisplayModeTap(): Promise<void> {
|
||||
const current = displayModeSetting.get();
|
||||
const options = DISPLAY_MODE_VALUES.map((value) => displayModeLabel(value) + (value === current ? " ✓" : ""));
|
||||
const picked = await Dialogs.action({ title: "Display mode", cancelButtonText: "Cancel", actions: options });
|
||||
const index = options.indexOf(picked);
|
||||
if (index < 0) return;
|
||||
const value = DISPLAY_MODE_VALUES[index] as DisplayModeSetting;
|
||||
if (value !== current) displayModeSetting.set(value);
|
||||
this.notifyPropertyChange("displayModeLabel", this.displayModeLabel);
|
||||
}
|
||||
|
||||
get brightnessAuto(): boolean {
|
||||
return brightnessSetting.get() === "auto";
|
||||
}
|
||||
|
||||
get brightnessSliderEnabled(): boolean {
|
||||
return !this.brightnessAuto;
|
||||
}
|
||||
|
||||
/** The slider's position; while Auto, the last manual level (or 50). */
|
||||
get brightnessPercent(): number {
|
||||
const value = brightnessSetting.get();
|
||||
if (value === "auto") return this.lastManualBrightness;
|
||||
const numeric = parseInt(value, 10);
|
||||
return Number.isFinite(numeric) ? numeric : 50;
|
||||
}
|
||||
|
||||
private lastManualBrightness = 50;
|
||||
|
||||
onBrightnessChange(args: { value?: number; object?: { value?: number } }): void {
|
||||
if (this.brightnessAuto) return;
|
||||
const raw = typeof args.value === "number" ? args.value : Number(args.object?.value ?? NaN);
|
||||
if (!Number.isFinite(raw)) return;
|
||||
// The setting only has every tenth level; snap to the nearest.
|
||||
const level = Math.min(100, Math.max(0, Math.round(raw / 10) * 10));
|
||||
this.lastManualBrightness = level;
|
||||
const value = String(level) as BrightnessSetting;
|
||||
if (brightnessSetting.get() !== value) brightnessSetting.set(value);
|
||||
}
|
||||
|
||||
onBrightnessAutoChange(args: { value?: boolean; object?: { checked?: boolean } }): void {
|
||||
const on = typeof args.value === "boolean" ? args.value : Boolean(args.object?.checked);
|
||||
if (on) {
|
||||
if (brightnessSetting.get() !== "auto") {
|
||||
this.lastManualBrightness = this.brightnessPercent;
|
||||
brightnessSetting.set("auto");
|
||||
}
|
||||
} else if (brightnessSetting.get() === "auto") {
|
||||
brightnessSetting.set(String(this.lastManualBrightness) as BrightnessSetting);
|
||||
}
|
||||
this.refreshDisplayControls();
|
||||
}
|
||||
|
||||
private refreshDisplayControls(): void {
|
||||
this.notifyPropertyChange("brightnessAuto", this.brightnessAuto);
|
||||
this.notifyPropertyChange("brightnessSliderEnabled", this.brightnessSliderEnabled);
|
||||
this.notifyPropertyChange("brightnessPercent", this.brightnessPercent);
|
||||
this.notifyPropertyChange("displayModeLabel", this.displayModeLabel);
|
||||
}
|
||||
|
||||
// ---- BLE bandwidth indicator (Settings > Developer > Show BLE bandwidth usage) ----
|
||||
//
|
||||
// A running total of outbound BLE messages/bytes, overlaid at the bottom of
|
||||
|
||||
@@ -17,3 +17,5 @@ global.registerModule('phone-ui/onboarding-flash-page.xml', () => require('./onb
|
||||
global.registerModule('phone-ui/document-page', () => require('./document-page'));
|
||||
global.registerModule('phone-ui/document-page.xml', () => require('./document-page.xml'));
|
||||
global.registerModule('phone-ui/main-page', () => require('./main-page.ios'));
|
||||
global.registerModule('phone-ui/remote-controls.xml', () => require('./remote-controls.xml'));
|
||||
global.registerModule('phone-ui/keyboard-input-panel.xml', () => require('./keyboard-input-panel.xml'));
|
||||
@@ -0,0 +1,131 @@
|
||||
import { Dialogs, Observable } from '@nativescript/core';
|
||||
import {
|
||||
brightnessSetting, DISPLAY_MODE_VALUES, displayModeLabel, displayModeSetting,
|
||||
type BrightnessSetting, type DisplayModeSetting,
|
||||
} from '../ui/dashboard-settings';
|
||||
|
||||
type ControlsTab = 'settings' | 'watch' | 'ring';
|
||||
// Remember the tab across navigation on both platforms, without persisting it.
|
||||
let lastControlsTab: ControlsTab = 'watch';
|
||||
|
||||
/** Shared state and actions for remote-controls.xml; transport stays in the host. */
|
||||
export class RemoteControlsViewModel extends Observable {
|
||||
private _controlsTab: ControlsTab = lastControlsTab;
|
||||
|
||||
get settingsTabVisibility(): "visible" | "collapse" {
|
||||
return this._controlsTab === "settings" ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get watchTabVisibility(): "visible" | "collapse" {
|
||||
return this._controlsTab === "watch" ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get ringTabVisibility(): "visible" | "collapse" {
|
||||
return this._controlsTab === "ring" ? "visible" : "collapse";
|
||||
}
|
||||
|
||||
get settingsTabClass(): string {
|
||||
return this._controlsTab === "settings" ? "tab-button tab-button-selected" : "tab-button";
|
||||
}
|
||||
|
||||
get watchTabClass(): string {
|
||||
return this._controlsTab === "watch" ? "tab-button tab-button-selected" : "tab-button";
|
||||
}
|
||||
|
||||
get ringTabClass(): string {
|
||||
return this._controlsTab === "ring" ? "tab-button tab-button-selected" : "tab-button";
|
||||
}
|
||||
|
||||
onSettingsTabTap(): void {
|
||||
this.setControlsTab("settings");
|
||||
}
|
||||
|
||||
onWatchTabTap(): void {
|
||||
this.setControlsTab("watch");
|
||||
}
|
||||
|
||||
onRingTabTap(): void {
|
||||
this.setControlsTab("ring");
|
||||
}
|
||||
|
||||
protected setControlsTab(tab: ControlsTab): void {
|
||||
if (this._controlsTab === tab) return;
|
||||
this._controlsTab = tab;
|
||||
// Remembered across navigations (module-level) so the page comes back on
|
||||
// the tab it left on; deliberately not persisted to disk.
|
||||
lastControlsTab = tab;
|
||||
this.notifyPropertyChange("settingsTabVisibility", this.settingsTabVisibility);
|
||||
this.notifyPropertyChange("watchTabVisibility", this.watchTabVisibility);
|
||||
this.notifyPropertyChange("ringTabVisibility", this.ringTabVisibility);
|
||||
this.notifyPropertyChange("settingsTabClass", this.settingsTabClass);
|
||||
this.notifyPropertyChange("watchTabClass", this.watchTabClass);
|
||||
this.notifyPropertyChange("ringTabClass", this.ringTabClass);
|
||||
}
|
||||
|
||||
// ---- display mode and brightness, on the Settings tab ----
|
||||
|
||||
get displayModeLabel(): string {
|
||||
return displayModeLabel(displayModeSetting.get()) + " ▾";
|
||||
}
|
||||
|
||||
async onDisplayModeTap(): Promise<void> {
|
||||
const current = displayModeSetting.get();
|
||||
const options = DISPLAY_MODE_VALUES.map((value) => displayModeLabel(value) + (value === current ? " ✓" : ""));
|
||||
const picked = await Dialogs.action({ title: "Display mode", cancelButtonText: "Cancel", actions: options });
|
||||
const index = options.indexOf(picked);
|
||||
if (index < 0) return;
|
||||
const value = DISPLAY_MODE_VALUES[index] as DisplayModeSetting;
|
||||
if (value !== current) displayModeSetting.set(value);
|
||||
this.notifyPropertyChange("displayModeLabel", this.displayModeLabel);
|
||||
}
|
||||
|
||||
get brightnessAuto(): boolean {
|
||||
return brightnessSetting.get() === "auto";
|
||||
}
|
||||
|
||||
get brightnessSliderEnabled(): boolean {
|
||||
return !this.brightnessAuto;
|
||||
}
|
||||
|
||||
/** The slider's position; while Auto, the last manual level (or 50). */
|
||||
get brightnessPercent(): number {
|
||||
const value = brightnessSetting.get();
|
||||
if (value === "auto") return this.lastManualBrightness;
|
||||
const numeric = parseInt(value, 10);
|
||||
return Number.isFinite(numeric) ? numeric : 50;
|
||||
}
|
||||
|
||||
private lastManualBrightness = 50;
|
||||
|
||||
onBrightnessChange(args: { value?: number; object?: { value?: number } }): void {
|
||||
if (this.brightnessAuto) return;
|
||||
const raw = typeof args.value === "number" ? args.value : Number(args.object?.value ?? NaN);
|
||||
if (!Number.isFinite(raw)) return;
|
||||
// The setting only has every tenth level; snap to the nearest.
|
||||
const level = Math.min(100, Math.max(0, Math.round(raw / 10) * 10));
|
||||
this.lastManualBrightness = level;
|
||||
const value = String(level) as BrightnessSetting;
|
||||
if (brightnessSetting.get() !== value) brightnessSetting.set(value);
|
||||
}
|
||||
|
||||
onBrightnessAutoChange(args: { value?: boolean; object?: { checked?: boolean } }): void {
|
||||
const on = typeof args.value === "boolean" ? args.value : Boolean(args.object?.checked);
|
||||
if (on) {
|
||||
if (brightnessSetting.get() !== "auto") {
|
||||
this.lastManualBrightness = this.brightnessPercent;
|
||||
brightnessSetting.set("auto");
|
||||
}
|
||||
} else if (brightnessSetting.get() === "auto") {
|
||||
brightnessSetting.set(String(this.lastManualBrightness) as BrightnessSetting);
|
||||
}
|
||||
this.refreshDisplayControls();
|
||||
}
|
||||
|
||||
public refreshDisplayControls(): void {
|
||||
this.notifyPropertyChange("brightnessAuto", this.brightnessAuto);
|
||||
this.notifyPropertyChange("brightnessSliderEnabled", this.brightnessSliderEnabled);
|
||||
this.notifyPropertyChange("brightnessPercent", this.brightnessPercent);
|
||||
this.notifyPropertyChange("displayModeLabel", this.displayModeLabel);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/* The phone's controller for the glasses (phone-ui/remote-controls.xml). */
|
||||
.remote-controls {
|
||||
margin: 0 8 0 8;
|
||||
}
|
||||
/* The Settings / Watch / Ring tab bar above the controls. */
|
||||
.controls-tab-bar {
|
||||
margin-bottom: 8;
|
||||
}
|
||||
.tab-button {
|
||||
font-size: 14;
|
||||
padding: 8 0;
|
||||
margin: 0 2;
|
||||
border-radius: 6;
|
||||
background-color: #e2e2e2;
|
||||
color: #333333;
|
||||
}
|
||||
.tab-button-selected {
|
||||
background-color: #424242;
|
||||
color: #ffffff;
|
||||
}
|
||||
/* 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.
|
||||
* The height also bounds the tile's measure, without which its star row
|
||||
* would collapse to content and pin the icon to the top. */
|
||||
height: 48;
|
||||
margin: 6 2;
|
||||
android-elevation: 2;
|
||||
}
|
||||
.tab-icon {
|
||||
height: 20;
|
||||
tint-color: #333333;
|
||||
}
|
||||
/* Landscape uses the full page height and a shared left edge for tabs/pad. */
|
||||
.landscape-layout .remote-controls {
|
||||
margin: 0;
|
||||
}
|
||||
.landscape-layout .controls-tab-bar {
|
||||
margin-bottom: 2;
|
||||
}
|
||||
.landscape-layout .tab-button {
|
||||
margin-left: 1;
|
||||
margin-right: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.landscape-layout .tab-button[col="0"] {
|
||||
margin-left: 0;
|
||||
}
|
||||
.landscape-layout .tab-icon-button {
|
||||
width: 48;
|
||||
}
|
||||
.landscape-layout .tab-icon-button[col="4"] {
|
||||
margin-right: 0;
|
||||
}
|
||||
.ns-dark .tab-icon {
|
||||
tint-color: #cccccc;
|
||||
}
|
||||
.ns-dark .tab-button {
|
||||
background-color: #333333;
|
||||
color: #cccccc;
|
||||
}
|
||||
.ns-dark .tab-button-selected {
|
||||
background-color: #e2e2e2;
|
||||
color: #222222;
|
||||
}
|
||||
/* Settings tab rows. */
|
||||
.settings-row {
|
||||
margin-bottom: 8;
|
||||
}
|
||||
.settings-row-label {
|
||||
font-size: 14;
|
||||
margin-right: 10;
|
||||
}
|
||||
.mode-button {
|
||||
font-size: 13;
|
||||
padding: 6 10;
|
||||
margin-right: 6;
|
||||
}
|
||||
.brightness-icon {
|
||||
font-size: 16;
|
||||
margin: 0 4 0 4;
|
||||
color: #444444;
|
||||
}
|
||||
.auto-toggle Label {
|
||||
font-size: 13;
|
||||
margin-right: 2;
|
||||
}
|
||||
.touchpad {
|
||||
height: 230;
|
||||
background-color: #1f1f1f;
|
||||
border-radius: 14;
|
||||
border-width: 1;
|
||||
border-color: #3a3a3a;
|
||||
color: #f0f0f0;
|
||||
margin-top: 2;
|
||||
}
|
||||
.pad-focus {
|
||||
font-size: 20;
|
||||
color: #ffffff;
|
||||
}
|
||||
.pad-legend {
|
||||
font-size: 11;
|
||||
color: #8a8a8a;
|
||||
margin-bottom: 8;
|
||||
}
|
||||
.action-row {
|
||||
margin-top: 6;
|
||||
}
|
||||
.action-button {
|
||||
margin: 2;
|
||||
font-size: 14;
|
||||
}
|
||||
/* Ring tab: the same touchpad, but portrait like the ring's own pad. */
|
||||
.ring-touchpad {
|
||||
width: 150;
|
||||
height: 250;
|
||||
}
|
||||
/* Cosmetic marks mirroring the six rectangles on the physical ring's touch
|
||||
strip; barely lighter than the pad so they read as texture, not buttons. */
|
||||
.ring-pad-marking {
|
||||
width: 18;
|
||||
height: 5;
|
||||
border-radius: 2;
|
||||
background-color: #2a2a2a;
|
||||
horizontal-align: center;
|
||||
vertical-align: center;
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
height (the Watch face centers in it); the three sections share the star
|
||||
cell, only one visible at a time.
|
||||
-->
|
||||
<GridLayout xmlns="http://schemas.nativescript.org/tns.xsd" rows="auto,*" class="remote-controls">
|
||||
<GridLayout xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:android="http://schemas.nativescript.org/tns.xsd" rows="auto,*" class="remote-controls">
|
||||
<!-- rows="auto" everywhere below: a rows-less GridLayout's implicit row
|
||||
acts as star, and this component sits in a bounded (star-row) parent,
|
||||
where that would balloon the first grid to fill all remaining height. -->
|
||||
@@ -26,10 +26,10 @@
|
||||
<!-- A Button can't hold an image, so these are button-styled tiles. The
|
||||
explicit star row makes the cell fill the tile's height so the icon's
|
||||
center alignment has room to work in. -->
|
||||
<GridLayout col="3" rows="*" tap="{{ onSyntheticMicTap }}" class="tab-button tab-icon-button">
|
||||
<GridLayout col="3" rows="*" accessible="true" accessibilityRole="button" accessibilityLabel="Voice input" tap="{{ onSyntheticMicTap }}" class="tab-button tab-icon-button">
|
||||
<Image src="res://ic_tab_mic" class="tab-icon" verticalAlignment="center" horizontalAlignment="center" />
|
||||
</GridLayout>
|
||||
<GridLayout col="4" rows="*" tap="{{ onKeyboardTap }}" class="tab-button tab-icon-button">
|
||||
<GridLayout col="4" rows="*" accessible="true" accessibilityRole="button" accessibilityLabel="Keyboard input" tap="{{ onKeyboardTap }}" class="tab-button tab-icon-button">
|
||||
<Image src="res://ic_tab_keyboard" class="tab-icon" verticalAlignment="center" horizontalAlignment="center" />
|
||||
</GridLayout>
|
||||
</GridLayout>
|
||||
@@ -53,9 +53,9 @@
|
||||
|
||||
<!-- Watch tab: centered in the leftover height, capped at the 1.5:1 face
|
||||
aspect (watchFaceWidth = min(available, 1.5 x face height). -->
|
||||
<GridLayout visibility="{{ watchTabVisibility }}" width="{{ watchFaceWidth }}" height="{{ watchFaceHeight }}" horizontalAlignment="center" verticalAlignment="center" class="touchpad" tap="{{ onPadTap }}" doubleTap="{{ onPadDoubleTap }}" longPress="{{ onPadLongPress }}" swipe="{{ onPadSwipe }}" touch="{{ onPadTouch }}">
|
||||
<Label text="{{ padFocusLine }}" class="pad-focus" horizontalAlignment="center" verticalAlignment="center" />
|
||||
<Label text="▲▼ swipe ● select ●● back ‒ menu" class="pad-legend" horizontalAlignment="center" verticalAlignment="bottom" />
|
||||
<GridLayout visibility="{{ watchTabVisibility }}" width="{{ watchFaceWidth }}" height="{{ watchFaceHeight }}" horizontalAlignment="center" verticalAlignment="center" class="touchpad" android:tap="{{ onPadTap }}" android:doubleTap="{{ onPadDoubleTap }}" android:longPress="{{ onPadLongPress }}" android:swipe="{{ onPadSwipe }}" touch="{{ onPadTouch }}">
|
||||
<Label isUserInteractionEnabled="false" text="{{ padFocusLine }}" class="pad-focus" horizontalAlignment="center" verticalAlignment="center" />
|
||||
<Label isUserInteractionEnabled="false" text="▲▼ swipe ● select ●● back ‒ menu" class="pad-legend" horizontalAlignment="center" verticalAlignment="bottom" />
|
||||
</GridLayout>
|
||||
|
||||
<!-- Ring tab: a touchpad on the ring's own scheme. Vertical swipes only
|
||||
@@ -66,8 +66,8 @@
|
||||
<GridLayout visibility="{{ ringTabVisibility }}" height="{{ ringTouchpadHeight }}" class="touchpad ring-touchpad"
|
||||
rows="*,auto,*,auto,*,auto,*,auto,*,auto,*,auto,*"
|
||||
horizontalAlignment="center" verticalAlignment="center"
|
||||
tap="{{ onRingPadTap }}" doubleTap="{{ onRingPadDoubleTap }}"
|
||||
longPress="{{ onRingPadLongPress }}" swipe="{{ onRingPadSwipe }}"
|
||||
android:tap="{{ onRingPadTap }}" android:doubleTap="{{ onRingPadDoubleTap }}"
|
||||
android:longPress="{{ onRingPadLongPress }}" android:swipe="{{ onRingPadSwipe }}"
|
||||
touch="{{ onRingPadTouch }}">
|
||||
<Label row="1" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="3" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
|
||||
Reference in new issue
Block a user