diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleCommunicator.java b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleCommunicator.java index 98074d90..e2f26a64 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleCommunicator.java +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleCommunicator.java @@ -569,12 +569,17 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable { * foreground), including worker-app frames the TS side never sees. */ public android.graphics.Bitmap getCompositePreviewBitmap(double brightenGamma) { + return getCompositePreviewBitmap(brightenGamma, false); + } + + /** As above; `green` renders the preview green-on-black (Settings > Phone display > Preview color). */ + public android.graphics.Bitmap getCompositePreviewBitmap(double brightenGamma, boolean green) { SurfaceCompositor.Composite composite = compositor.previewComposite(); if (composite == null) { return null; } return PreviewBitmapUtil.fromGray( - java.nio.ByteBuffer.wrap(composite.gray), composite.width, composite.height, brightenGamma); + java.nio.ByteBuffer.wrap(composite.gray), composite.width, composite.height, brightenGamma, green); } /** Save the current composite as a 4-bit grayscale PNG; returns the path or "". */ diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/PreviewBitmapUtil.java b/App_Resources/Android/src/main/java/com/faceclaw/app/PreviewBitmapUtil.java index fd1de064..4b599d67 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/PreviewBitmapUtil.java +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/PreviewBitmapUtil.java @@ -15,13 +15,18 @@ public final class PreviewBitmapUtil { private PreviewBitmapUtil() {} public static Bitmap fromGray(ByteBuffer gray, int width, int height, double brightenGamma) { + return fromGray(gray, width, height, brightenGamma, false); + } + + /** As above; `green` renders green-on-black (matching the physical glasses) instead of grayscale. */ + public static Bitmap fromGray(ByteBuffer gray, int width, int height, double brightenGamma, boolean green) { if (gray == null || width <= 0 || height <= 0 || gray.remaining() < width * height) { throw new IllegalArgumentException("invalid gray preview buffer"); } int[] lut = new int[256]; for (int g = 0; g < 256; g++) { int v = (int) Math.max(0, Math.min(255, Math.round(255 * Math.pow(g / 255.0, brightenGamma)))); - lut[g] = 0xff000000 | (v << 16) | (v << 8) | v; + lut[g] = green ? (0xff000000 | (v << 8)) : (0xff000000 | (v << 16) | (v << 8) | v); } byte[] bytes = new byte[width * height]; gray.get(bytes); diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index 0a9b8a9b..705dda29 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -58,7 +58,7 @@ import { type InProcessAppOptions, type InProcessWindow } from "../ui/shell/in-p import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-apps-persistence"; import { appViewportRect, SIDEBAR_WIDTH, sidebarStripVisible, type WindowHeightMode } from "../ui/shell/geometry"; import { type LayerActions } from "../ui/layers"; -import { assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, brightnessSetting, brightnessSettingToLevel, displayModeSetting, watchWakesDisplaySetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, verticalPositionSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings"; +import { assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, brightnessSetting, brightnessSettingToLevel, displayModeSetting, watchWakesDisplaySetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, verticalPositionSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings"; import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization"; import { getInstalledEvenHubAppById, @@ -330,6 +330,9 @@ class DashboardController { this.applyDisplayModeIfChanged(); this.syncAssistantBridgeIfChanged(); this.syncLockScreenSettingIfChanged(); + // A Preview color change should show on the mirror at once, not at the + // next composited frame (cheap: floor-limited, dedup'd on the Java side). + this.schedulePreviewUpdate(); }); // Connect to the external agent bridge at boot if configured; the // connection stays up (with re-dial) so proactive tool calls work @@ -2195,7 +2198,7 @@ class DashboardController { this.lastRecordCaptureAtMs = now; this.communicator.recordScreenFrame(); } - const preview = this.communicator.getCompositePreview(); + const preview = this.communicator.getCompositePreview(previewColorSetting.get() === "green"); if (preview) { this.setDisplayPreview(preview); } diff --git a/app/native/faceclaw-communicator.ts b/app/native/faceclaw-communicator.ts index 1f604a39..acca49ac 100644 --- a/app/native/faceclaw-communicator.ts +++ b/app/native/faceclaw-communicator.ts @@ -456,10 +456,14 @@ export class FaceclawCommunicatorBridge { }); } - /** Phone-UI preview of the current composited screen, or null if none yet. */ - getCompositePreview(): ImageSource | null { + /** + * Phone-UI preview of the current composited screen, or null if none yet. + * `green` tints it green-on-black (the Preview color setting) instead of + * grayscale. + */ + getCompositePreview(green = false): ImageSource | null { if (!global.isAndroid) return null; - const bitmap = this.communicator.getCompositePreviewBitmap(PREVIEW_BRIGHTEN_GAMMA); + const bitmap = this.communicator.getCompositePreviewBitmap(PREVIEW_BRIGHTEN_GAMMA, green); return bitmap ? new ImageSource(bitmap) : null; } diff --git a/app/phone-ui/main-view-model.ts b/app/phone-ui/main-view-model.ts index b4fa43e4..039e57cd 100644 --- a/app/phone-ui/main-view-model.ts +++ b/app/phone-ui/main-view-model.ts @@ -18,11 +18,13 @@ import { DISPLAY_MODE_VALUES, displayModeLabel, displayModeSetting, + mirrorTouchSetting, onAnySettingChanged, + showBrightnessControlSetting, + showScreenSizeSetting, type BrightnessSetting, type DisplayModeSetting, } from "../ui/dashboard-settings"; -import { getBooleanSetting, setBooleanSetting } from "../native/settings-store"; import { isValidMacAddress, loadDeviceAddresses } from "../g2/device-addresses"; import { isAutoReconnectSuppressed, resumeAutoReconnect } from "../g2/reconnect-policy"; import { formatErrorMessage } from "../util/format-error"; @@ -742,14 +744,10 @@ export class MainViewModel extends Observable { // ---- touching the mirror itself ---- + // Toggled from Settings > Phone display > Touch mirror; read per gesture, + // so no change notification is needed. get mirrorTouchEnabled(): boolean { - return getBooleanSetting(MIRROR_TOUCH_KEY, true); - } - - onMirrorTouchChange(args: { value?: boolean; object?: { checked?: boolean } }): void { - const on = typeof args.value === "boolean" ? args.value : Boolean(args.object?.checked); - setBooleanSetting(MIRROR_TOUCH_KEY, on); - this.notifyPropertyChange("mirrorTouchEnabled", on); + return mirrorTouchSetting.get(); } private mirrorFraction(args: GestureEventData & { getX?: () => number; getY?: () => number }): { nx: number; ny: number } | null { @@ -785,6 +783,21 @@ export class MainViewModel extends Observable { } // ---- display mode and brightness, beside the mirror ---- + // + // Both controls are hidden unless enabled in Settings > Phone display + // (the settings themselves stay reachable through the Settings app). + + get screenSizeControlVisibility(): "visible" | "collapse" { + return showScreenSizeSetting.get() ? "visible" : "collapse"; + } + + get brightnessControlVisibility(): "visible" | "collapse" { + return showBrightnessControlSetting.get() ? "visible" : "collapse"; + } + + get displayControlsVisibility(): "visible" | "collapse" { + return showScreenSizeSetting.get() || showBrightnessControlSetting.get() ? "visible" : "collapse"; + } get displayModeLabel(): string { return displayModeLabel(displayModeSetting.get()) + " ▾"; @@ -848,6 +861,9 @@ export class MainViewModel extends Observable { this.notifyPropertyChange("brightnessSliderEnabled", this.brightnessSliderEnabled); this.notifyPropertyChange("brightnessPercent", this.brightnessPercent); this.notifyPropertyChange("displayModeLabel", this.displayModeLabel); + this.notifyPropertyChange("screenSizeControlVisibility", this.screenSizeControlVisibility); + this.notifyPropertyChange("brightnessControlVisibility", this.brightnessControlVisibility); + this.notifyPropertyChange("displayControlsVisibility", this.displayControlsVisibility); } private readLayoutOrientation(): LayoutOrientation { @@ -863,8 +879,6 @@ export class MainViewModel extends Observable { } } -const MIRROR_TOUCH_KEY = "phone.mirrorTouch"; - /** NativeScript swipe direction -> the watch-scheme directional gesture. */ function swipeKind(direction: SwipeDirection): "swipe-up" | "swipe-down" | "swipe-left" | "swipe-right" { switch (direction) { diff --git a/app/phone-ui/remote-controls.xml b/app/phone-ui/remote-controls.xml index aadfe111..b769e29e 100644 --- a/app/phone-ui/remote-controls.xml +++ b/app/phone-ui/remote-controls.xml @@ -7,13 +7,14 @@ MainViewModel. --> - -