From 5e8ac1e2f5a660e55ea132996e1d5730cfa4fa64 Mon Sep 17 00:00:00 2001 From: cirakg Date: Wed, 21 Oct 2026 03:55:10 +0200 Subject: feat(glance): show the favourite code in the glance (opt-in) With "Show the favourite code in the glance" on, the glance shows the code of the first favourite TOTP or Steam entry without the PIN, with a countdown bar. The glance can't open the vault, so the About scan seals that entry under "g" (device key, aad OTPW-GL-1) after every change, and removes it when the option is off or no entry qualifies; the glance also reads the option itself. HKDF moves to its own module so the glance loads only the crypto it needs (37 % of its 64 KB). Manage entry gains "Mark as favourite (glance)" and "Remove favourite", queued for locked entries like the other changes. Lines are inset on round screens so the Instinct 3's curved glance corner doesn't cut them. Co-Authored-By: Claude Opus 5.5 --- source/settings/AboutScan.mc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/settings/AboutScan.mc') diff --git a/source/settings/AboutScan.mc b/source/settings/AboutScan.mc index 8fc898a..559cce9 100644 --- a/source/settings/AboutScan.mc +++ b/source/settings/AboutScan.mc @@ -1,5 +1,5 @@ // Author: cirakg & claude ai -// Summary: Writes the read-only About fields (catalog, version, storage use) and applies "Encrypt names" to existing entries. +// Summary: Writes the read-only About fields (catalog, version, storage use), applies "Encrypt names" to existing entries and updates the glance code. // // One pass over every entry header, a few per step: // * catalog: "K7F2 GitHub (alice) · 9QXR Gym card · ...", so the Manage @@ -11,8 +11,11 @@ // "Encrypt names" option are re-sealed, one per step. Locked ones need // the session; if one can't be done now, the next scan retries (after // the next PIN entry, which runs the processor again). +// * The glance code (GlanceCode.mc): the first favourite TOTP or Steam +// entry without the PIN is sealed for the glance, or the glance item +// removed when there is none or the option is off. // The scan only runs when something it reports changed: a form was -// applied, or the signature of the entry list (IDs, pending, option, +// applied, or the signature of the entry list (IDs, pending, options, // version) differs from the last complete scan. import Toybox.Lang; @@ -35,6 +38,7 @@ class AboutScan extends Jobs.Job { private var _left as Number = 0; private var _bytes as Number = 0; private var _incomplete as Boolean = false; + private var _glanceId as String? = null; function initialize(vault as Vault, store as Forms.Store) { Job.initialize(); @@ -55,6 +59,7 @@ class AboutScan extends Jobs.Job { content.add(vault.ids().toString()); content.add(vault.pendingIds().toString()); content.add(vault.encryptNames); + content.add(vault.glanceCode); content.add(ChangeQueue.count(vault)); content.add(AppInfo.VERSION); return Forms.hash(vault, content); @@ -102,6 +107,9 @@ class AboutScan extends Jobs.Job { } } addItem(id + " " + describe(header) + (header.locked ? " (PIN)" : "")); + if (_glanceId == null && GlanceStore.qualifies(header)) { + _glanceId = id; + } return converted; } @@ -156,6 +164,14 @@ class AboutScan extends Jobs.Job { setIfChanged("catalog", catalog); setIfChanged("storageUse", use); setIfChanged("version", AppInfo.VERSION); + try { + GlanceStore.update(_vault, _glanceId); + } catch (e instanceof Lang.Exception) { + // Damaged entry or a full store: no glance code, and the scan + // runs again next time. + _vault.storage().deleteValue(GlanceCode.KEY); + _incomplete = true; + } if (!_incomplete) { try { _vault.storage().setValue(SIGNATURE_KEY, signature(_vault)); -- cgit v1.2.3