forked from Blendman974/faceclaw
Merge branch 'main' of https://github.com/jimrandomh/faceclaw
This commit is contained in:
commit
43738b181d
28 files changed
+1062
-95
No files matched your search
@@ -20,11 +20,11 @@ const PERM_GAP = 4;
|
||||
* Cancel (or double-click) backs out. A privacy-policy-only app still reaches
|
||||
* this dialog so the user can review the policy before allowing first run.
|
||||
*
|
||||
* When the list overflows the viewport the dialog scrolls: scroll events move
|
||||
* through the content row by row, and only once the bottom is fully visible do
|
||||
* further scrolls move the action selection. The actions are inert until then
|
||||
* (a click just scrolls), so the user can't Allow without having had the whole
|
||||
* list on screen.
|
||||
* When the list overflows the viewport the dialog scrolls a page at a time,
|
||||
* keeping one line of overlap (the last line of one page is the first of the
|
||||
* next), and only once the bottom is fully visible do further scrolls move the
|
||||
* action selection. The actions are inert until then (a click just pages
|
||||
* down), so the user can't Allow without having had the whole list on screen.
|
||||
*/
|
||||
export class EvenHubPermissionDialogLayer implements Layer {
|
||||
/** Floats in front of the window content, like the context menus. */
|
||||
@@ -35,6 +35,9 @@ export class EvenHubPermissionDialogLayer implements Layer {
|
||||
private firstRow = 0;
|
||||
/** Scroll position at which the last row is fully visible; set by paint. */
|
||||
private maxFirstRow = 0;
|
||||
/** Heights of the content rows and of the viewport they scroll in, as last painted (for paging). */
|
||||
private rowHeights: number[] = [];
|
||||
private visibleHeight = 0;
|
||||
private resolved = false;
|
||||
|
||||
constructor(
|
||||
@@ -125,6 +128,8 @@ export class EvenHubPermissionDialogLayer implements Layer {
|
||||
}
|
||||
this.maxFirstRow = maxFirstRow;
|
||||
this.firstRow = Math.max(0, Math.min(this.firstRow, maxFirstRow));
|
||||
this.rowHeights = rows.map((row) => row.height);
|
||||
this.visibleHeight = visibleHeight;
|
||||
|
||||
// Fill 1 (transparent color key is 0), outline for the dialog edge.
|
||||
image.fillRoundedRect(dialogX, dialogY, dialogWidth, height, 1);
|
||||
@@ -159,19 +164,19 @@ export class EvenHubPermissionDialogLayer implements Layer {
|
||||
if (this.atBottom() && this.selectedIndex > 0) {
|
||||
this.selectedIndex -= 1;
|
||||
} else if (this.firstRow > 0) {
|
||||
this.firstRow -= 1;
|
||||
this.pageUp();
|
||||
}
|
||||
return;
|
||||
case "scroll-down":
|
||||
if (!this.atBottom()) {
|
||||
this.firstRow += 1;
|
||||
this.pageDown();
|
||||
} else {
|
||||
this.selectedIndex = Math.min(actions.length - 1, this.selectedIndex + 1);
|
||||
}
|
||||
return;
|
||||
case "click":
|
||||
if (!this.atBottom()) {
|
||||
this.firstRow += 1;
|
||||
this.pageDown();
|
||||
return;
|
||||
}
|
||||
if (actions[this.selectedIndex] === "Privacy policy") {
|
||||
@@ -188,6 +193,29 @@ export class EvenHubPermissionDialogLayer implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
/** Scroll so the last fully visible row becomes the first (one row of overlap). */
|
||||
private pageDown(): void {
|
||||
let y = 0;
|
||||
let lastVisible = this.firstRow;
|
||||
for (let index = this.firstRow; index < this.rowHeights.length; index++) {
|
||||
y += this.rowHeights[index]!;
|
||||
if (y > this.visibleHeight) break;
|
||||
lastVisible = index;
|
||||
}
|
||||
this.firstRow = Math.min(this.maxFirstRow, Math.max(this.firstRow + 1, lastVisible));
|
||||
}
|
||||
|
||||
/** Scroll so the current first row becomes the last fully visible one (one row of overlap). */
|
||||
private pageUp(): void {
|
||||
let first = this.firstRow;
|
||||
let y = this.rowHeights[first] ?? 0;
|
||||
while (first > 0 && y + this.rowHeights[first - 1]! <= this.visibleHeight) {
|
||||
first -= 1;
|
||||
y += this.rowHeights[first]!;
|
||||
}
|
||||
this.firstRow = Math.max(0, Math.min(this.firstRow - 1, first));
|
||||
}
|
||||
|
||||
onRemoved(): void {
|
||||
// Dismissed some other way (window closed, back button): treat as cancel.
|
||||
if (!this.resolved) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { GrayImage, type UiFont } from "../../graphics/image";
|
||||
import { truncateText, wrapText } from "../../graphics/textwrap";
|
||||
import { GESTURE_CLICK, type InputEvent } from "../../ui/gestures";
|
||||
import { directionalFallback, GESTURE_CLICK, isDirectionalInput, type InputEvent } from "../../ui/gestures";
|
||||
import { type Layer, type LayerActions, type LayerContext, type LayerStack } from "../../ui/layers";
|
||||
import { drawSelectionHighlight, type MenuItem } from "../../ui/menu";
|
||||
import { Menu } from "../../ui/menu-core";
|
||||
@@ -55,7 +55,32 @@ type StoreRow =
|
||||
/** The Search tab's first row: shows the query and opens the phone editor. */
|
||||
| { kind: "search-query" }
|
||||
/** A registry entry whose package is gone and which the store no longer lists. */
|
||||
| { kind: "orphan"; update: EvenHubAppUpdate };
|
||||
| { kind: "orphan"; update: EvenHubAppUpdate }
|
||||
/** The Updates tab's first row while any update is installable; `busy` while Update All runs. */
|
||||
| { kind: "update-all"; count: number; busy: boolean };
|
||||
|
||||
type AppRow = Extract<StoreRow, { kind: "app" }>;
|
||||
|
||||
/** An Updates row that installing the store's version would satisfy. */
|
||||
function isUpdatableRow(row: StoreRow): row is AppRow {
|
||||
return row.kind === "app" && row.update !== undefined;
|
||||
}
|
||||
|
||||
/** An Updates row for one installed app (not the Update All row). */
|
||||
function isInstalledAppRow(row: StoreRow): boolean {
|
||||
return row.kind === "app" || row.kind === "orphan";
|
||||
}
|
||||
|
||||
function rowPackageId(row: StoreRow): string | undefined {
|
||||
switch (row.kind) {
|
||||
case "app":
|
||||
return row.app.packageId;
|
||||
case "orphan":
|
||||
return row.update.installed.packageId;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
type TabState = {
|
||||
rows: StoreRow[];
|
||||
@@ -118,10 +143,13 @@ export type EvenHubStoreLayerOptions = {
|
||||
* The EvenHub storefront: Top (leaderboard), New (by first publication),
|
||||
* Search, and Updates (installed apps that are stale or whose package is
|
||||
* missing). The tab row is its own focus level above the list: double-click
|
||||
* in the list focuses the tabs, scrolling there switches tabs, and a click
|
||||
* returns to the list.
|
||||
* in the list focuses the tabs, scrolling (or a watch swipe in any direction)
|
||||
* there switches tabs, and a click returns to the list.
|
||||
*/
|
||||
export class EvenHubStoreLayer implements Layer {
|
||||
/** Swipes left/right switch tabs on the tab strip; elsewhere they get the usual fallback. */
|
||||
readonly acceptsDirectional = true;
|
||||
|
||||
private readonly tabs: Record<StoreTab, TabState> = {
|
||||
top: emptyTab(),
|
||||
new: emptyTab(),
|
||||
@@ -229,7 +257,7 @@ export class EvenHubStoreLayer implements Layer {
|
||||
const label = TABS.find((entry) => entry.id === tab)!.label;
|
||||
if (tab !== "updates") return label;
|
||||
const updates = this.tabs.updates;
|
||||
const count = updates.rows.filter((row) => row.kind !== "search-query").length;
|
||||
const count = updates.rows.filter(isInstalledAppRow).length;
|
||||
return updates.loaded && count > 0 ? `${label} (${count})` : label;
|
||||
}
|
||||
|
||||
@@ -245,9 +273,11 @@ export class EvenHubStoreLayer implements Layer {
|
||||
if (!state.query) return "Search public apps";
|
||||
return results === 1 ? `1 result for "${state.query}"` : `${results} results for "${state.query}"`;
|
||||
}
|
||||
case "updates":
|
||||
case "updates": {
|
||||
if (!state.loaded) return "Installed apps with newer versions";
|
||||
return count === 0 ? "All installed apps are up to date" : count === 1 ? "1 app needs attention" : `${count} apps need attention`;
|
||||
const apps = state.rows.filter(isInstalledAppRow).length;
|
||||
return apps === 0 ? "All installed apps are up to date" : apps === 1 ? "1 app needs attention" : `${apps} apps need attention`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +293,10 @@ export class EvenHubStoreLayer implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
async handleInput(event: InputEvent, ctx: LayerContext): Promise<void> {
|
||||
async handleInput(rawEvent: InputEvent, ctx: LayerContext): Promise<void> {
|
||||
const tabSwipe = !this.showingLogin && this.focus === "tabs"
|
||||
&& (rawEvent.type === "swipe-left" || rawEvent.type === "swipe-right");
|
||||
const event = isDirectionalInput(rawEvent) && !tabSwipe ? directionalFallback(rawEvent) : rawEvent;
|
||||
if (this.showingLogin) {
|
||||
if (event.type === "click" && !this.loginBusy) {
|
||||
this.openCredentialEditor(ctx);
|
||||
@@ -301,9 +334,11 @@ export class EvenHubStoreLayer implements Layer {
|
||||
const index = TABS.findIndex((tab) => tab.id === this.activeTab);
|
||||
switch (event.type) {
|
||||
case "scroll-up":
|
||||
case "swipe-left":
|
||||
this.switchTab(ctx, TABS[Math.max(0, index - 1)]!.id);
|
||||
return;
|
||||
case "scroll-down":
|
||||
case "swipe-right":
|
||||
this.switchTab(ctx, TABS[Math.min(TABS.length - 1, index + 1)]!.id);
|
||||
return;
|
||||
case "click":
|
||||
@@ -333,6 +368,9 @@ export class EvenHubStoreLayer implements Layer {
|
||||
case "search-query":
|
||||
this.openSearchEditor(ctx);
|
||||
return;
|
||||
case "update-all":
|
||||
void this.updateAll(ctx);
|
||||
return;
|
||||
case "orphan": {
|
||||
// Nothing can be reinstalled; the only useful action is to drop the
|
||||
// dead registry entry so the launcher stops offering it.
|
||||
@@ -532,8 +570,7 @@ export class EvenHubStoreLayer implements Layer {
|
||||
const rows: StoreRow[] = updates.map((update) =>
|
||||
update.latest ? { kind: "app", app: update.latest, update } : { kind: "orphan", update },
|
||||
);
|
||||
state.rows = rows;
|
||||
state.menu.setItems(rows, 0);
|
||||
this.setUpdateRows(state, rows, 0);
|
||||
state.menu.scrollTop = 0;
|
||||
state.status = "";
|
||||
state.exhausted = true;
|
||||
@@ -548,10 +585,20 @@ export class EvenHubStoreLayer implements Layer {
|
||||
}
|
||||
}
|
||||
|
||||
private updatableRows(): Extract<StoreRow, { kind: "app" }>[] {
|
||||
return this.tabs.updates.rows.filter(
|
||||
(row): row is Extract<StoreRow, { kind: "app" }> => row.kind === "app" && row.update !== undefined,
|
||||
);
|
||||
private updatableRows(): AppRow[] {
|
||||
return this.tabs.updates.rows.filter(isUpdatableRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the Updates rows, putting an Update All row on top while any of
|
||||
* them can be installed (and dropping it once none can).
|
||||
*/
|
||||
private setUpdateRows(state: TabState, entries: readonly StoreRow[], selectedIndex?: number): void {
|
||||
const rows = entries.filter(isInstalledAppRow);
|
||||
const count = rows.filter(isUpdatableRow).length;
|
||||
if (count > 0) rows.unshift({ kind: "update-all", count, busy: this.updatingAll });
|
||||
state.rows = rows;
|
||||
state.menu.setItems(rows, selectedIndex);
|
||||
}
|
||||
|
||||
/** Install every pending update in turn; a declined permission dialog skips that app. */
|
||||
@@ -559,6 +606,7 @@ export class EvenHubStoreLayer implements Layer {
|
||||
if (this.updatingAll) return;
|
||||
this.updatingAll = true;
|
||||
const state = this.tabs.updates;
|
||||
this.setUpdateRows(state, state.rows);
|
||||
const pending = this.updatableRows();
|
||||
let installed = 0;
|
||||
const failures: string[] = [];
|
||||
@@ -593,6 +641,7 @@ export class EvenHubStoreLayer implements Layer {
|
||||
: installed === 1 ? "Updated 1 app." : `Updated ${installed} apps.`;
|
||||
} finally {
|
||||
this.updatingAll = false;
|
||||
this.setUpdateRows(this.tabs.updates, this.tabs.updates.rows);
|
||||
if (!this.closed) ctx.actions.requestRender();
|
||||
}
|
||||
}
|
||||
@@ -609,10 +658,7 @@ export class EvenHubStoreLayer implements Layer {
|
||||
|
||||
private removeUpdateRow(packageId: string): void {
|
||||
const state = this.tabs.updates;
|
||||
state.rows = state.rows.filter((row) =>
|
||||
row.kind === "search-query" ? true : row.kind === "app" ? row.app.packageId !== packageId : row.update.installed.packageId !== packageId,
|
||||
);
|
||||
state.menu.setItems(state.rows);
|
||||
this.setUpdateRows(state, state.rows.filter((row) => rowPackageId(row) !== packageId));
|
||||
}
|
||||
|
||||
// ---- login and phone editors --------------------------------------------
|
||||
@@ -751,6 +797,14 @@ function rowText(row: StoreRow): { title: string; detail: string; titleValue: nu
|
||||
titleValue: 200,
|
||||
};
|
||||
}
|
||||
case "update-all":
|
||||
return {
|
||||
title: row.busy ? "Updating..." : "Update All",
|
||||
detail: row.busy
|
||||
? "Installing updates; progress is shown above."
|
||||
: row.count === 1 ? "Install the 1 available update" : `Install all ${row.count} available updates`,
|
||||
titleValue: row.busy ? 150 : 230,
|
||||
};
|
||||
case "orphan":
|
||||
return {
|
||||
title: row.update.installed.name,
|
||||
|
||||
@@ -61,9 +61,28 @@ export const glanceboardEnabledSetting = new ConfigSettingBoolean({
|
||||
"While the display is asleep, a tap, a long-press or a head-tilt shows the Glanceboard instead of the regular UI. Double-tap still wakes the regular UI.",
|
||||
});
|
||||
|
||||
export type GlanceTapDuration = "off" | "3s" | "5s" | "7s" | "10s";
|
||||
const TAP_DURATION_SECONDS = {
|
||||
"3s": 3,
|
||||
"5s": 5,
|
||||
"7s": 7,
|
||||
"10s": 10,
|
||||
"20s": 20,
|
||||
"30s": 30,
|
||||
"1min": 60,
|
||||
} as const;
|
||||
|
||||
const DEFAULT_TAP_DURATION: GlanceTapDuration = "5s";
|
||||
type GlanceTapDurationTimed = keyof typeof TAP_DURATION_SECONDS;
|
||||
export type GlanceTapDuration = "off" | GlanceTapDurationTimed;
|
||||
|
||||
const TAP_DURATION_VALUES: readonly GlanceTapDuration[] = ["off", ...(Object.keys(TAP_DURATION_SECONDS) as GlanceTapDurationTimed[])];
|
||||
|
||||
const DEFAULT_TAP_DURATION: GlanceTapDurationTimed = "5s";
|
||||
|
||||
function formatTapDuration(value: GlanceTapDuration): string {
|
||||
if (value === "off") return "Disabled";
|
||||
const seconds = TAP_DURATION_SECONDS[value];
|
||||
return seconds % 60 === 0 ? `${seconds / 60} min` : `${seconds} s`;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long a tap (or head-tilt) keeps the board up; each further tap restarts
|
||||
@@ -75,8 +94,8 @@ export const glanceTapDurationSetting = new ConfigSettingEnum<GlanceTapDuration>
|
||||
label: "Show on tap",
|
||||
storageKey: "glanceboard.tapDuration",
|
||||
defaultValue: DEFAULT_TAP_DURATION,
|
||||
values: ["off", "3s", "5s", "7s", "10s"],
|
||||
formatValue: (value) => (value === "off" ? "Disabled" : value.replace("s", " s")),
|
||||
values: TAP_DURATION_VALUES,
|
||||
formatValue: formatTapDuration,
|
||||
description:
|
||||
"How long a single tap (or a head-tilt) keeps the Glanceboard on screen. Disabled: a single tap does not show the Glanceboard.",
|
||||
});
|
||||
@@ -88,8 +107,7 @@ export function glanceShowOnTap(): boolean {
|
||||
|
||||
export function glanceTapTimeoutMs(): number {
|
||||
const duration = glanceTapDurationSetting.get();
|
||||
const seconds = duration === "off" ? DEFAULT_TAP_DURATION : duration;
|
||||
return Number.parseInt(seconds, 10) * 1000;
|
||||
return TAP_DURATION_SECONDS[duration === "off" ? DEFAULT_TAP_DURATION : duration] * 1000;
|
||||
}
|
||||
|
||||
/** A long-press holds the board up until the press is released. */
|
||||
|
||||
@@ -14,7 +14,12 @@ const notificationsApp: AppDefinition = {
|
||||
if (listenerState === "no-access" || listenerState === "stuck") {
|
||||
requestNotificationListenerAccess();
|
||||
}
|
||||
return ctx.launchInProcessApp(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID, createNotificationsAppWindow);
|
||||
return ctx.launchInProcessApp(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID, (options) =>
|
||||
createNotificationsAppWindow(options, (section) => {
|
||||
void ctx.launchApp("settings", { section }).catch((error) => {
|
||||
ctx.appendLog(`settings launch failed: ${error}`);
|
||||
});
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NotificationsListLayer } from "../../ui/notifications";
|
||||
import { NotificationFilterLayer } from "../../ui/notification-filter";
|
||||
import { NOTIFICATIONS_SETTINGS_SECTION } from "../../ui/dashboard/settings-menus";
|
||||
import { onAndroidNotificationsChanged } from "../../native/notification-icons";
|
||||
import {
|
||||
createInProcessWindow,
|
||||
@@ -14,9 +14,13 @@ export const NOTIFICATIONS_SURFACE_ID = "window:notifications";
|
||||
/**
|
||||
* The Notifications app: the Android-notification list (previously a
|
||||
* dashboard page) in its own in-process window; selecting a notification
|
||||
* opens the detail view with its quick actions.
|
||||
* opens the detail view with its quick actions. `openSettings` opens a
|
||||
* Settings section (the menu's "Settings" goes to Notifications).
|
||||
*/
|
||||
export function createNotificationsAppWindow(options: InProcessAppOptions): InProcessWindow {
|
||||
export function createNotificationsAppWindow(
|
||||
options: InProcessAppOptions,
|
||||
openSettings: (section: string) => void,
|
||||
): InProcessWindow {
|
||||
// Newly posted notifications repaint the list while the window is open.
|
||||
let offNotificationsChanged: (() => void) | null = null;
|
||||
const created = createInProcessWindow({
|
||||
@@ -27,10 +31,10 @@ export function createNotificationsAppWindow(options: InProcessAppOptions): InPr
|
||||
icon: "bell",
|
||||
closeable: true,
|
||||
menuItems: () => [{
|
||||
label: "Notification filter",
|
||||
label: "Settings",
|
||||
onSelect: (ctx) => {
|
||||
ctx.stack.pop();
|
||||
ctx.stack.push(new NotificationFilterLayer());
|
||||
openSettings(NOTIFICATIONS_SETTINGS_SECTION);
|
||||
},
|
||||
}],
|
||||
actions: options.actions,
|
||||
|
||||
@@ -16,7 +16,6 @@ import { mediaControllerBridge } from "../native/media-controller";
|
||||
import { nightscoutBridge } from "../native/nightscout-bridge";
|
||||
import { weatherBridge } from "../native/weather";
|
||||
import { ALL_NOTIFICATIONS, onAndroidNotificationPosted, onAndroidNotificationRemoved, readActiveNotifications } from "../native/notification-icons";
|
||||
import { shouldShowNotificationOnGlasses } from "../native/notification-sources";
|
||||
import { watchNotificationListenerBinding } from "../native/notification-access";
|
||||
import { openEvenAppSettings, readEvenAppNotificationState } from "../native/even-app-conflict";
|
||||
import { defaultRingName, setGlassesRingLink } from "../native/ring-status";
|
||||
@@ -78,7 +77,7 @@ import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-a
|
||||
import { appViewportRect, isOnSwitcherEdge, screenHeight, screenWidth, sidebarStripVisible, type ScreenRect, type WindowHeightMode } from "../ui/shell/geometry";
|
||||
import { type ContinuousCaptureOptions, type LayerActions, type TextSettingsEditToggle, type TranscriptionChoice } from "../ui/layers";
|
||||
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
|
||||
import { appSwitcherPositionSetting, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, effectiveRingConnectionMode, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { appSwitcherPositionSetting, glassesTypeSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, effectiveRingConnectionMode, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, shouldPopUpNewNotification, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
|
||||
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
|
||||
import {
|
||||
getInstalledEvenHubAppById,
|
||||
@@ -449,7 +448,8 @@ class DashboardController {
|
||||
this.emit();
|
||||
},
|
||||
openNotificationsWindow: () =>
|
||||
this.openInProcessAppInBackground(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID, createNotificationsAppWindow),
|
||||
this.openInProcessAppInBackground(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID,
|
||||
(options) => createNotificationsAppWindow(options, (section) => this.openSettings(section))),
|
||||
onSwitcherBarHeightChanged: () => this.applySwitcherBarHeight(),
|
||||
onScreenStateChanged: (on) => {
|
||||
// Any wake of the regular UI replaces a showing Glanceboard.
|
||||
@@ -2644,11 +2644,7 @@ class DashboardController {
|
||||
setSurfaceVisible: (surfaceId, visible) => this.setWindowSurfaceVisible(surfaceId, visible),
|
||||
removeSurface: (surfaceId) => this.removeWindowSurface(surfaceId),
|
||||
requestShellRender: () => this.requestShellRender(),
|
||||
openSettings: (section) => {
|
||||
void this.launchApp("settings", { section }).catch((error) => {
|
||||
this.appendLog(`settings launch failed: ${this.formatError(error)}`);
|
||||
});
|
||||
},
|
||||
openSettings: (section) => this.openSettings(section),
|
||||
startTextSettingEdit: (settingId) => {
|
||||
const setting = getStringSettingById(settingId);
|
||||
if (setting) {
|
||||
@@ -2732,6 +2728,13 @@ class DashboardController {
|
||||
this.requestShellRender();
|
||||
}
|
||||
|
||||
/** Open or focus the Settings app, optionally on a section (by label). */
|
||||
private openSettings(section?: string): void {
|
||||
void this.launchApp("settings", { section }).catch((error) => {
|
||||
this.appendLog(`settings launch failed: ${this.formatError(error)}`);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch an app by id: the launcher grid, assistant tools, window-menu
|
||||
* Settings item, and open-apps restore all come through here. Apps with an
|
||||
@@ -2948,7 +2951,7 @@ class DashboardController {
|
||||
// The tray shows the notification at once; its popup waits out a short
|
||||
// delay, so one withdrawn right away (see NotificationPopupDelay) never shows.
|
||||
const notification = readActiveNotifications(ALL_NOTIFICATIONS).find((item) => item.key === notificationKey);
|
||||
if (notification && shouldShowNotificationOnGlasses(notification.packageName)) {
|
||||
if (notification && shouldPopUpNewNotification(notification.packageName)) {
|
||||
this.notificationPopups.post(notificationKey, notificationPopupDelayMs(notification));
|
||||
}
|
||||
this.requestShellRender();
|
||||
@@ -2970,7 +2973,7 @@ class DashboardController {
|
||||
private popUpAndroidNotification(notificationKey: string): void {
|
||||
try {
|
||||
const notification = readActiveNotifications(ALL_NOTIFICATIONS).find((item) => item.key === notificationKey);
|
||||
if (!notification || !shouldShowNotificationOnGlasses(notification.packageName)) return;
|
||||
if (!notification || !shouldPopUpNewNotification(notification.packageName)) return;
|
||||
// New notifications open a shell modal over the app viewport; if the
|
||||
// screen was off, wake for it and go back to sleep when it is closed.
|
||||
// Waking while already on would steal focus, so only wake from sleep.
|
||||
|
||||
@@ -2,7 +2,6 @@ import { startRemoteInput } from "../remote/service"
|
||||
import type { KeyboardInputSession } from '../ui/shell/keyboard-input'
|
||||
import { acceptInput, resetRingInputFilter } from "../ui/input-monitor";
|
||||
import { bindIosNotifications, iosNotificationsChanged, onIosNotificationPopup, readActiveNotifications } from '../native/notification-icons.ios'
|
||||
import { shouldShowNotificationOnGlasses } from '../native/notification-sources'
|
||||
import { launcherEntries } from '../apps/launcher'
|
||||
import { discardZeroedEvenHubPackage, getInstalledEvenHubAppById, installedEvenHubPackageId, uninstallEvenHubPackage } from '../apps/evenhub/installed-apps'
|
||||
import { isInstalledPackagePresent } from '../apps/evenhub/updates'
|
||||
@@ -54,7 +53,7 @@ import { onAnySettingChanged,
|
||||
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
|
||||
nightscoutSiteUrlSetting, nightscoutApiTokenSetting, voiceProviderSetting, elevenLabsApiKeySetting,
|
||||
openAiApiKeySetting, sonioxApiKeySetting, whisperServerApiKeySetting, whisperServerLanguageSetting,
|
||||
whisperServerModelSetting, whisperServerUrlSetting, ringConnectionModeSetting, saveTranscribeAudioSetting, glassesTypeSetting } from '../ui/dashboard-settings'
|
||||
whisperServerModelSetting, whisperServerUrlSetting, ringConnectionModeSetting, saveTranscribeAudioSetting, glassesTypeSetting, shouldPopUpNewNotification } from '../ui/dashboard-settings'
|
||||
import { transcriptionKey, type VoiceProviderSelection } from '../native/cloud-stt-provider'
|
||||
import type { PhoneGesture } from '../phone-ui/phone-gestures'
|
||||
import { claimGlassesOnboardingAutoLaunch, ONBOARDING_APP_ID } from '../apps/onboarding/onboarding-progress'
|
||||
@@ -216,7 +215,8 @@ export class IosPreviewController {
|
||||
requestShellRender: () => this.requestShellRender(),
|
||||
onWindowsChanged: () => { this.requestShellRender(); this.syncEvenHubPhoneUi(); this.wearRemote?.schedulePublish() },
|
||||
openNotificationsWindow: () =>
|
||||
this.openInProcessAppInBackground(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID, createNotificationsAppWindow),
|
||||
this.openInProcessAppInBackground(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID,
|
||||
options => createNotificationsAppWindow(options, section => { void this.launchApp('settings', { section }) })),
|
||||
onSwitcherBarHeightChanged: () => {
|
||||
this.relayout()
|
||||
shell.foregroundWindow()?.requestRender()
|
||||
@@ -248,7 +248,7 @@ export class IosPreviewController {
|
||||
shell.focusWindow(launcher.windowId)
|
||||
onIosNotificationPopup(key => {
|
||||
const notification = readActiveNotifications(128).find(n => n.key === key)
|
||||
if (this.glassesLocked || !notification || !shouldShowNotificationOnGlasses(notification.packageName)) return
|
||||
if (this.glassesLocked || !notification || !shouldPopUpNewNotification(notification.packageName)) return
|
||||
const woke = !shell.isScreenOn() && shell.wake('sidebar')
|
||||
shell.openNotificationModal(key, woke)
|
||||
this.requestShellRender()
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
type AssistantModel,
|
||||
} from "~/assistant/models";
|
||||
import { isLocalModelReady } from "../native/local-llm";
|
||||
import { shouldShowNotificationOnGlasses } from "../native/notification-sources";
|
||||
import { normalizeWhisperServerUrl } from "../native/whisper-server-stt";
|
||||
import { normalizeOpenAiCompatibleUrl } from "../native/openai-chat";
|
||||
import { isValidSpotifyClientId, SPOTIFY_CLIENT_ID_KEY } from "../native/spotify-auth";
|
||||
@@ -40,6 +41,8 @@ export type TimeFormat = "24h" | "12h";
|
||||
export type TemperatureUnit = "fahrenheit" | "celsius";
|
||||
export type DistanceUnit = "miles" | "kilometers";
|
||||
export type ScreenTimeoutSetting = "15s" | "30s" | "1m" | "3m" | "never";
|
||||
/** Whether new phone notifications pop up on the glasses, and for how long without interaction. */
|
||||
export type NewNotificationDisplay = "off" | "until-dismissed" | "5s" | "15s" | "1m";
|
||||
// Auto runs Faceclaw's light curve. Numeric values use the calibrated firmware
|
||||
// scale, clamped to 2–100; 2 is also the endpoint for screen fades.
|
||||
export const BRIGHTNESS_VALUES = ["auto", "2", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"] as const;
|
||||
@@ -663,6 +666,23 @@ export const screenTimeoutSetting = new ConfigSettingEnum<ScreenTimeoutSetting>(
|
||||
description: "How long the display stays on after the last input before turning itself off. \"Never\" keeps it on until turned off manually.",
|
||||
});
|
||||
|
||||
export const newNotificationDisplaySetting = new ConfigSettingEnum<NewNotificationDisplay>({
|
||||
id: "new-notification-display",
|
||||
label: "Display new notifications",
|
||||
storageKey: "notifications.newNotificationDisplay",
|
||||
defaultValue: "15s",
|
||||
values: ["off", "until-dismissed", "5s", "15s", "1m"],
|
||||
formatValue: newNotificationDisplayLabel,
|
||||
description:
|
||||
"Pop up new phone notifications on the glasses. A timed popup closes once left untouched that long; " +
|
||||
"the notification stays on the phone and in the status bar.",
|
||||
});
|
||||
|
||||
/** Whether a newly posted phone notification from this app pops up on the glasses (the global setting, then the app's filter toggle). */
|
||||
export function shouldPopUpNewNotification(packageName: string): boolean {
|
||||
return newNotificationDisplaySetting.get() !== "off" && shouldShowNotificationOnGlasses(packageName);
|
||||
}
|
||||
|
||||
export const lockScreenEnabledSetting = new ConfigSettingBoolean({
|
||||
id: "lock-screen-enabled",
|
||||
label: "Enable lock screen",
|
||||
@@ -1571,6 +1591,34 @@ export function screenTimeoutSettingToMs(value: ScreenTimeoutSetting): number |
|
||||
}
|
||||
}
|
||||
|
||||
/** How long an untouched new-notification popup stays up; null keeps it until dismissed (and for "off", which never opens one). */
|
||||
export function newNotificationDisplayTimeoutMs(value: NewNotificationDisplay): number | null {
|
||||
switch (value) {
|
||||
case "5s":
|
||||
return 5_000;
|
||||
case "15s":
|
||||
return 15_000;
|
||||
case "1m":
|
||||
return 60_000;
|
||||
case "off":
|
||||
case "until-dismissed":
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function newNotificationDisplayLabel(value: NewNotificationDisplay): string {
|
||||
switch (value) {
|
||||
case "off":
|
||||
return "Off";
|
||||
case "until-dismissed":
|
||||
return "Until dismissed";
|
||||
case "1m":
|
||||
return "1min";
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
export function brightnessLabel(value: BrightnessSetting): string {
|
||||
return value === "auto" ? "Auto" : value;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ import {
|
||||
firmwareDebugFlagsSetting,
|
||||
lockScreenEnabledSetting,
|
||||
menuAnimationSetting,
|
||||
newNotificationDisplaySetting,
|
||||
saveVoiceRecordingsSetting,
|
||||
showBleBandwidthSetting,
|
||||
suspendEvenHubWhenScreenOffSetting,
|
||||
@@ -100,9 +101,13 @@ import {
|
||||
import { wearBridge } from "../../native/wear-bridge";
|
||||
import { openSettingsSubMenu, SettingsPanelLayer, type SettingsSection } from "./settings-panel";
|
||||
import { uiFontPickerMenuItem } from "../font-picker";
|
||||
import { NotificationFilterLayer } from "../notification-filter";
|
||||
import { compatibleModelDiscoveryMenuItem } from "../openai-compatible-model-picker";
|
||||
import { isVeniceApiBaseUrl } from "../../native/openai-chat";
|
||||
|
||||
/** The Settings section the Notifications app's "Settings" menu item opens. */
|
||||
export const NOTIFICATIONS_SETTINGS_SECTION = "Notifications";
|
||||
|
||||
/** The Settings app's master-detail panel (sections on the left, contents on the right). */
|
||||
export function createSettingsPanelLayer(): SettingsPanelLayer {
|
||||
return new SettingsPanelLayer(settingsSections());
|
||||
@@ -138,6 +143,14 @@ function settingsSections(): SettingsSection[] {
|
||||
return customizationItems();
|
||||
},
|
||||
},
|
||||
{
|
||||
// Also opened from the Notifications app's menu (deep link by label).
|
||||
label: NOTIFICATIONS_SETTINGS_SECTION,
|
||||
items: [
|
||||
enumSettingMenuItem(newNotificationDisplaySetting),
|
||||
notificationFilterMenuItem(),
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Voice",
|
||||
items: [
|
||||
@@ -334,6 +347,17 @@ function customizationRows(): () => MenuItem[] {
|
||||
};
|
||||
}
|
||||
|
||||
/** Notifications > Notification filter: per-app toggles for which notifications pop up. */
|
||||
function notificationFilterMenuItem(): MenuItem {
|
||||
return submenuItem(
|
||||
"Notification filter",
|
||||
(ctx) => {
|
||||
ctx.stack.push(new NotificationFilterLayer());
|
||||
},
|
||||
{ description: "Choose which apps' new notifications pop up on the glasses. All of them still appear in the Notifications app." },
|
||||
);
|
||||
}
|
||||
|
||||
function autoBrightnessMenuItem(): MenuItem {
|
||||
return submenuItem(
|
||||
"Auto-brightness",
|
||||
|
||||
@@ -40,12 +40,21 @@ export function modalRect(): { x: number; y: number; width: number; height: numb
|
||||
export class ShellModalLayer implements Layer {
|
||||
private readonly stack: LayerStack;
|
||||
|
||||
constructor(baseLayer: Layer, actions: LayerActions, private readonly removed?: () => void) {
|
||||
constructor(
|
||||
baseLayer: Layer,
|
||||
actions: LayerActions,
|
||||
private readonly hooks: {
|
||||
/** The modal left the shell stack, however it went. */
|
||||
removed?: () => void;
|
||||
/** Input reached the modal (before its inner stack handles it). */
|
||||
input?: (event: InputEvent) => void;
|
||||
} = {},
|
||||
) {
|
||||
this.stack = new LayerStack(baseLayer, actions, modalInterior());
|
||||
}
|
||||
|
||||
onRemoved(): void {
|
||||
this.removed?.();
|
||||
this.hooks.removed?.();
|
||||
}
|
||||
|
||||
paint(_ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
|
||||
@@ -73,6 +82,7 @@ export class ShellModalLayer implements Layer {
|
||||
}
|
||||
|
||||
async handleInput(event: InputEvent, _ctx: LayerContext): Promise<void> {
|
||||
this.hooks.input?.(event);
|
||||
await this.stack.handleInput(event);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export function notificationPopupDelayMs(notification: { foregroundService?: boo
|
||||
/** Runs `run` after `delayMs`; returns a function that cancels it. */
|
||||
export type ScheduleFn = (run: () => void, delayMs: number) => () => void;
|
||||
|
||||
const scheduleTimeout: ScheduleFn = (run, delayMs) => {
|
||||
export const scheduleTimeout: ScheduleFn = (run, delayMs) => {
|
||||
const timer = setTimeout(run, delayMs);
|
||||
return () => clearTimeout(timer);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { scheduleTimeout, type ScheduleFn } from "./notification-popup-delay";
|
||||
|
||||
/**
|
||||
* Closes a new-notification popup that is left untouched for its timeout
|
||||
* ("Display new notifications"). The host restarts the countdown when the
|
||||
* popup opens and on each interaction with it (any input, including moving
|
||||
* its menu selection), and stops it when the popup goes away.
|
||||
*/
|
||||
export class NotificationPopupTimeout {
|
||||
private cancel: (() => void) | null = null;
|
||||
|
||||
/** `timeoutMs` null never expires (the popup stays until dismissed). */
|
||||
constructor(
|
||||
private readonly timeoutMs: number | null,
|
||||
private readonly expired: () => void,
|
||||
private readonly schedule: ScheduleFn = scheduleTimeout,
|
||||
) {}
|
||||
|
||||
/** Start the countdown over. */
|
||||
restart(): void {
|
||||
this.stop();
|
||||
if (this.timeoutMs === null) return;
|
||||
this.cancel = this.schedule(() => {
|
||||
this.cancel = null;
|
||||
this.expired();
|
||||
}, this.timeoutMs);
|
||||
}
|
||||
|
||||
stop(): void {
|
||||
this.cancel?.();
|
||||
this.cancel = null;
|
||||
}
|
||||
|
||||
/** Whether a countdown is running (for tests). */
|
||||
isRunning(): boolean {
|
||||
return this.cancel !== null;
|
||||
}
|
||||
}
|
||||
+26
-5
@@ -45,8 +45,11 @@ import {
|
||||
veniceWebSearchSetting,
|
||||
batteryIndicatorSettingsKey,
|
||||
brightnessSetting,
|
||||
newNotificationDisplaySetting,
|
||||
newNotificationDisplayTimeoutMs,
|
||||
onAnySettingChanged,
|
||||
openAiApiKeySetting,
|
||||
shouldPopUpNewNotification,
|
||||
statusBarPositionSetting,
|
||||
statusBarVisibilitySetting,
|
||||
timeFormatSetting,
|
||||
@@ -65,8 +68,8 @@ import {
|
||||
} from "./chrome-layer";
|
||||
import { ShellModalLayer } from "./modal-layer";
|
||||
import { NotificationModalQueue } from "./notification-modal-queue";
|
||||
import { NotificationPopupTimeout } from "./notification-popup-timeout";
|
||||
import { ALL_NOTIFICATIONS, readActiveNotifications } from "../../native/notification-icons";
|
||||
import { shouldShowNotificationOnGlasses } from "../../native/notification-sources";
|
||||
import { ToolDebugMenuLayer } from "./tool-debug-layer";
|
||||
import type { InProcessWindow } from "./in-process-window";
|
||||
import { BrightnessPickerLayer } from "./brightness-picker-layer";
|
||||
@@ -483,7 +486,7 @@ class Shell {
|
||||
isAvailable: (notificationKey) => {
|
||||
if (this.appNotifications.has(notificationKey)) return true;
|
||||
const notification = readActiveNotifications(ALL_NOTIFICATIONS).find((item) => item.key === notificationKey);
|
||||
return !!notification && shouldShowNotificationOnGlasses(notification.packageName);
|
||||
return !!notification && shouldPopUpNewNotification(notification.packageName);
|
||||
},
|
||||
sleep: () => this.sleep(),
|
||||
});
|
||||
@@ -929,18 +932,36 @@ class Shell {
|
||||
const content = appNotification
|
||||
? null
|
||||
: new SingleNotificationLayer(notificationKey, { origin: "new-notification-modal", onClose: close });
|
||||
// A phone notification's popup closes once left untouched for the
|
||||
// "Display new notifications" time, as if closed by hand: the notification
|
||||
// stays on the phone and in the status bar. An app's own notification
|
||||
// (e.g. a Nightscout alert) is nowhere else to be found, so it stays up.
|
||||
const timeout = new NotificationPopupTimeout(
|
||||
appNotification ? null : newNotificationDisplayTimeoutMs(newNotificationDisplaySetting.get()),
|
||||
() => {
|
||||
// Something over the popup (a voice dialog, the system menu) is in
|
||||
// use; count that as interaction rather than closing underneath it.
|
||||
if (this.stack.topMatches((layer) => layer === popup.modal)) close();
|
||||
else timeout.restart();
|
||||
},
|
||||
);
|
||||
const popup: NotificationPopup = {
|
||||
content,
|
||||
modal: new ShellModalLayer(
|
||||
appNotification ? appNotification.createLayer(close) : content!,
|
||||
this.config.actions,
|
||||
() => {
|
||||
this.appNotifications.delete(notificationKey);
|
||||
this.notificationModals.removed(popup, this.screenOn);
|
||||
{
|
||||
removed: () => {
|
||||
timeout.stop();
|
||||
this.appNotifications.delete(notificationKey);
|
||||
this.notificationModals.removed(popup, this.screenOn);
|
||||
},
|
||||
input: () => timeout.restart(),
|
||||
},
|
||||
),
|
||||
};
|
||||
this.stack.push(popup.modal);
|
||||
timeout.restart();
|
||||
return popup;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user