Add a phone preview Rotation setting; improve landscape layout

This commit is contained in:
James Babcock committed 2026-09-08 02:43:51 -07:00
1 parent 3d39d27456
commit 1154474754
9 files changed
+165 -74

No files matched your search

+1
View File
@@ -4,6 +4,7 @@
* Navigate and terminal app: App-specific screen size/position setting * Navigate and terminal app: App-specific screen size/position setting
* Transcribe app: Scrolling; automatic reconnection; insert newlines * Transcribe app: Scrolling; automatic reconnection; insert newlines
* Notifications: Add notification filters * Notifications: Add notification filters
* Phone screen preview: Add rotation option; improve landscape layout
## 0.6.5 - 2026-09-04 ## 0.6.5 - 2026-09-04
* Changed context menu gestures: — for system, ●— for app context menu. * Changed context menu gestures: — for system, ●— for app context menu.
+21
View File
@@ -201,6 +201,27 @@ Button.-primary {
height: 20; height: 20;
tint-color: #333333; 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 { .ns-dark .tab-icon {
tint-color: #cccccc; tint-color: #cccccc;
} }
+2
View File
@@ -7,9 +7,11 @@ purpose of the file is to pass control to the app’s first module.
import { Application } from '@nativescript/core' import { Application } from '@nativescript/core'
import { registerShareIntentHandler } from './native/share-intents' import { registerShareIntentHandler } from './native/share-intents'
import { installNativeUserAgent } from './util/http' import { installNativeUserAgent } from './util/http'
import { registerPhoneRotation } from './native/phone-rotation'
installNativeUserAgent() installNativeUserAgent()
registerShareIntentHandler() registerShareIntentHandler()
registerPhoneRotation()
Application.run({ moduleName: 'app-root' }) Application.run({ moduleName: 'app-root' })
+30
View File
@@ -0,0 +1,30 @@
import { Application, isAndroid } from "@nativescript/core";
import { getStringSetting, onSettingsStoreChanged } from "./settings-store";
// Shared with phoneRotationSetting; keep startup independent of the glasses UI.
const ROTATION_KEY = "phone.rotation";
/** Installed once on the UI thread; also covers navigation and activity recreation. */
export function registerPhoneRotation(): void {
if (!isAndroid) return;
const apply = (activity = Application.android.foregroundActivity ?? Application.android.startActivity): void => {
if (!activity) return;
const orientations = android.content.pm.ActivityInfo;
const requested = {
auto: orientations.SCREEN_ORIENTATION_UNSPECIFIED,
portrait: orientations.SCREEN_ORIENTATION_PORTRAIT,
landscape: orientations.SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
}[getStringSetting(ROTATION_KEY, "auto")] ?? orientations.SCREEN_ORIENTATION_UNSPECIFIED;
if (activity.getRequestedOrientation() !== requested) {
activity.setRequestedOrientation(requested);
}
};
Application.android.on(Application.android.activityCreatedEvent, (args) => apply(args.activity));
Application.android.on(Application.android.activityResumedEvent, (args) => apply(args.activity));
onSettingsStoreChanged((key) => {
if (key === ROTATION_KEY) apply();
});
apply();
}
+22 -21
View File
@@ -38,30 +38,31 @@
</GridLayout> </GridLayout>
</GridLayout> </GridLayout>
<GridLayout class="p-20" visibility="{{ landscapeLayoutVisibility }}"> <GridLayout class="landscape-layout" visibility="{{ landscapeLayoutVisibility }}">
<GridLayout rows="auto" columns="*,360"> <GridLayout rows="*" columns="*,345">
<StackLayout row="0" col="0" visibility="{{ displayPreviewVisibility }}" horizontalAlignment="left"> <GridLayout col="0" layoutChanged="{{ onLandscapePreviewLayoutChanged }}">
<Image <StackLayout visibility="{{ displayPreviewVisibility }}" horizontalAlignment="left" verticalAlignment="center">
src="{{ displayPreview }}" <Image
stretch="fill" 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 }}" width="{{ landscapeDisplayPreviewWidth }}"
height="{{ landscapeDisplayPreviewHeight }}" height="{{ landscapeDisplayPreviewHeight }}"
tap="{{ onMirrorTap }}" doubleTap="{{ onMirrorDoubleTap }}" longPress="{{ onMirrorLongPress }}" swipe="{{ onMirrorSwipe }}" /> visibility="{{ displayPreviewMessageVisibility }}">
</StackLayout> <Label text="{{ displayPreviewMessage }}" textWrap="true" horizontalAlignment="center" verticalAlignment="center" />
<GridLayout </GridLayout>
row="0" </GridLayout>
col="0" <GridLayout col="1" rows="*,auto">
class="display-preview-message" <rc:remote-controls row="0" visibility="{{ controlsVisibility }}" />
horizontalAlignment="left" <Button row="1" text="Stop recording" tap="{{ onStopRecordingTap }}" visibility="{{ stopRecordingButtonVisibility }}" />
width="{{ landscapeDisplayPreviewWidth }}"
height="{{ landscapeDisplayPreviewHeight }}"
visibility="{{ displayPreviewMessageVisibility }}">
<Label text="{{ displayPreviewMessage }}" textWrap="true" horizontalAlignment="center" verticalAlignment="center" />
</GridLayout> </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>
</GridLayout> </GridLayout>
<!-- Developer BLE-bandwidth indicator: overlays the bottom edge of the <!-- Developer BLE-bandwidth indicator: overlays the bottom edge of the
+36 -12
View File
@@ -44,6 +44,9 @@ export class MainViewModel extends Observable {
private _displayPreview: ImageSource | null = null; private _displayPreview: ImageSource | null = null;
private _displayPreviewMessage = ""; private _displayPreviewMessage = "";
private _layoutOrientation: LayoutOrientation = this.readLayoutOrientation(); private _layoutOrientation: LayoutOrientation = this.readLayoutOrientation();
private _landscapePreviewWidth = 0;
private _landscapePreviewHeight = 0;
private _controlsContentHeight = 250;
private _activeTextSettingId: string | null = null; private _activeTextSettingId: string | null = null;
private _activeTextEditorTitle = ""; private _activeTextEditorTitle = "";
private _activeTextSettingTitle = ""; private _activeTextSettingTitle = "";
@@ -236,18 +239,25 @@ export class MainViewModel extends Observable {
} }
get landscapeDisplayPreviewWidth(): number { get landscapeDisplayPreviewWidth(): number {
return Math.floor(this.landscapeDisplayPreviewHeight * LENS_ASPECT_RATIO); return this._landscapePreviewWidth;
} }
get landscapeDisplayPreviewHeight(): number { get landscapeDisplayPreviewHeight(): number {
// Height keeps the vertical footprint the preview had at the old 2:1 return this._landscapePreviewHeight;
// 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; onLandscapePreviewLayoutChanged(args: { object: View }): void {
// Must match the landscape grid's fixed side-panel column in main-page.xml. // Measure the actual content cell: excludes the action bar, system bars,
const sidePanelWidth = 360; // and controls, and updates for rotation, split-screen, and the keyboard.
const availableWidth = Math.max(240, Math.floor(screenWidth - sidePanelWidth - 56)); const { width, height } = args.object.getActualSize();
return Math.floor(availableWidth / 2); 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). */ /** Near-full-width on phones, capped on tablets (the 32 clears the 16 margins). */
@@ -264,13 +274,27 @@ export class MainViewModel extends Observable {
const faceHeight = 230; const faceHeight = 230;
const available = const available =
this._layoutOrientation === "landscape" this._layoutOrientation === "landscape"
? // The landscape side panel column (see main-page.xml) minus its ? 345 // Matches the unpadded landscape controls column in main-page.xml.
// m-l-16 margin and the controls' own 8+8 margins.
360 - 32
: Screen.mainScreen.widthDIPs - 56; // p-20 padding + controls margins : Screen.mainScreen.widthDIPs - 56; // p-20 padding + controls margins
return Math.min(available, Math.round(faceHeight * 1.5)); 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" { get portraitLayoutVisibility(): "visible" | "collapse" {
return this._layoutOrientation === "portrait" ? "visible" : "collapse"; return this._layoutOrientation === "portrait" ? "visible" : "collapse";
} }
+40 -41
View File
@@ -20,9 +20,9 @@
acts as star, and this component sits in a bounded (star-row) parent, 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. --> where that would balloon the first grid to fill all remaining height. -->
<GridLayout row="0" rows="auto" columns="*,*,*,auto,auto" class="controls-tab-bar"> <GridLayout row="0" rows="auto" columns="*,*,*,auto,auto" class="controls-tab-bar">
<Button col="0" text="Settings" tap="{{ onSettingsTabTap }}" class="{{ settingsTabClass }}" /> <Button col="0" text="Settings" textWrap="false" tap="{{ onSettingsTabTap }}" class="{{ settingsTabClass }}" />
<Button col="1" text="Watch" tap="{{ onWatchTabTap }}" class="{{ watchTabClass }}" /> <Button col="1" text="Watch" textWrap="false" tap="{{ onWatchTabTap }}" class="{{ watchTabClass }}" />
<Button col="2" text="Ring" tap="{{ onRingTabTap }}" class="{{ ringTabClass }}" /> <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 <!-- 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 explicit star row makes the cell fill the tile's height so the icon's
center alignment has room to work in. --> center alignment has room to work in. -->
@@ -34,48 +34,47 @@
</GridLayout> </GridLayout>
</GridLayout> </GridLayout>
<!-- Settings tab --> <GridLayout row="1" layoutChanged="{{ onControlsContentLayoutChanged }}">
<StackLayout row="1" visibility="{{ settingsTabVisibility }}"> <!-- Settings tab -->
<GridLayout rows="auto" columns="auto,*" class="settings-row"> <StackLayout visibility="{{ settingsTabVisibility }}">
<Label col="0" text="Screen size" class="settings-row-label" verticalAlignment="center" /> <GridLayout rows="auto" columns="auto,*" class="settings-row">
<Button col="1" text="{{ displayModeLabel }}" tap="{{ onDisplayModeTap }}" class="mode-button" horizontalAlignment="left" /> <Label col="0" text="Screen size" class="settings-row-label" verticalAlignment="center" />
</GridLayout> <Button col="1" text="{{ displayModeLabel }}" tap="{{ onDisplayModeTap }}" class="mode-button" horizontalAlignment="left" />
<GridLayout rows="auto" columns="auto,*,auto" class="settings-row"> </GridLayout>
<Label col="0" text="☀" class="brightness-icon" verticalAlignment="center" /> <GridLayout rows="auto" columns="auto,*,auto" class="settings-row">
<Slider col="1" width="100%" minValue="0" maxValue="100" value="{{ brightnessPercent }}" valueChange="{{ onBrightnessChange }}" isEnabled="{{ brightnessSliderEnabled }}" /> <Label col="0" text="☀" class="brightness-icon" verticalAlignment="center" />
<StackLayout col="2" orientation="horizontal" verticalAlignment="center" class="auto-toggle"> <Slider col="1" width="100%" minValue="0" maxValue="100" value="{{ brightnessPercent }}" valueChange="{{ onBrightnessChange }}" isEnabled="{{ brightnessSliderEnabled }}" />
<Label text="Auto" verticalAlignment="center" /> <StackLayout col="2" orientation="horizontal" verticalAlignment="center" class="auto-toggle">
<Switch checked="{{ brightnessAuto }}" checkedChange="{{ onBrightnessAutoChange }}" /> <Label text="Auto" verticalAlignment="center" />
</StackLayout> <Switch checked="{{ brightnessAuto }}" checkedChange="{{ onBrightnessAutoChange }}" />
</GridLayout> </StackLayout>
</StackLayout> </GridLayout>
</StackLayout>
<!-- Watch tab: centered in the leftover height, capped at the 1.5:1 face <!-- Watch tab: centered in the leftover height, capped at the 1.5:1 face
aspect (watchFaceWidth = min(available, 1.5 x face height). --> aspect (watchFaceWidth = min(available, 1.5 x face height). -->
<StackLayout row="1" visibility="{{ watchTabVisibility }}" width="{{ watchFaceWidth }}" horizontalAlignment="center" verticalAlignment="center"> <GridLayout visibility="{{ watchTabVisibility }}" width="{{ watchFaceWidth }}" height="{{ watchFaceHeight }}" horizontalAlignment="center" verticalAlignment="center" class="touchpad" tap="{{ onPadTap }}" doubleTap="{{ onPadDoubleTap }}" longPress="{{ onPadLongPress }}" swipe="{{ onPadSwipe }}" touch="{{ onPadTouch }}">
<GridLayout class="touchpad" tap="{{ onPadTap }}" doubleTap="{{ onPadDoubleTap }}" longPress="{{ onPadLongPress }}" swipe="{{ onPadSwipe }}" touch="{{ onPadTouch }}">
<Label text="{{ padFocusLine }}" class="pad-focus" horizontalAlignment="center" verticalAlignment="center" /> <Label text="{{ padFocusLine }}" class="pad-focus" horizontalAlignment="center" verticalAlignment="center" />
<Label text="▲▼ swipe ● select ●● back ‒ menu" class="pad-legend" horizontalAlignment="center" verticalAlignment="bottom" /> <Label text="▲▼ swipe ● select ●● back ‒ menu" class="pad-legend" horizontalAlignment="center" verticalAlignment="bottom" />
</GridLayout> </GridLayout>
</StackLayout>
<!-- Ring tab: a touchpad on the ring's own scheme. Vertical swipes only <!-- 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 (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 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 physical ring has on its touch strip (they don't take touches); the star
rows are the seven equal gaps around them, edges included. --> rows are the seven equal gaps around them, edges included. -->
<GridLayout row="1" visibility="{{ ringTabVisibility }}" class="touchpad ring-touchpad" <GridLayout visibility="{{ ringTabVisibility }}" height="{{ ringTouchpadHeight }}" class="touchpad ring-touchpad"
rows="*,auto,*,auto,*,auto,*,auto,*,auto,*,auto,*" rows="*,auto,*,auto,*,auto,*,auto,*,auto,*,auto,*"
horizontalAlignment="center" verticalAlignment="center" horizontalAlignment="center" verticalAlignment="center"
tap="{{ onRingPadTap }}" doubleTap="{{ onRingPadDoubleTap }}" tap="{{ onRingPadTap }}" doubleTap="{{ onRingPadDoubleTap }}"
longPress="{{ onRingPadLongPress }}" swipe="{{ onRingPadSwipe }}" longPress="{{ onRingPadLongPress }}" swipe="{{ onRingPadSwipe }}"
touch="{{ onRingPadTouch }}"> touch="{{ onRingPadTouch }}">
<Label row="1" class="ring-pad-marking" isUserInteractionEnabled="false" /> <Label row="1" class="ring-pad-marking" isUserInteractionEnabled="false" />
<Label row="3" 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="5" class="ring-pad-marking" isUserInteractionEnabled="false" />
<Label row="7" 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="9" class="ring-pad-marking" isUserInteractionEnabled="false" />
<Label row="11" class="ring-pad-marking" isUserInteractionEnabled="false" /> <Label row="11" class="ring-pad-marking" isUserInteractionEnabled="false" />
</GridLayout>
</GridLayout> </GridLayout>
</GridLayout> </GridLayout>
+11
View File
@@ -285,6 +285,17 @@ export const lockScreenEnabledSetting = new ConfigSettingBoolean({
// Phone display: the phone app's mirror of the glasses screen and the // Phone display: the phone app's mirror of the glasses screen and the
// controls around it on the main page. // controls around it on the main page.
export type PreviewColor = "white" | "green"; export type PreviewColor = "white" | "green";
export type PhoneRotation = "auto" | "portrait" | "landscape";
export const phoneRotationSetting = new ConfigSettingEnum<PhoneRotation>({
id: "phone-rotation",
label: "Rotation",
storageKey: "phone.rotation",
defaultValue: "auto",
values: ["auto", "portrait", "landscape"],
formatValue: (value) => ({ auto: "Auto-Rotate", portrait: "Always Portrait", landscape: "Always Landscape" })[value],
description: "Automatically rotate with the phone, or keep the phone app in portrait or landscape. Auto-Rotate follows the phone's system rotation preference.",
});
export const previewColorSetting = new ConfigSettingEnum<PreviewColor>({ export const previewColorSetting = new ConfigSettingEnum<PreviewColor>({
id: "preview-color", id: "preview-color",
+2
View File
@@ -48,6 +48,7 @@ import {
navigateWorkAddressSetting, navigateWorkAddressSetting,
openAiApiKeySetting, openAiApiKeySetting,
previewColorSetting, previewColorSetting,
phoneRotationSetting,
ringConnectionModeSetting, ringConnectionModeSetting,
sonioxApiKeySetting, sonioxApiKeySetting,
enumSettingMenuItem, enumSettingMenuItem,
@@ -177,6 +178,7 @@ function settingsSections(): SettingsSection[] {
// The phone app's mirror of the glasses screen and its controls // The phone app's mirror of the glasses screen and its controls
// (app/phone-ui/): all read live by the main page. // (app/phone-ui/): all read live by the main page.
items: [ items: [
enumSettingMenuItem(phoneRotationSetting),
enumSettingMenuItem(previewColorSetting), enumSettingMenuItem(previewColorSetting),
toggleSettingMenuItem(mirrorTouchSetting), toggleSettingMenuItem(mirrorTouchSetting),
], ],