diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFirmwareFlasher.java b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFirmwareFlasher.java index ee58dbab..84d66a4f 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFirmwareFlasher.java +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFirmwareFlasher.java @@ -188,11 +188,21 @@ public class FaceclawFirmwareFlasher implements FaceclawBleListener { if (!isEndOk(beginStatus)) { emitLog("warning: unexpected begin status " + beginStatus + "; continuing"); } + // Progress is reported in bytes across the whole image: the segments + // are one large firmware blob plus several small ones, so a bar + // stepped per segment would sit still through the big one and then + // sprint through the rest. + long totalBytes = 0; + for (Segment seg : segs) { + totalBytes += seg.ps; + } + long bytesBefore = 0; for (int i = 0; i < segs.size(); i++) { if (cancelled) { throw new IllegalStateException("Cancelled."); } - flashComponentWithRetry(lens, address, i, segs.size(), segs.get(i), img); + flashComponentWithRetry(lens, address, i, segs.size(), segs.get(i), img, bytesBefore, totalBytes); + bytesBefore += segs.get(i).ps; } emitLog(lens + " lens: all components verified"); try { @@ -201,14 +211,15 @@ public class FaceclawFirmwareFlasher implements FaceclawBleListener { } } - private void flashComponentWithRetry(String lens, String address, int index, int count, Segment seg, byte[] img) { + private void flashComponentWithRetry(String lens, String address, int index, int count, Segment seg, byte[] img, + long bytesBefore, long totalBytes) { for (int attempt = 0; attempt < COMPONENT_RETRIES; attempt++) { if (attempt > 0) { emitLog(seg.name + ": re-flash attempt " + (attempt + 1) + "/" + COMPONENT_RETRIES); } int endStatus; try { - endStatus = flashComponent(lens, address, index, count, seg, img); + endStatus = flashComponent(lens, address, index, count, seg, img, bytesBefore, totalBytes); } catch (TimeoutException | RuntimeException e) { emitLog(seg.name + ": block phase failed: " + e.getMessage()); endStatus = -1; @@ -226,8 +237,8 @@ public class FaceclawFirmwareFlasher implements FaceclawBleListener { throw new IllegalStateException("component " + seg.name + " failed after " + COMPONENT_RETRIES + " attempts"); } - private int flashComponent(String lens, String address, int index, int count, Segment seg, byte[] img) - throws TimeoutException { + private int flashComponent(String lens, String address, int index, int count, Segment seg, byte[] img, + long bytesBefore, long totalBytes) throws TimeoutException { byte[] sub = Arrays.copyOfRange(img, seg.off, seg.off + 128); int ps = seg.ps; int payloadStart = seg.off + 128; @@ -260,7 +271,8 @@ public class FaceclawFirmwareFlasher implements FaceclawBleListener { throw new IllegalStateException("block " + b + " NAK'd " + BLOCK_NAK_RETRIES + " times"); } if (b % 20 == 0 || b == blockCount - 1) { - emitProgress(lens, index + 1, count, b + 1, blockCount); + long bytesSent = bytesBefore + Math.min((long) (b + 1) * BLOCK_SIZE, (long) ps); + emitProgress(lens, index + 1, count, b + 1, blockCount, bytesSent, totalBytes); } } emitLog(seg.name + ": data phase done; sending END"); @@ -651,11 +663,12 @@ public class FaceclawFirmwareFlasher implements FaceclawBleListener { }); } - private void emitProgress(String lens, int componentIndex, int componentCount, int blockIndex, int blockCount) { + private void emitProgress(String lens, int componentIndex, int componentCount, int blockIndex, int blockCount, + long bytesSent, long bytesTotal) { mainHandler.post(() -> { FaceclawFirmwareFlasherListener current = listener; if (current != null) { - current.onProgress(lens, componentIndex, componentCount, blockIndex, blockCount); + current.onProgress(lens, componentIndex, componentCount, blockIndex, blockCount, bytesSent, bytesTotal); } }); } diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFirmwareFlasherListener.java b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFirmwareFlasherListener.java index a111c174..2cd24e20 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFirmwareFlasherListener.java +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawFirmwareFlasherListener.java @@ -6,9 +6,12 @@ public interface FaceclawFirmwareFlasherListener { /** * Fine-grained progress for the UI bar. `lens` is "left"/"right"; - * component/block indices are 1-based against their counts. + * component/block indices are 1-based against their counts. `bytesSent` / + * `bytesTotal` cover the whole lens image, so a bar driven by them moves + * evenly even though the components differ wildly in size. */ - void onProgress(String lens, int componentIndex, int componentCount, int blockIndex, int blockCount); + void onProgress(String lens, int componentIndex, int componentCount, int blockIndex, int blockCount, + long bytesSent, long bytesTotal); /** * Coarse lifecycle. `state` is one of: validating, connecting, flashing, diff --git a/app/app.css b/app/app.css index 365b6da7..673fc5bb 100644 --- a/app/app.css +++ b/app/app.css @@ -20,6 +20,15 @@ TextField { color: #222222; } +/* Without this, the theme's .ns-dark rules recolour the text white while the + * white background above sticks, rendering white-on-white fields. + * Order matters: .system-name-modal TextField must stay after this rule so the + * deliberately light modal wins the equal-specificity tie in dark mode. */ +.ns-dark TextField { + background-color: #2e2e2e; + color: #f0f0f0; +} + .system-name-modal TextField { background-color: #ffffff; color: #222222; @@ -35,6 +44,12 @@ Button.-primary { font-size: 18; } +/* The logo art is black-on-transparent; tint it light in dark mode so it + * doesn't vanish into the dark page background. */ +.ns-dark .onboarding-logo { + tint-color: #e6e6e6; +} + /* * Stands in for the lens preview when showing it would be misleading (silent * mode, or a disconnect explained by a flat battery). Sized by the view model @@ -177,12 +192,6 @@ Button.-primary { padding: 10; } -.pairing-diagnostics { - font-size: 11; - color: #888888; - font-family: monospace; -} - Button.pairing-link { background-color: transparent; color: #2a5bc4; diff --git a/app/g2/ble-proximity.ts b/app/g2/ble-proximity.ts index 9bb24686..4ca475a6 100644 --- a/app/g2/ble-proximity.ts +++ b/app/g2/ble-proximity.ts @@ -28,10 +28,9 @@ * absolute numbers metres out. * * It is **not** a measurement. A hand over the temple, a pocket, or a body - * between phone and glasses moves the estimate by metres. Every user-facing - * number is therefore rounded hard, prefixed with "~" when confidence is low, - * and paired with a coarse zone rather than being presented as a distance the - * wearer could act on precisely. + * between phone and glasses moves the estimate by metres. The wearer therefore + * only ever sees a coarse zone (glyph + label), never a number in metres they + * might over-trust; the metres value exists purely to rank and bucket. * * This module is pure (no NativeScript imports) so it can run under node tests. */ @@ -113,27 +112,6 @@ export type ProximityEstimate = { readonly zone: ProximityZone; }; -/** "0.4 m", "~3 m". The tilde marks an estimate the reader should not lean on. */ -export function formatDistance(estimate: ProximityEstimate): string { - const prefix = estimate.confidence < 0.6 ? "~" : ""; - const meters = estimate.meters; - if (meters < 1) { - return `${prefix}${Math.round(meters * 100)} cm`; - } - if (meters < 10) { - return `${prefix}${meters.toFixed(1)} m`; - } - if (meters < MAXIMUM_METERS) { - return `${prefix}${Math.round(meters)} m`; - } - return `${prefix}>${MAXIMUM_METERS} m`; -} - -/** "In your hand · 0.3 m" — zone first, because the zone is the trustworthy half. */ -export function proximitySummary(estimate: ProximityEstimate): string { - return `${zoneLabel(estimate.zone)} · ${formatDistance(estimate)}`; -} - /** * Estimate distance from a signal sample. Null when there is no RSSI to work * from, so callers can say "signal unknown" rather than render a fabricated diff --git a/app/g2/pairing-candidates.ts b/app/g2/pairing-candidates.ts index 8ddd367d..ce1f4d7e 100644 --- a/app/g2/pairing-candidates.ts +++ b/app/g2/pairing-candidates.ts @@ -14,10 +14,10 @@ import { estimateProximity, GLASSES_CALIBRATION, - proximitySummary, RING_CALIBRATION, sortedByProximity, zoneGlyph, + zoneLabel, type ProximityEstimate, type ProximityZone, } from "./ble-proximity"; @@ -251,9 +251,11 @@ function stripSmoothing(record: EvenAdvertisement & { smoothedRssi: number | nul /** * The candidate whose signal is strong enough to call "the one you are * holding". `null` when nothing leads clearly, which is the honest answer for - * two pairs sitting on the same table. + * two pairs sitting on the same table — and when the list has a single entry, + * where "closest" has nothing to be closer than. */ export function nearestCandidateId(candidates: ReadonlyArray<{ id: string; rssi: number | null }>): string | null { + if (candidates.length < 2) return null; const ranked = candidates .filter((candidate): candidate is { id: string; rssi: number } => candidate.rssi != null) .slice() @@ -301,7 +303,7 @@ export type PairingRowPresentation = { proximitySummary: string; proximityGlyph: string; zone: ProximityZone | null; - /** "Left + right arms found", "Only the left arm has been seen", … */ + /** "Left + right arms found", "Only the left arm has been seen", …; "" when there is nothing worth a line (an unbonded ring). */ armsSummary: string; /** A problem the wearer should read before tapping, or "" when none. */ warning: string; @@ -329,7 +331,7 @@ function presentationBase( isNearest, isPreviouslyPaired: isPaired, badge: isPaired ? "Yours" : isNearest ? "Closest" : "", - proximitySummary: proximity ? proximitySummary(proximity) : "Signal unknown", + proximitySummary: proximity ? zoneLabel(proximity.zone) : "Signal unknown", proximityGlyph: proximity ? zoneGlyph(proximity.zone) : "○○○○", zone: proximity?.zone ?? null, warning: warnings.join(" "), @@ -408,7 +410,9 @@ export function ringRow(ring: RingCandidate, context: RowContext = {}): PairingR imagePath: R1_IMAGE_PATH, hasVariantImage: true, ...presentationBase(ring.proximity, isNearest, isPaired, warnings), - armsSummary: ad.bonded ? "Paired with this phone" : "Advertising", + // "Advertising" told the wearer nothing (a listed ring is advertising by + // definition); only the bonded state is worth a line. + armsSummary: ad.bonded ? "Paired with this phone" : "", canSelect: true, }; } diff --git a/app/native/firmware-flasher.ts b/app/native/firmware-flasher.ts index b2cfba7e..cd75d0b7 100644 --- a/app/native/firmware-flasher.ts +++ b/app/native/firmware-flasher.ts @@ -10,6 +10,9 @@ export type FlashProgress = { componentCount: number; blockIndex: number; blockCount: number; + /** Bytes flashed so far across the whole lens image — the size-weighted progress signal. */ + bytesSent: number; + bytesTotal: number; }; /** @@ -42,6 +45,8 @@ export class FirmwareFlasher { componentCount: number, blockIndex: number, blockCount: number, + bytesSent: number, + bytesTotal: number, ) => this.emit(this.progressListeners, { lens: String(lens), @@ -49,6 +54,8 @@ export class FirmwareFlasher { componentCount: Number(componentCount), blockIndex: Number(blockIndex), blockCount: Number(blockCount), + bytesSent: Number(bytesSent), + bytesTotal: Number(bytesTotal), }), onState: (state: string, detail: string) => this.emit(this.stateListeners, String(state) as FlashState, String(detail ?? "")), diff --git a/app/phone-ui/config-page.xml b/app/phone-ui/config-page.xml index 366c17b6..cffe6f9e 100644 --- a/app/phone-ui/config-page.xml +++ b/app/phone-ui/config-page.xml @@ -37,8 +37,8 @@