forked from Blendman974/faceclaw
Phone screen input shows gesture help for wake (and not random other gesture-help)
This commit is contained in:
1 parent
22c31f4240
commit
f01214f4a0
8 files changed
+73
-12
No files matched your search
@@ -93,7 +93,7 @@ import { createNotificationsAppWindow, NOTIFICATIONS_SURFACE_ID, NOTIFICATIONS_W
|
|||||||
import { isInstalledPackagePresent } from "../apps/evenhub/updates";
|
import { isInstalledPackagePresent } from "../apps/evenhub/updates";
|
||||||
import { wearerVerificationOptions } from "../apps/microphones/speakers";
|
import { wearerVerificationOptions } from "../apps/microphones/speakers";
|
||||||
import { micSession } from "../apps/microphones/mic-session";
|
import { micSession } from "../apps/microphones/mic-session";
|
||||||
import { glassesDisplayLabel } from "./glasses-display-state";
|
import { glassesDisplayAsleep, glassesDisplayLabel, type GlassesDisplayState } from "./glasses-display-state";
|
||||||
import { PreviewDisplayTarget, type DisplayTarget } from "../native/preview-display";
|
import { PreviewDisplayTarget, type DisplayTarget } from "../native/preview-display";
|
||||||
|
|
||||||
type ConnectionPhase = "disconnected" | "connecting" | "connected" | "charging" | "disconnecting";
|
type ConnectionPhase = "disconnected" | "connecting" | "connected" | "charging" | "disconnecting";
|
||||||
@@ -1171,14 +1171,23 @@ class DashboardController {
|
|||||||
|
|
||||||
/** What occupies the foreground-title line on the watch-style controls. */
|
/** What occupies the foreground-title line on the watch-style controls. */
|
||||||
glassesDisplayLabel(): string {
|
glassesDisplayLabel(): string {
|
||||||
return glassesDisplayLabel({
|
return glassesDisplayLabel(this.glassesDisplayState());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether that line reads "Display off" (the watch face adds a wake hint under it). */
|
||||||
|
glassesDisplayAsleep(): boolean {
|
||||||
|
return glassesDisplayAsleep(this.glassesDisplayState());
|
||||||
|
}
|
||||||
|
|
||||||
|
private glassesDisplayState(): GlassesDisplayState {
|
||||||
|
return {
|
||||||
phase: this.phase,
|
phase: this.phase,
|
||||||
silentMode: this.silentMode,
|
silentMode: this.silentMode,
|
||||||
screenOn: shell.isScreenOn(),
|
screenOn: shell.isScreenOn(),
|
||||||
battery: this.lastHeadsetBattery,
|
battery: this.lastHeadsetBattery,
|
||||||
foregroundTitle: shell.getForegroundApp()?.title ?? null,
|
foregroundTitle: shell.getForegroundApp()?.title ?? null,
|
||||||
previewMode: this.isPreviewDisplayActive(),
|
previewMode: this.isPreviewDisplayActive(),
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,12 +23,25 @@ export function glassesDisplayLabel(state: GlassesDisplayState): string {
|
|||||||
if (state.silentMode) {
|
if (state.silentMode) {
|
||||||
return "Silent mode";
|
return "Silent mode";
|
||||||
}
|
}
|
||||||
if (!state.screenOn) {
|
if (glassesDisplayAsleep(state)) {
|
||||||
return "Display off";
|
return "Display off";
|
||||||
}
|
}
|
||||||
return state.foregroundTitle || "Launcher";
|
return state.foregroundTitle || "Launcher";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True when the label reads "Display off": the screen is dark but the glasses
|
||||||
|
* (or the preview standing in for them) would light it on a wake gesture.
|
||||||
|
*/
|
||||||
|
export function glassesDisplayAsleep(state: GlassesDisplayState): boolean {
|
||||||
|
return (
|
||||||
|
state.phase !== "charging" &&
|
||||||
|
(state.phase === "connected" || state.previewMode) &&
|
||||||
|
!state.silentMode &&
|
||||||
|
!state.screenOn
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function chargingDisplayLabel(battery: number | null): string {
|
export function chargingDisplayLabel(battery: number | null): string {
|
||||||
return validBatteryLevel(battery) ? `Charging · G2 ${battery}%` : "Charging";
|
return validBatteryLevel(battery) ? `Charging · G2 ${battery}%` : "Charging";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1127,8 +1127,14 @@ export class MainViewModel extends RemoteControlsViewModel {
|
|||||||
return dashboardController.glassesDisplayLabel();
|
return dashboardController.glassesDisplayLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override get padDisplayAsleep(): boolean {
|
||||||
|
return dashboardController.glassesDisplayAsleep();
|
||||||
|
}
|
||||||
|
|
||||||
private refreshPadFocusLine(): void {
|
private refreshPadFocusLine(): void {
|
||||||
this.notifyPropertyChange("padFocusLine", this.padFocusLine);
|
this.notifyPropertyChange("padFocusLine", this.padFocusLine);
|
||||||
|
this.notifyPropertyChange("padFocusClass", this.padFocusClass);
|
||||||
|
this.notifyPropertyChange("padWakeHintVisibility", this.padWakeHintVisibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onPadTap(): Promise<void> {
|
async onPadTap(): Promise<void> {
|
||||||
|
|||||||
@@ -33,6 +33,23 @@ export class RemoteControlsViewModel extends Observable {
|
|||||||
return this._controlsTab === "ring" ? "tab-button tab-button-selected" : "tab-button";
|
return this._controlsTab === "ring" ? "tab-button tab-button-selected" : "tab-button";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The watch face's status line reads "Display off": dim it and show the wake
|
||||||
|
* gesture under it. The host overrides this and notifies padFocusClass and
|
||||||
|
* padWakeHintVisibility when it changes.
|
||||||
|
*/
|
||||||
|
protected get padDisplayAsleep(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
get padFocusClass(): string {
|
||||||
|
return this.padDisplayAsleep ? "pad-focus pad-focus-asleep" : "pad-focus";
|
||||||
|
}
|
||||||
|
|
||||||
|
get padWakeHintVisibility(): "visible" | "collapse" {
|
||||||
|
return this.padDisplayAsleep ? "visible" : "collapse";
|
||||||
|
}
|
||||||
|
|
||||||
onSettingsTabTap(): void {
|
onSettingsTabTap(): void {
|
||||||
this.setControlsTab("settings");
|
this.setControlsTab("settings");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,10 +104,14 @@
|
|||||||
font-size: 20;
|
font-size: 20;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
.pad-legend {
|
/* "Display off": dimmed like the dark screen it describes. */
|
||||||
font-size: 11;
|
.pad-focus-asleep {
|
||||||
color: #8a8a8a;
|
color: #8a8a8a;
|
||||||
margin-bottom: 8;
|
}
|
||||||
|
.pad-wake-hint {
|
||||||
|
font-size: 13;
|
||||||
|
color: #6a6a6a;
|
||||||
|
margin-top: 4;
|
||||||
}
|
}
|
||||||
.action-row {
|
.action-row {
|
||||||
margin-top: 6;
|
margin-top: 6;
|
||||||
|
|||||||
@@ -52,10 +52,12 @@
|
|||||||
</StackLayout>
|
</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). The star
|
||||||
<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 }}">
|
rows center the status line, plus the wake hint under it while the
|
||||||
<Label isUserInteractionEnabled="false" text="{{ padFocusLine }}" class="pad-focus" horizontalAlignment="center" verticalAlignment="center" />
|
display is off (a double-tap is the only gesture that wakes it). -->
|
||||||
<Label isUserInteractionEnabled="false" text="▲▼ swipe ● select ●● back ‒ menu" class="pad-legend" horizontalAlignment="center" verticalAlignment="bottom" />
|
<GridLayout visibility="{{ watchTabVisibility }}" width="{{ watchFaceWidth }}" height="{{ watchFaceHeight }}" rows="*,auto,auto,*" horizontalAlignment="center" verticalAlignment="center" class="touchpad" android:tap="{{ onPadTap }}" android:doubleTap="{{ onPadDoubleTap }}" android:longPress="{{ onPadLongPress }}" android:swipe="{{ onPadSwipe }}" touch="{{ onPadTouch }}">
|
||||||
|
<Label row="1" isUserInteractionEnabled="false" text="{{ padFocusLine }}" class="{{ padFocusClass }}" horizontalAlignment="center" />
|
||||||
|
<Label row="2" isUserInteractionEnabled="false" text="●● wake" visibility="{{ padWakeHintVisibility }}" class="pad-wake-hint" horizontalAlignment="center" />
|
||||||
</GridLayout>
|
</GridLayout>
|
||||||
|
|
||||||
<!-- 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
|
||||||
|
|||||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
|||||||
const test = require("node:test");
|
const test = require("node:test");
|
||||||
const assert = require("node:assert/strict");
|
const assert = require("node:assert/strict");
|
||||||
|
|
||||||
const { chargingDisplayLabel, glassesDisplayLabel } = require("../.test-build/app/g2/glasses-display-state.js");
|
const { chargingDisplayLabel, glassesDisplayAsleep, glassesDisplayLabel } = require("../.test-build/app/g2/glasses-display-state.js");
|
||||||
|
|
||||||
const connected = {
|
const connected = {
|
||||||
phase: "connected",
|
phase: "connected",
|
||||||
@@ -9,6 +9,7 @@ const connected = {
|
|||||||
screenOn: true,
|
screenOn: true,
|
||||||
battery: 72,
|
battery: 72,
|
||||||
foregroundTitle: "Music",
|
foregroundTitle: "Music",
|
||||||
|
previewMode: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
test("the foreground-title line covers visible, dark, and silent displays", () => {
|
test("the foreground-title line covers visible, dark, and silent displays", () => {
|
||||||
@@ -18,6 +19,15 @@ test("the foreground-title line covers visible, dark, and silent displays", () =
|
|||||||
assert.equal(glassesDisplayLabel({ ...connected, screenOn: false, silentMode: true }), "Silent mode");
|
assert.equal(glassesDisplayLabel({ ...connected, screenOn: false, silentMode: true }), "Silent mode");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("only the Display off state counts as asleep (the watch face's wake hint)", () => {
|
||||||
|
assert.equal(glassesDisplayAsleep({ ...connected, screenOn: false }), true);
|
||||||
|
assert.equal(glassesDisplayAsleep({ ...connected, phase: "disconnected", screenOn: false, previewMode: true }), true);
|
||||||
|
assert.equal(glassesDisplayAsleep(connected), false);
|
||||||
|
assert.equal(glassesDisplayAsleep({ ...connected, screenOn: false, silentMode: true }), false);
|
||||||
|
assert.equal(glassesDisplayAsleep({ ...connected, phase: "charging", screenOn: false }), false);
|
||||||
|
assert.equal(glassesDisplayAsleep({ ...connected, phase: "disconnected", screenOn: false }), false);
|
||||||
|
});
|
||||||
|
|
||||||
test("charging takes precedence and includes the last-known G2 battery", () => {
|
test("charging takes precedence and includes the last-known G2 battery", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
glassesDisplayLabel({ ...connected, phase: "charging", silentMode: true, screenOn: false }),
|
glassesDisplayLabel({ ...connected, phase: "charging", silentMode: true, screenOn: false }),
|
||||||
|
|||||||
Reference in new issue
Block a user