Merge silent-mode feedback

# Conflicts:
#	tests/kotlin/src/commonTest/kotlin/com/faceclaw/app/GlassesSessionCoreTest.kt
This commit is contained in:
Blendman974 committed 2026-11-06 21:48:38 +01:00
commit 3aeed72f5d
8 files changed
+128 -5

No files matched your search

+31 -3
View File
@@ -121,6 +121,7 @@ export type DashboardSnapshot = {
* glasses, and this says which harmless thing is actually going on.
*/
displayPreviewMessage: string;
silentModeFeedback: string;
activeTextSettingId: string | null;
activeTextEditorTitle: string;
activeTextSettingTitle: string;
@@ -294,6 +295,8 @@ class DashboardController {
/** The screen area displayPreview shows (Preview scaling), or null for the whole panel. */
private displayPreviewCrop: ScreenRect | null = null;
private silentMode = false;
private silentModeFeedback = "";
private silentModeFeedbackTimer: ReturnType<typeof setTimeout> | null = null;
// Brightness value last pushed to the glasses; see pushBrightness.
private lastPushedBrightness: string | null = null;
private lastPushedHeadUp: string | null = null;
@@ -1160,6 +1163,7 @@ class DashboardController {
status: this.status,
displayPreview: this.displayPreview,
displayPreviewMessage: this.displayPreviewMessage(),
silentModeFeedback: this.silentModeFeedback,
activeTextSettingId: primaryTextSetting?.id ?? null,
activeTextEditorTitle: this.activeTextEditorTitle,
activeTextSettingTitle: primaryTextSetting?.editorTitle ?? "",
@@ -1199,6 +1203,29 @@ class DashboardController {
* charging and silent mode both make the display unavailable while BLE stays
* up, and a battery that just ran out simply stops answering.
*/
private handleSilentMode(silent: boolean): void {
if (this.silentMode === silent) return;
this.silentMode = silent;
if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer);
this.silentModeFeedbackTimer = null;
this.silentModeFeedback = silent
? "Silent mode enabled — hold both touchpads to exit"
: "Silent mode disabled";
if (!silent) {
// Do not wake a sleeping/locked display merely to announce a state change.
if (this.phase === "connected" && shell.isScreenOn() && !this.glassesLocked) {
shell.showAlert("Silent mode disabled");
shell.foregroundWindow()?.requestRender();
}
this.silentModeFeedbackTimer = setTimeout(() => {
this.silentModeFeedbackTimer = null;
this.silentModeFeedback = "";
this.emit();
}, 5000);
}
this.emit();
}
private displayPreviewMessage(): string {
if (this.phase === "charging") {
return chargingPreviewMessage(this.glassesDisplayState());
@@ -1624,9 +1651,7 @@ class DashboardController {
});
});
this.offSilentMode = communicator.onSilentMode((silent) => {
if (this.silentMode === silent) return;
this.silentMode = silent;
this.emit();
this.handleSilentMode(silent);
});
this.offWearState = communicator.onWearState((wearing) => {
this.handleWearState(wearing);
@@ -3004,6 +3029,9 @@ class DashboardController {
// Kept across "connecting": silent mode blocks app launches, so it can
// itself cause the reconnect churn, and Java re-reports it either way.
this.silentMode = false;
if (this.silentModeFeedbackTimer !== null) clearTimeout(this.silentModeFeedbackTimer);
this.silentModeFeedbackTimer = null;
this.silentModeFeedback = "";
}
this.emit();
}