forked from Blendman974/faceclaw
Glanceboard tap setting includes a Disable option
This commit is contained in:
1 parent
937c73d81b
commit
2971999467
5 files changed
+31
-10
No files matched your search
@@ -3,6 +3,7 @@
|
||||
## 0.7.1 - Unreleased
|
||||
|
||||
* Add Wear OS watch battery indicator to the top bar and Glanceboard
|
||||
* Glanceboard tap setting includes a Disable option
|
||||
|
||||
## 0.7.0 - 2026-09-12
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ export type GlanceboardProvider = {
|
||||
size: { width: number; height: number };
|
||||
/** Whether sleep-time gestures should show the board at all (user setting). */
|
||||
isEnabled: () => boolean;
|
||||
/** Whether a single tap shows the board (for tapTimeoutMs). */
|
||||
showOnTap: () => boolean;
|
||||
/** How long a tap or head-tilt keeps the board up. */
|
||||
tapTimeoutMs: () => number;
|
||||
/** Whether a long-press holds the board up until released. */
|
||||
|
||||
@@ -41,21 +41,35 @@ 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 = "3s" | "5s" | "7s" | "10s";
|
||||
export type GlanceTapDuration = "off" | "3s" | "5s" | "7s" | "10s";
|
||||
|
||||
/** How long a tap (or head-tilt) keeps the board up; each further tap restarts it. */
|
||||
const DEFAULT_TAP_DURATION: GlanceTapDuration = "5s";
|
||||
|
||||
/**
|
||||
* How long a tap (or head-tilt) keeps the board up; each further tap restarts
|
||||
* it. "off" means a single tap does not show the board at all; a head-tilt
|
||||
* then uses the default duration.
|
||||
*/
|
||||
export const glanceTapDurationSetting = new ConfigSettingEnum<GlanceTapDuration>({
|
||||
id: "glanceboard-tap-duration",
|
||||
label: "Show on tap",
|
||||
storageKey: "glanceboard.tapDuration",
|
||||
defaultValue: "5s",
|
||||
values: ["3s", "5s", "7s", "10s"],
|
||||
formatValue: (value) => value.replace("s", " s"),
|
||||
description: "How long a single tap (or a head-tilt) keeps the Glanceboard on screen.",
|
||||
defaultValue: DEFAULT_TAP_DURATION,
|
||||
values: ["off", "3s", "5s", "7s", "10s"],
|
||||
formatValue: (value) => (value === "off" ? "Disabled" : value.replace("s", " s")),
|
||||
description:
|
||||
"How long a single tap (or a head-tilt) keeps the Glanceboard on screen. Disabled: a single tap does not show the Glanceboard.",
|
||||
});
|
||||
|
||||
/** Whether a single tap while asleep shows the board. */
|
||||
export function glanceShowOnTap(): boolean {
|
||||
return glanceTapDurationSetting.get() !== "off";
|
||||
}
|
||||
|
||||
export function glanceTapTimeoutMs(): number {
|
||||
return Number.parseInt(glanceTapDurationSetting.get(), 10) * 1000;
|
||||
const duration = glanceTapDurationSetting.get();
|
||||
const seconds = duration === "off" ? DEFAULT_TAP_DURATION : duration;
|
||||
return Number.parseInt(seconds, 10) * 1000;
|
||||
}
|
||||
|
||||
/** A long-press holds the board up until the press is released. */
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
glanceboardEnabledSetting,
|
||||
glanceShowOnHeadTiltSetting,
|
||||
glanceShowOnLongPressSetting,
|
||||
glanceShowOnTap,
|
||||
glanceTapTimeoutMs,
|
||||
} from "./glanceboard-settings";
|
||||
import { QUADRANT_LAYOUT } from "./layout";
|
||||
@@ -17,6 +18,7 @@ const glanceboardApp: AppDefinition = {
|
||||
glanceboard: {
|
||||
size: { width: QUADRANT_LAYOUT.width, height: QUADRANT_LAYOUT.height },
|
||||
isEnabled: () => glanceboardEnabledSetting.get(),
|
||||
showOnTap: glanceShowOnTap,
|
||||
tapTimeoutMs: glanceTapTimeoutMs,
|
||||
showOnLongPress: () => glanceShowOnLongPressSetting.get(),
|
||||
showOnHeadTilt: () => glanceShowOnHeadTiltSetting.get(),
|
||||
|
||||
@@ -68,13 +68,15 @@ export class GlanceHost {
|
||||
/**
|
||||
* The glance event a sleep-time gesture means under the board's settings,
|
||||
* or null when the shell should see the input as usual: nothing while the
|
||||
* board is disabled, no hold when "Show on long press" is off, no press
|
||||
* from a head-tilt when "Show on head tilt" is off (it then wakes the
|
||||
* regular UI). A release always passes so a hold in progress can end.
|
||||
* board is disabled, no press from a tap when "Show on tap" is disabled,
|
||||
* no hold when "Show on long press" is off, no press from a head-tilt when
|
||||
* "Show on head tilt" is off (it then wakes the regular UI). A release
|
||||
* always passes so a hold in progress can end.
|
||||
*/
|
||||
eventForGesture(gesture: "head-tilt" | string): GlanceEvent | null {
|
||||
const provider = this.options.getProvider();
|
||||
if (!provider?.isEnabled()) return null;
|
||||
if (gesture === "click" && !provider.showOnTap()) return null;
|
||||
if (gesture === "long-press" && !provider.showOnLongPress()) return null;
|
||||
if (gesture === "head-tilt" && !provider.showOnHeadTilt()) return null;
|
||||
return glanceEventForGesture(gesture, this.isVisible());
|
||||
|
||||
Reference in new issue
Block a user