forked from Blendman974/faceclaw
Merge branch 'main' into ios-port
This commit is contained in:
commit
a31ddae4d2
49 files changed
+2068
-212
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { Application, Color, EventData, isAndroid, Observable, Page, TextField } from '@nativescript/core'
|
||||
import { Application, Color, EventData, isAndroid, Observable, Page, TextField, TextView } from '@nativescript/core'
|
||||
import { MainViewModel } from './main-view-model'
|
||||
import { dashboardController } from '../g2/dashboard-controller'
|
||||
|
||||
@@ -44,7 +44,7 @@ function cleanupPage(page: Page): void {
|
||||
* suits replacing an existing setting value; a message being composed keeps
|
||||
* its caret where the user taps.
|
||||
*/
|
||||
function applySettingsTextFieldContrast(textField: TextField, selectAllOnFocus = true): void {
|
||||
function applySettingsTextFieldContrast(textField: TextField | TextView, selectAllOnFocus = true): void {
|
||||
textField.color = SETTINGS_TEXT_COLOR
|
||||
textField.backgroundColor = SETTINGS_BACKGROUND_COLOR
|
||||
textField.placeholderColor = SETTINGS_PLACEHOLDER_COLOR
|
||||
@@ -53,7 +53,7 @@ function applySettingsTextFieldContrast(textField: TextField, selectAllOnFocus =
|
||||
return
|
||||
}
|
||||
|
||||
const nativeTextField = (textField as TextField & { nativeView?: android.widget.EditText }).nativeView
|
||||
const nativeTextField = (textField as (TextField | TextView) & { nativeView?: android.widget.EditText }).nativeView
|
||||
if (!nativeTextField) {
|
||||
return
|
||||
}
|
||||
@@ -90,13 +90,13 @@ function focusTextEditor(page: Page): void {
|
||||
|
||||
/** The keyboard dialog closed on the glasses (sent, discarded, or screen off). */
|
||||
function dismissKeyboardInputKeyboard(page: Page): void {
|
||||
page.getViewById<TextField>('keyboardInputField')?.dismissSoftInput()
|
||||
page.getViewById<TextView>('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')
|
||||
const textField = page.getViewById<TextView>('keyboardInputField')
|
||||
if (textField) {
|
||||
applySettingsTextFieldContrast(textField, false)
|
||||
textField.focus()
|
||||
|
||||
+26
-27
@@ -38,30 +38,31 @@
|
||||
</GridLayout>
|
||||
</GridLayout>
|
||||
|
||||
<GridLayout class="p-20" visibility="{{ landscapeLayoutVisibility }}">
|
||||
<GridLayout rows="auto" columns="*,360">
|
||||
<StackLayout row="0" col="0" visibility="{{ displayPreviewVisibility }}" horizontalAlignment="left">
|
||||
<Image
|
||||
src="{{ displayPreview }}"
|
||||
stretch="fill"
|
||||
<GridLayout class="landscape-layout" visibility="{{ landscapeLayoutVisibility }}">
|
||||
<GridLayout rows="*" columns="*,345">
|
||||
<GridLayout col="0" layoutChanged="{{ onLandscapePreviewLayoutChanged }}">
|
||||
<StackLayout visibility="{{ displayPreviewVisibility }}" horizontalAlignment="left" verticalAlignment="center">
|
||||
<Image
|
||||
src="{{ displayPreview }}"
|
||||
stretch="fill"
|
||||
width="{{ landscapeDisplayPreviewWidth }}"
|
||||
height="{{ landscapeDisplayPreviewHeight }}"
|
||||
tap="{{ onMirrorTap }}" doubleTap="{{ onMirrorDoubleTap }}" longPress="{{ onMirrorLongPress }}" swipe="{{ onMirrorSwipe }}" />
|
||||
</StackLayout>
|
||||
<GridLayout
|
||||
class="display-preview-message"
|
||||
horizontalAlignment="left"
|
||||
verticalAlignment="center"
|
||||
width="{{ landscapeDisplayPreviewWidth }}"
|
||||
height="{{ landscapeDisplayPreviewHeight }}"
|
||||
tap="{{ onMirrorTap }}" doubleTap="{{ onMirrorDoubleTap }}" longPress="{{ onMirrorLongPress }}" swipe="{{ onMirrorSwipe }}" />
|
||||
</StackLayout>
|
||||
<GridLayout
|
||||
row="0"
|
||||
col="0"
|
||||
class="display-preview-message"
|
||||
horizontalAlignment="left"
|
||||
width="{{ landscapeDisplayPreviewWidth }}"
|
||||
height="{{ landscapeDisplayPreviewHeight }}"
|
||||
visibility="{{ displayPreviewMessageVisibility }}">
|
||||
<Label text="{{ displayPreviewMessage }}" textWrap="true" horizontalAlignment="center" verticalAlignment="center" />
|
||||
visibility="{{ displayPreviewMessageVisibility }}">
|
||||
<Label text="{{ displayPreviewMessage }}" textWrap="true" horizontalAlignment="center" verticalAlignment="center" />
|
||||
</GridLayout>
|
||||
</GridLayout>
|
||||
<GridLayout col="1" rows="*,auto">
|
||||
<rc:remote-controls row="0" visibility="{{ controlsVisibility }}" />
|
||||
<Button row="1" text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
|
||||
</GridLayout>
|
||||
<StackLayout row="0" col="1" class="m-l-16">
|
||||
<rc:remote-controls visibility="{{ controlsVisibility }}" />
|
||||
<Button text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
|
||||
</StackLayout>
|
||||
</GridLayout>
|
||||
</GridLayout>
|
||||
<!-- Developer BLE-bandwidth indicator: overlays the bottom edge of the
|
||||
@@ -153,22 +154,20 @@
|
||||
<!-- Keyboard-input panel (the keyboard button beside the mic button):
|
||||
the phone's end of the keyboard dialog on the glasses
|
||||
(ui/shell/keyboard-input.ts). Same placement and collapsing rules
|
||||
as the setting editor above. The IME's send key goes to whichever
|
||||
destination is highlighted on the glasses; the buttons pick one
|
||||
directly. -->
|
||||
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" />
|
||||
<TextField
|
||||
<TextView
|
||||
id="keyboardInputField"
|
||||
text="{{ keyboardInputText }}"
|
||||
hint="Type a message"
|
||||
textChange="{{ onKeyboardInputTextChange }}"
|
||||
returnPress="{{ onKeyboardInputReturnPress }}"
|
||||
returnKeyType="send" />
|
||||
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" />
|
||||
|
||||
@@ -45,6 +45,9 @@ export class MainViewModel extends Observable {
|
||||
private _displayPreview: ImageSource | null = null;
|
||||
private _displayPreviewMessage = "";
|
||||
private _layoutOrientation: LayoutOrientation = this.readLayoutOrientation();
|
||||
private _landscapePreviewWidth = 0;
|
||||
private _landscapePreviewHeight = 0;
|
||||
private _controlsContentHeight = 250;
|
||||
private _activeTextSettingId: string | null = null;
|
||||
private _activeTextEditorTitle = "";
|
||||
private _activeTextSettingTitle = "";
|
||||
@@ -237,18 +240,25 @@ export class MainViewModel extends Observable {
|
||||
}
|
||||
|
||||
get landscapeDisplayPreviewWidth(): number {
|
||||
return Math.floor(this.landscapeDisplayPreviewHeight * LENS_ASPECT_RATIO);
|
||||
return this._landscapePreviewWidth;
|
||||
}
|
||||
|
||||
get landscapeDisplayPreviewHeight(): number {
|
||||
// Height keeps the vertical footprint the preview had at the old 2:1
|
||||
// aspect; the width is derived from it, so a wider lens aspect can't
|
||||
// grow the preview past the side panel.
|
||||
const screenWidth = Screen.mainScreen.widthDIPs;
|
||||
// Must match the landscape grid's fixed side-panel column in main-page.xml.
|
||||
const sidePanelWidth = 360;
|
||||
const availableWidth = Math.max(240, Math.floor(screenWidth - sidePanelWidth - 56));
|
||||
return Math.floor(availableWidth / 2);
|
||||
return this._landscapePreviewHeight;
|
||||
}
|
||||
|
||||
onLandscapePreviewLayoutChanged(args: { object: View }): void {
|
||||
// Measure the actual content cell: excludes the action bar, system bars,
|
||||
// and controls, and updates for rotation, split-screen, and the keyboard.
|
||||
const { width, height } = args.object.getActualSize();
|
||||
if (width <= 0 || height <= 0) return;
|
||||
const previewHeight = Math.min(height, width / LENS_ASPECT_RATIO);
|
||||
const previewWidth = previewHeight * LENS_ASPECT_RATIO;
|
||||
if (previewWidth === this._landscapePreviewWidth && previewHeight === this._landscapePreviewHeight) return;
|
||||
this._landscapePreviewWidth = previewWidth;
|
||||
this._landscapePreviewHeight = previewHeight;
|
||||
this.notifyPropertyChange("landscapeDisplayPreviewWidth", previewWidth);
|
||||
this.notifyPropertyChange("landscapeDisplayPreviewHeight", previewHeight);
|
||||
}
|
||||
|
||||
/** Near-full-width on phones, capped on tablets (the 32 clears the 16 margins). */
|
||||
@@ -265,13 +275,27 @@ export class MainViewModel extends Observable {
|
||||
const faceHeight = 230;
|
||||
const available =
|
||||
this._layoutOrientation === "landscape"
|
||||
? // The landscape side panel column (see main-page.xml) minus its
|
||||
// m-l-16 margin and the controls' own 8+8 margins.
|
||||
360 - 32
|
||||
? 345 // Matches the unpadded landscape controls column in main-page.xml.
|
||||
: Screen.mainScreen.widthDIPs - 56; // p-20 padding + controls margins
|
||||
return Math.min(available, Math.round(faceHeight * 1.5));
|
||||
}
|
||||
|
||||
get watchFaceHeight(): number {
|
||||
return Math.min(230, Math.max(0, this._controlsContentHeight - 2));
|
||||
}
|
||||
|
||||
get ringTouchpadHeight(): number {
|
||||
return Math.min(250, Math.max(0, this._controlsContentHeight - 2));
|
||||
}
|
||||
|
||||
onControlsContentLayoutChanged(args: { object: View }): void {
|
||||
const { height } = args.object.getActualSize();
|
||||
if (height <= 0 || height === this._controlsContentHeight) return;
|
||||
this._controlsContentHeight = height;
|
||||
this.notifyPropertyChange("watchFaceHeight", this.watchFaceHeight);
|
||||
this.notifyPropertyChange("ringTouchpadHeight", this.ringTouchpadHeight);
|
||||
}
|
||||
|
||||
get portraitLayoutVisibility(): "visible" | "collapse" {
|
||||
return this._layoutOrientation === "portrait" ? "visible" : "collapse";
|
||||
}
|
||||
@@ -541,18 +565,11 @@ export class MainViewModel extends Observable {
|
||||
}
|
||||
|
||||
onKeyboardInputTextChange(args: { value?: string; object?: { text?: string } }): void {
|
||||
dashboardController.setKeyboardInputText(args.object?.text ?? args.value ?? "");
|
||||
}
|
||||
|
||||
/** The IME's send key: the destination highlighted on the glasses. */
|
||||
onKeyboardInputReturnPress(args: { object?: { text?: string } }): void {
|
||||
// Commit the field's actual text at send-time, in case the final
|
||||
// keystroke's textChange hadn't landed yet.
|
||||
const text = args?.object?.text;
|
||||
if (typeof text === "string") {
|
||||
dashboardController.setKeyboardInputText(text);
|
||||
}
|
||||
dashboardController.sendKeyboardInput();
|
||||
const text = args.object?.text ?? args.value ?? "";
|
||||
// Track the draft so closing the dialog emits a clear even when the
|
||||
// binding hasn't updated the model. Avoid echoing edits into the IME.
|
||||
this._keyboardInputText = text;
|
||||
dashboardController.setKeyboardInputText(text);
|
||||
}
|
||||
|
||||
onKeyboardInputPrimarySendTap(): void {
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
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. -->
|
||||
<GridLayout row="0" rows="auto" columns="*,*,*,auto,auto" class="controls-tab-bar">
|
||||
<Button col="0" text="Settings" tap="{{ onSettingsTabTap }}" class="{{ settingsTabClass }}" />
|
||||
<Button col="1" text="Watch" tap="{{ onWatchTabTap }}" class="{{ watchTabClass }}" />
|
||||
<Button col="2" text="Ring" tap="{{ onRingTabTap }}" class="{{ ringTabClass }}" />
|
||||
<Button col="0" text="Settings" textWrap="false" tap="{{ onSettingsTabTap }}" class="{{ settingsTabClass }}" />
|
||||
<Button col="1" text="Watch" textWrap="false" tap="{{ onWatchTabTap }}" class="{{ watchTabClass }}" />
|
||||
<Button col="2" text="Ring" textWrap="false" tap="{{ onRingTabTap }}" class="{{ ringTabClass }}" />
|
||||
<!-- 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. -->
|
||||
@@ -34,48 +34,47 @@
|
||||
</GridLayout>
|
||||
</GridLayout>
|
||||
|
||||
<!-- Settings tab -->
|
||||
<StackLayout row="1" visibility="{{ settingsTabVisibility }}">
|
||||
<GridLayout rows="auto" columns="auto,*" class="settings-row">
|
||||
<Label col="0" text="Screen size" class="settings-row-label" verticalAlignment="center" />
|
||||
<Button col="1" text="{{ displayModeLabel }}" tap="{{ onDisplayModeTap }}" class="mode-button" horizontalAlignment="left" />
|
||||
</GridLayout>
|
||||
<GridLayout rows="auto" columns="auto,*,auto" class="settings-row">
|
||||
<Label col="0" text="☀" class="brightness-icon" verticalAlignment="center" />
|
||||
<Slider col="1" width="100%" minValue="0" maxValue="100" value="{{ brightnessPercent }}" valueChange="{{ onBrightnessChange }}" isEnabled="{{ brightnessSliderEnabled }}" />
|
||||
<StackLayout col="2" orientation="horizontal" verticalAlignment="center" class="auto-toggle">
|
||||
<Label text="Auto" verticalAlignment="center" />
|
||||
<Switch checked="{{ brightnessAuto }}" checkedChange="{{ onBrightnessAutoChange }}" />
|
||||
</StackLayout>
|
||||
</GridLayout>
|
||||
</StackLayout>
|
||||
<GridLayout row="1" layoutChanged="{{ onControlsContentLayoutChanged }}">
|
||||
<!-- Settings tab -->
|
||||
<StackLayout visibility="{{ settingsTabVisibility }}">
|
||||
<GridLayout rows="auto" columns="auto,*" class="settings-row">
|
||||
<Label col="0" text="Screen size" class="settings-row-label" verticalAlignment="center" />
|
||||
<Button col="1" text="{{ displayModeLabel }}" tap="{{ onDisplayModeTap }}" class="mode-button" horizontalAlignment="left" />
|
||||
</GridLayout>
|
||||
<GridLayout rows="auto" columns="auto,*,auto" class="settings-row">
|
||||
<Label col="0" text="☀" class="brightness-icon" verticalAlignment="center" />
|
||||
<Slider col="1" width="100%" minValue="0" maxValue="100" value="{{ brightnessPercent }}" valueChange="{{ onBrightnessChange }}" isEnabled="{{ brightnessSliderEnabled }}" />
|
||||
<StackLayout col="2" orientation="horizontal" verticalAlignment="center" class="auto-toggle">
|
||||
<Label text="Auto" verticalAlignment="center" />
|
||||
<Switch checked="{{ brightnessAuto }}" checkedChange="{{ onBrightnessAutoChange }}" />
|
||||
</StackLayout>
|
||||
</GridLayout>
|
||||
</StackLayout>
|
||||
|
||||
<!-- Watch tab: centered in the leftover height, capped at the 1.5:1 face
|
||||
aspect (watchFaceWidth = min(available, 1.5 x face height). -->
|
||||
<StackLayout row="1" visibility="{{ watchTabVisibility }}" width="{{ watchFaceWidth }}" horizontalAlignment="center" verticalAlignment="center">
|
||||
<GridLayout class="touchpad" tap="{{ onPadTap }}" doubleTap="{{ onPadDoubleTap }}" longPress="{{ onPadLongPress }}" swipe="{{ onPadSwipe }}" touch="{{ onPadTouch }}">
|
||||
<!-- 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>
|
||||
</StackLayout>
|
||||
|
||||
<!-- Ring tab: a touchpad on the ring's own scheme. Vertical swipes only
|
||||
(the ring has no horizontal axis) and no focus/status line; portrait
|
||||
like the ring's pad itself. The auto rows hold the cosmetic markings the
|
||||
physical ring has on its touch strip (they don't take touches); the star
|
||||
rows are the seven equal gaps around them, edges included. -->
|
||||
<GridLayout row="1" visibility="{{ ringTabVisibility }}" class="touchpad ring-touchpad"
|
||||
rows="*,auto,*,auto,*,auto,*,auto,*,auto,*,auto,*"
|
||||
horizontalAlignment="center" verticalAlignment="center"
|
||||
tap="{{ onRingPadTap }}" doubleTap="{{ onRingPadDoubleTap }}"
|
||||
longPress="{{ onRingPadLongPress }}" swipe="{{ onRingPadSwipe }}"
|
||||
touch="{{ onRingPadTouch }}">
|
||||
<Label row="1" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="3" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="5" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="7" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="9" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="11" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<!-- Ring tab: a touchpad on the ring's own scheme. Vertical swipes only
|
||||
(the ring has no horizontal axis) and no focus/status line; portrait
|
||||
like the ring's pad itself. The auto rows hold the cosmetic markings the
|
||||
physical ring has on its touch strip (they don't take touches); the star
|
||||
rows are the seven equal gaps around them, edges included. -->
|
||||
<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 }}"
|
||||
touch="{{ onRingPadTouch }}">
|
||||
<Label row="1" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="3" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="5" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="7" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="9" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
<Label row="11" class="ring-pad-marking" isUserInteractionEnabled="false" />
|
||||
</GridLayout>
|
||||
</GridLayout>
|
||||
|
||||
</GridLayout>
|
||||
Reference in new issue
Block a user