diff --git a/lib/ble/slot_comparison.dart b/lib/ble/slot_comparison.dart new file mode 100644 index 000000000..921f20176 --- /dev/null +++ b/lib/ble/slot_comparison.dart @@ -0,0 +1,345 @@ +// What a device gives in each of the two columns the pairing screens draw: +// "Every day" (the main band, or the active wearable that fills the days the +// band left empty) and "Workouts only" (a workout-armed sensor). Capabilities +// come from the compute layer's eligibility rules, never from raw-signal +// membership. +import '../compute/inputs/canonical.dart' + show Cell, MetricClass, capabilities, columnFor, kWorkoutArmedSensors; +import 'adapters/_registry.dart'; + +/// The two columns. A WHOOP fills [everyDay] as the main band; a ring or a +/// watch fills it as the active wearable (canonical.dart `activeWearable`, +/// `wearableSubstrate`); a workout-armed sensor fills [workoutsOnly]. +enum DeviceSlot { everyDay, workoutsOnly } + +enum DeviceCapability { + sleep, + recovery, + strain, + + /// Heart rate and resting heart rate (the column's `resting_hr` row). + heartRate, + hrv, + respiration, + skinTemperature, + steps, + bloodOxygen, + workoutHeartRate, + workoutBeatToBeat, +} + +/// How a capability is delivered. +/// native: this app computes it. conditional: only when [CapabilityStatus.reasonKey] +/// holds (an l10n-able key). vendorReported: the device's own number, shown as +/// the device's (never passed off as native). +enum CapabilityKind { native, conditional, vendorReported } + +class CapabilityStatus { + final CapabilityKind kind; + + /// Required (nonblank) when [kind] is conditional, else null. + final String? reasonKey; + const CapabilityStatus(this.kind, {this.reasonKey}); +} + +class SlotSide { + final Map sends; + + /// The table's rows ([kTableRows]) this side does not send. + final Set doesNotSend; + const SlotSide({required this.sends, required this.doesNotSend}); +} + +class SlotComparison { + /// What the entry gives every day: as the main band (a WHOOP) or as the + /// active wearable (a columned ring or watch). Empty for a chest strap. + final SlotSide everyDay; + + /// What the entry gives during workouts as a workout-armed sensor (a WHOOP + /// kept for workouts is read as one). Empty for a ring. + final SlotSide workoutsOnly; + + /// The column the device goes into, or null when it fits neither (a Coros + /// watch, a scale). + final DeviceSlot? slot; + const SlotComparison( + {required this.everyDay, required this.workoutsOnly, this.slot}); + + SlotSide side(DeviceSlot s) => switch (s) { + DeviceSlot.everyDay => everyDay, + DeviceSlot.workoutsOnly => workoutsOnly, + }; +} + +/// The whole-day rows of the table, in the order they are drawn. +const List kDayCapabilities = [ + DeviceCapability.sleep, + DeviceCapability.recovery, + DeviceCapability.strain, + DeviceCapability.heartRate, + DeviceCapability.hrv, + DeviceCapability.respiration, + DeviceCapability.skinTemperature, + DeviceCapability.steps, +]; + +/// Capabilities decided per workout session, not per day: the band records a +/// workout itself; a sensor only through the sensor path +/// (`kWorkoutArmedSensors`, canonical.dart; `HrsLink.deriveTier`). +const Set kSessionCapabilities = { + DeviceCapability.workoutHeartRate, + DeviceCapability.workoutBeatToBeat, +}; + +/// Every row the table draws: the whole-day rows, then the workout rows. +/// Blood oxygen is never one of them. +const List kTableRows = [ + ...kDayCapabilities, + DeviceCapability.workoutHeartRate, + DeviceCapability.workoutBeatToBeat, +]; + +/// THE mapping from a whole-day capability to its row in the compute layer's +/// metric x device columns (`columnFor`, compute/inputs/canonical.dart). A +/// capability's status for a wearable is read off `capabilities(column)[row]`. +const Map kCapabilityRow = { + DeviceCapability.sleep: 'sleep_window', + DeviceCapability.recovery: 'readiness', + DeviceCapability.strain: 'strain', + DeviceCapability.heartRate: 'resting_hr', + DeviceCapability.hrv: 'hrv', + DeviceCapability.respiration: 'respiratory_rate', + DeviceCapability.skinTemperature: 'skin_temp', + DeviceCapability.steps: 'steps', +}; + +// Blood oxygen is never claimed by a pairing comparison, for any device: the +// app refuses its own SpO2 (onehz_pipeline.dart kSpo2Refusal), and a vendor's +// reading is not a promise made at pairing. It is not in [kCapabilityRow]. +// (The enum value and its label stay so the absence can be asserted.) + +/// Where a claimed capability comes from: [rule] names the eligibility rule, +/// [source] is the repo file that holds it. +typedef CapabilityTrace = ({String rule, String source}); + +/// l10n keys (lib/l10n/app_*.arb) of the one-line captions a conditional +/// capability carries. +const String kReasonSkinTempNights = 'capReasonSkinTempNights'; + +// Ring settle bands use synthetic nights (oura_inputs.dart), so waiting +// for the minimum nights does not remove their provisional status. +const String kReasonSkinTempProvisional = 'capReasonSkinTempProvisional'; +const String kReasonEstimated = 'capReasonEstimated'; +const String kReasonEarly = 'capReasonEarly'; + +/// A wearable's readiness is provisional until its inputs have 14 nights of +/// baseline (oura_inputs.dart `readiness`, onehz_pipeline.dart +/// kSkinTempDevMinNights). +const String kReasonFirstNights = 'capReasonFirstNights'; + +/// A wearable's sleep window is ours, its stages the device's own +/// (`sleep_stages` is a device-only row). +const String kReasonOwnStagesRing = 'capReasonOwnStagesRing'; +const String kReasonOwnStages = 'capReasonOwnStages'; + +/// WHOOP 4 has no step counter: its steps come from the strap's 100 Hz +/// pedometer over a live link only (live_step_runs.dart). +const String kReasonLiveSessions = 'capReasonLiveSessions'; + +/// A row that depends on whether the device sends it, where nobody has +/// confirmed it does: RR intervals are optional in the Heart Rate Service, so +/// a generic strap's (or a WHOOP read as one) beat timing is unconfirmed. A +/// device people use and send it (Polar's PPI stream) carries no caption. +const String kReasonUnconfirmed = 'capReasonUnconfirmed'; + +/// Pebble 2 SE has no HR sensor; only Pebble 2 can supply HR-based rows. +const String kReasonPebble2Only = 'capReasonPebble2Only'; + +/// [kReasonPebble2Only] on a row that is also an estimate on Pebble 2. +const String kReasonPebble2OnlyEstimated = 'capReasonPebble2OnlyEstimated'; + +/// l10n key of each capability's user-facing name. +const Map kCapabilityLabelKey = { + DeviceCapability.sleep: 'capLabelSleep', + DeviceCapability.recovery: 'capLabelRecovery', + DeviceCapability.strain: 'capLabelStrain', + DeviceCapability.heartRate: 'capLabelHeartRate', + DeviceCapability.hrv: 'capLabelHrv', + DeviceCapability.respiration: 'capLabelRespiration', + DeviceCapability.skinTemperature: 'capLabelSkinTemperature', + DeviceCapability.steps: 'capLabelSteps', + DeviceCapability.bloodOxygen: 'capLabelBloodOxygen', + DeviceCapability.workoutHeartRate: 'capLabelWorkoutHeartRate', + DeviceCapability.workoutBeatToBeat: 'capLabelWorkoutBeatToBeat', +}; + +typedef _Claim = ({CapabilityStatus status, CapabilityTrace trace}); + +const String _canonical = 'lib/compute/inputs/canonical.dart'; +const String _pipeline = 'lib/compute/onehz_pipeline.dart'; +const String _engine = 'lib/compute/derivation_engine.dart'; + +const CapabilityStatus _native = CapabilityStatus(CapabilityKind.native); + +CapabilityStatus _when(String reasonKey) => + CapabilityStatus(CapabilityKind.conditional, reasonKey: reasonKey); + +bool _nativeWhoop(BandEntry e) => kWhoopGen4.id == e.id || kWhoopGen5.id == e.id; + +/// The column [e] goes into, or null when it fits neither. +DeviceSlot? _slotOf(BandEntry e) { + if (_nativeWhoop(e)) return DeviceSlot.everyDay; + if (e.category == DeviceCategory.wearable && columnFor(e.id) != null) { + return DeviceSlot.everyDay; + } + if (kWorkoutArmedSensors.contains(e.id)) return DeviceSlot.workoutsOnly; + return null; +} + +/// Every capability [e] gives in [slot], each with the rule behind it. The one +/// place claims are made, so a claim cannot exist without its trace. +Map _claims(BandEntry e, DeviceSlot slot, + {bool modelKnown = true}) => + switch (slot) { + DeviceSlot.everyDay => _everyDayClaims(e, modelKnown: modelKnown), + DeviceSlot.workoutsOnly => _workoutClaims(e), + }; + +Map _everyDayClaims(BandEntry e, + {bool modelKnown = true}) { + if (!_nativeWhoop(e)) { + // The active wearable: its column's rows, behind its own switch. Coros has + // no column (and wearableEnabled() is false for it): nothing. + return e.category == DeviceCategory.wearable ? _columnClaims(e) : {}; + } + // The native pipeline (onehz_pipeline.dart): sleep, rmssd, resting HR, + // respiration, strain, readiness. Skin temperature needs a nightly mean, + // >= 3 prior nights and a baseline spread >= 1; WHOOP 5's deg C needs 14. + final out = { + for (final c in kDayCapabilities) + c: ( + status: c == DeviceCapability.skinTemperature + ? _when(kReasonSkinTempNights) + : _native, + trace: (rule: 'native WHOOP pipeline (${c.name})', source: _pipeline), + ), + }; + // Steps: WHOOP 5's cumulative on-chip counter rides every synced row; + // WHOOP 4 has none (derivation_engine.dart _stepCounterModulus), so only + // the live link's 100 Hz pedometer counts for it. + out[DeviceCapability.steps] = ( + status: !modelKnown + ? _when(kReasonUnconfirmed) + : e.id == kWhoopGen5.id ? _native : _when(kReasonLiveSessions), + trace: (rule: 'band steps (counter or live pedometer)', source: _engine), + ); + // The band records a workout itself. + for (final c in kSessionCapabilities) { + out[c] = (status: _native, trace: (rule: 'band workout session', source: _pipeline)); + } + return out; +} + +Map _workoutClaims(BandEntry e) { + // Only the sensors in kWorkoutArmedSensors (ble_hrs, polar_pmd) are session + // sources, and only with their switch on. A WHOOP kept for workouts is + // paired under ble_hrs, so it gets ble_hrs's claims. Anything else (a ring, + // Coros) sends nothing here. + final slotId = _nativeWhoop(e) ? kBleHrs.id : e.id; + if (!kWorkoutArmedSensors.contains(slotId)) return {}; + final out = {}; + final sig = declaredSignals(slotId).map((s) => s.name).toSet(); + const trace = ( + rule: 'workout session sensor (kWorkoutArmedSensors, flag on)', + source: _canonical, + ); + if (sig.contains('hr1Hz') || sig.contains('hrSparse')) { + out[DeviceCapability.workoutHeartRate] = (status: _native, trace: trace); + } + if (sig.contains('rrIntervals')) { + out[DeviceCapability.workoutBeatToBeat] = ( + status: slotId != kBleHrs.id ? _native : _when(kReasonUnconfirmed), + trace: trace, + ); + } + return out; +} + +/// [e]'s rows of the metric x device table, or none without a column. +Map _columnClaims(BandEntry e) { + final out = {}; + final col = columnFor(e.id); + if (col == null) return out; // Coros, sensors, scales: no column, no claim. + final cls = capabilities(col); + for (final m in kCapabilityRow.entries) { + var status = _statusOf(cls[m.value], col[m.value]); + if (status == null) continue; + if (status.kind == CapabilityKind.native) { + status = switch (m.key) { + // Ours is the window; the stages are the device's own. + DeviceCapability.sleep when cls['sleep_stages'] == MetricClass.device => + _when(e.kind == DeviceKind.ring + ? kReasonOwnStagesRing + : kReasonOwnStages), + _ => status, + }; + } + if (status.reasonKey == kReasonEarly) { + status = switch (m.key) { + DeviceCapability.recovery => _when(kReasonFirstNights), + DeviceCapability.skinTemperature => _when(kReasonSkinTempProvisional), + _ => status, + }; + } + // The shared Pebble entry covers the 2 SE too. It still serves the + // watch's reported sleep and steps without HR (dayCells), but cannot + // derive resting HR, strain or the resting-HR recovery estimate. + final pebbleHr = e.id == kPebble.id && + const {DeviceCapability.recovery, DeviceCapability.strain, + DeviceCapability.heartRate}.contains(m.key); + out[m.key] = ( + status: !pebbleHr + ? status + : _when(status.reasonKey == kReasonEstimated + ? kReasonPebble2OnlyEstimated + : kReasonPebble2Only), + trace: pebbleHr + ? (rule: 'Pebble 2 HR required for ${m.value}; SE has no HR sensor', + source: 'lib/compute/inputs/pebble_inputs.dart') + : (rule: 'metric x device column row ${m.value}', source: _canonical), + ); + } + return out; +} + +CapabilityStatus? _statusOf(MetricClass? cls, Cell? cell) => switch (cls) { + null || MetricClass.unavailable => null, + MetricClass.device => const CapabilityStatus(CapabilityKind.vendorReported), + MetricClass.estimated => _when(kReasonEstimated), + MetricClass.ours => cell?.provisionalAt != null ? _when(kReasonEarly) : _native, +}; + +/// The rule behind [c] for [e] in [slot], or null when no eligibility rule +/// supports the claim. +CapabilityTrace? capabilityTrace( + BandEntry e, + DeviceCapability c, { + required DeviceSlot slot, + bool modelKnown = true, +}) => _claims(e, slot, modelKnown: modelKnown)[c]?.trace; + +SlotSide _side(BandEntry e, DeviceSlot slot, {bool modelKnown = true}) { + final sends = { + for (final m in _claims(e, slot, modelKnown: modelKnown).entries) m.key: m.value.status, + }; + return SlotSide( + sends: sends, + doesNotSend: kTableRows.toSet().difference(sends.keys.toSet()), + ); +} + +SlotComparison slotComparisonFor(BandEntry e, {bool modelKnown = true}) => SlotComparison( + everyDay: _side(e, DeviceSlot.everyDay, modelKnown: modelKnown), + workoutsOnly: _side(e, DeviceSlot.workoutsOnly, modelKnown: modelKnown), + slot: _slotOf(e), +); diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index bfe9ab4b5..f297a0403 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -3613,6 +3613,95 @@ "pairModeTitle": "In den Kopplungsmodus versetzen", "pairModeNoSite": "Ein generisches Gerät ohne einzelnen Hersteller, daher gibt es keine Herstelleranleitung.", "pairOuraExistingKeyGuidance": "Nutzt du schon die Oura-App? Lass den Ring in der App gekoppelt und kopple ihn mit seinem vorhandenen Schlüssel. Überspringe die Schritte zum Zurücksetzen unten. Setze ihn nur zurück, wenn du einen neuen Schlüssel möchtest.", + "pairAddDevice": "Gerät hinzufügen", + "pairKindAll": "Alle", + "pairKindStrap": "Brustgurte & Armsensoren", + "pairKindRing": "Ringe", + "pairKindWatch": "Uhren", + "pairGoBack": "Zurück", + "pairAddDeviceSub": "Ringe, Uhren und Herzfrequenzgurte", + "pairAddDeviceSubtitle": "Bei jedem Gerät steht, wofür es passt: jeden Tag oder nur beim Training.", + "pairBandFoundBody": "Jeden Tag kann es viel mehr als nur beim Training. Was möchtest du?", + "pairBandFoundBodyHasBand": "Du hast schon ein Band. Es kann immer nur eines dein Band sein.", + "pairIdentifiedBody": "Es sah wie ein Herzfrequenzgurt aus, hat sich beim Verbinden aber als {label} gemeldet. Es wurde nichts gespeichert.", + "pairAsMyBand": "Als mein Band koppeln", + "pairSecondaryPaired": "Fürs Training gekoppelt.", + "pairBandNow": "Dein Band jetzt: {name}. Deine Daten bleiben beim Wechsel erhalten.", + "pairReplaceBand": "Dieses Band koppeln, dann {name} trennen", + "pairReplaceConfirmTitle": "{name} nach erfolgreicher Verbindung ersetzen?", + "pairReplaceConfirmBody": "Dein bisheriges Band bleibt bei Fehlern oder Abbruch gekoppelt. Daten, die bereits auf diesem Telefon gespeichert sind, bleiben erhalten. Was auf dem alten Band noch nicht synchronisiert wurde, wird nach dem Wechsel nicht mehr auf dieses Telefon übertragen.", + "pairReplaceConfirmYes": "Ersatz koppeln", + "pairCurrentBandFallback": "dein Band", + "pairWearableLead": "Es kann deine Tage mit Schlaf, Erholung und Herzfrequenz füllen.", + "pairWearableNote": "Füllt Tage ohne dein WHOOP. Experimentell, also schalte es unter Geräte ein.", + "pairStrapLead": "Es liefert Herzfrequenz beim Training. Schlaf, Erholung und tägliche Belastung zeichnet es nicht auf.", + "pairStrapNote": "Schalte „Beim Training nutzen“ ein, damit die Herzfrequenz beim Training aufgezeichnet wird.", + "pairDeviceNamed": "{name} koppeln", + "pairUseForWorkouts": "Nur fürs Training nutzen", + "pairReplaceUnpairFailed": "Dein neues Band ist gekoppelt, aber das alte Band konnte nicht entfernt werden.", + "pairWearableLeadPebble": "Pebble 2 kann deine Tage mit Schlaf und Herzfrequenz füllen. Pebble 2 SE zeigt die eigenen Schlaf- und Schrittdaten der Uhr. Sie hat keinen Herzfrequenzsensor, daher kann diese App daraus weder die tägliche Belastung berechnen noch die Erholung schätzen.", + "pairMainBandWhoopOnly": "Hauptband: nur WHOOP 4.0 oder WHOOP 5.0/MG. Andere Geräte lassen sich als zusätzliche Geräte hinzufügen.", + "pairBandTitle": "Band koppeln", + "pairBandSubtitle": "Wähle das, das du trägst. Wir suchen es in der Nähe.", + "pairStrapOnlyLink": "Ich habe nur einen Herzfrequenzgurt", + "pairWhoopRowLine": "Schlaf, Erholung, Belastung, Herzfrequenz und mehr", + "pairSetUpTitle": "Einrichten", + "capLabelSleep": "Schlaf", + "capLabelRecovery": "Erholung", + "capLabelStrain": "Belastung", + "capLabelHrv": "Herzfrequenzvariabilität", + "capLabelSkinTemperature": "Hauttemperatur", + "capLabelBloodOxygen": "Blutsauerstoff", + "capLabelWorkoutHeartRate": "Herzfrequenz beim Training", + "capLabelWorkoutBeatToBeat": "Abstand von Herzschlag zu Herzschlag beim Training", + "capLabelSteps": "Schritte", + "capReasonSkinTempNights": "Nach ein paar Nächten", + "capReasonEstimated": "Eine Schätzung, keine direkte Messung", + "capReasonEarly": "Erste Schätzung; wird in den ersten Wochen genauer", + "capVendorReported": "Eigener Messwert des Geräts", + "slotSendsHeading": "Liefert", + "slotDoesntSendHeading": "Liefert nicht", + "pairSectionTitle": "Gerät koppeln", + "pairCardBandBody": "Nur WHOOP 4.0 oder WHOOP 5.0/MG. Schlaf, Erholung und Belastung rund um die Uhr.", + "pairUnpairBand": "Band trennen", + "capLabelHeartRate": "Herzfrequenz und Ruhepuls", + "capLabelRespiration": "Atmung", + "capReasonFirstNights": "In den ersten 14 Nächten geschätzt", + "capReasonOwnStagesRing": "Aus den eigenen Schlafphasen des Rings", + "capReasonOwnStages": "Aus den eigenen Schlafphasen des Geräts", + "capReasonLiveSessions": "Während Live-Sitzungen", + "slotEveryDay": "Jeden Tag", + "slotWorkoutsOnly": "Nur Training", + "pairWearableCardNote": "Füllt Tage ohne dein WHOOP. Experimentell, also schalte es unten ein.", + "pairWhatItSends": "Was es sendet", + "capReasonUnconfirmed": "Falls das Gerät es sendet, nicht bestätigt", + "capReasonPebble2Only": "Nur Pebble 2. Die 2 SE hat keinen Herzfrequenzsensor.", + "capReasonPebble2OnlyEstimated": "Nur Pebble 2, und eine Schätzung, keine direkte Messung. Die 2 SE hat keinen Herzfrequenzsensor.", + "slotColumnReason": "{column}: {reason}", + "@slotColumnReason": { + "placeholders": { + "column": { + "type": "String" + }, + "reason": { + "type": "String" + } + } + }, + "slotCapabilityStatus": "{capability}, {column}: {status}", + "@slotCapabilityStatus": { + "placeholders": { + "capability": { + "type": "String" + }, + "column": { + "type": "String" + }, + "status": { + "type": "String" + } + } + }, "welcomeCoachKeyReentry": "Dein API-Schlüssel für den Coach bleibt im sicheren Speicher und wurde nicht gesichert. Gib ihn in den KI-Einstellungen erneut ein, um den Coach auf diesem Telefon zu nutzen.", "welcomeSettingsSkipped": "{n, plural, =1{1 Einstellung in der Sicherung war nicht lesbar und wurde übersprungen} other{{n} Einstellungen in der Sicherung waren nicht lesbar und wurden übersprungen}}", "@welcomeSettingsSkipped": { @@ -3686,40 +3775,14 @@ "whoopFirmwareWarningTitle": "WHOOP-Nutzer: Verbinde dich nicht wieder mit der WHOOP-App", "whoopFirmwareWarningAction": "Wenn du OpenStrap oder eine andere Open-Source-App nutzt oder später zu einer wechseln möchtest, verbinde dein Band nicht wieder mit der offiziellen WHOOP-App. Sie kann Firmware-Updates automatisch installieren. Deinstalliere oder deaktiviere die WHOOP-App, damit sie dein Band nicht aktualisiert.", "whoopFirmwareWarningDetails": "Berichte zur WHOOP 5.0 / MG Firmware 50.43.1.0 und 50.43.2.0 beschreiben einen blockierten Datenzugriff. Bluetooth kann sich weiterhin verbinden. OpenStrap kann das von WHOOP signierte Mitgliedschafts-Token nicht ausstellen, das betroffene Bänder entsperrt. Wir arbeiten an einer Lösung, aber es gibt noch keine Abhilfe.", - "bandStatusFirmwareLockedTitle": "Die Firmware des Bands hält wahrscheinlich seine Daten zurück", - "bandStatusFirmwareLockedReason": "Dieses Band läuft mit WHOOP-Firmware 50.43. Sie kann sich verbinden und der App antworten, aber keine Aufzeichnungen und keine Live-Herzfrequenz senden, solange kein von WHOOP signiertes Mitgliedschafts-Token auf dem Band ist. Das ist ein möglicher Grund, warum keine Daten ankommen. OpenStrap kann dieses Token nicht ausstellen. Alles, was hier schon gespeichert ist, bleibt erhalten.", - "bandStatusFirmwareLockedFix": "Liegt es an der Firmware, lässt sich das in der App nicht ändern, und der Hinweis verschwindet, sobald das Band wieder Aufzeichnungen sendet", - "healthWearNotUpdatedSince": "nicht aktualisiert seit {time}", - "dayStrainWornAsOf": "Getragen, Stand {time}", - "dayStepsWhoop4NoCounter": "Ein WHOOP 4.0 hat keinen eigenen Schrittzähler und zählt Schritte nur, solange diese App seine Live-Daten empfängt.", - "pairAddDevice": "Gerät hinzufügen", - "pairKindAll": "Alle", - "pairKindStrap": "Brustgurte & Armsensoren", - "pairKindRing": "Ringe", - "pairKindWatch": "Uhren", - "pairGoBack": "Zurück", - "pairAddDeviceSub": "Ringe, Uhren und Herzfrequenzgurte", - "pairAddDeviceSubtitle": "Bei jedem Gerät steht, wofür es passt: jeden Tag oder nur beim Training.", - "pairBandFoundBody": "Jeden Tag kann es viel mehr als nur beim Training. Was möchtest du?", - "pairBandFoundBodyHasBand": "Du hast schon ein Band. Es kann immer nur eines dein Band sein.", - "pairIdentifiedBody": "Es sah wie ein Herzfrequenzgurt aus, hat sich beim Verbinden aber als {label} gemeldet. Es wurde nichts gespeichert.", - "pairAsMyBand": "Als mein Band koppeln", - "pairSecondaryPaired": "Fürs Training gekoppelt.", - "pairBandNow": "Dein Band jetzt: {name}. Deine Daten bleiben beim Wechsel erhalten.", - "pairReplaceBand": "Dieses Band koppeln, dann {name} trennen", - "pairReplaceConfirmTitle": "{name} nach erfolgreicher Verbindung ersetzen?", - "pairReplaceConfirmBody": "Dein bisheriges Band bleibt bei Fehlern oder Abbruch gekoppelt. Daten, die bereits auf diesem Telefon gespeichert sind, bleiben erhalten. Was auf dem alten Band noch nicht synchronisiert wurde, wird nach dem Wechsel nicht mehr auf dieses Telefon übertragen.", - "pairReplaceConfirmYes": "Ersatz koppeln", - "pairCurrentBandFallback": "dein Band", - "pairWearableLead": "Es kann deine Tage mit Schlaf, Erholung und Herzfrequenz füllen.", - "pairWearableNote": "Füllt Tage ohne dein WHOOP. Experimentell, also schalte es unter Geräte ein.", - "pairStrapLead": "Es liefert Herzfrequenz beim Training. Schlaf, Erholung und tägliche Belastung zeichnet es nicht auf.", - "pairStrapNote": "Für beides muss „Beim Training nutzen“ an sein.", - "pairDeviceNamed": "{name} koppeln", - "pairUseForWorkouts": "Nur fürs Training nutzen", - "pairReplaceUnpairFailed": "Dein neues Band ist gekoppelt, aber das alte Band konnte nicht entfernt werden.", - "pairWearableLeadPebble": "Pebble 2 kann deine Tage mit Schlaf, Erholung und Herzfrequenz füllen. Pebble 2 SE zeigt die eigenen Schlaf- und Schrittdaten der Uhr. Sie hat keinen Herzfrequenzsensor, daher kann diese App daraus weder die tägliche Belastung berechnen noch die Erholung schätzen.", "pairSearchDevices": "Nach Geräten suchen", "pairPrimaryCannotBeSensor": "Dies ist bereits dein Hauptarmband. Es kann nicht zusätzlich als Trainingssensor gekoppelt werden.", - "pairReplaceMyBand": "Mein Band ersetzen" + "capReasonSkinTempProvisional": "Vorläufige Schätzung; benötigt einige Nächte", + "pairReplaceMyBand": "Mein Band ersetzen", + "dayStepsWhoop4NoCounter": "Ein WHOOP 4.0 hat keinen eigenen Schrittzähler und zählt Schritte nur, solange diese App seine Live-Daten empfängt.", + "healthWearNotUpdatedSince": "nicht aktualisiert seit {time}", + "dayStrainWornAsOf": "Getragen, Stand {time}", + "bandStatusFirmwareLockedTitle": "Die Firmware des Bands hält wahrscheinlich seine Daten zurück", + "bandStatusFirmwareLockedReason": "Dieses Band läuft mit WHOOP-Firmware 50.43. Sie kann sich verbinden und der App antworten, aber keine Aufzeichnungen und keine Live-Herzfrequenz senden, solange kein von WHOOP signiertes Mitgliedschafts-Token auf dem Band ist. Das ist ein möglicher Grund, warum keine Daten ankommen. OpenStrap kann dieses Token nicht ausstellen. Alles, was hier schon gespeichert ist, bleibt erhalten.", + "bandStatusFirmwareLockedFix": "Liegt es an der Firmware, lässt sich das in der App nicht ändern, und der Hinweis verschwindet, sobald das Band wieder Aufzeichnungen sendet" } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 01dbbbfff..8e39fcce6 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -16873,9 +16873,9 @@ "@pairStrapLead": { "description": "Sheet lead for a heart-rate strap or sensor." }, - "pairStrapNote": "Both need “Use during workouts” on.", + "pairStrapNote": "Turn on “Use during workouts” to record heart rate while you work out.", "@pairStrapNote": { - "description": "Note under a strap’s table: both workout rows need the switch. Quotes deviceUseWorkoutsTitle." + "description": "Note on a strap’s sheet: workout recording needs the switch. Quotes deviceUseWorkoutsTitle." }, "pairDeviceNamed": "Pair {name}", "@pairDeviceNamed": { @@ -16894,10 +16894,185 @@ "@pairReplaceUnpairFailed": { "description": "Shown when unpairing the old band failed during “Unpair (your band) and pair this one”; nothing else ran." }, - "pairWearableLeadPebble": "Pebble 2 can fill your days with sleep, recovery and heart rate. Pebble 2 SE shows the watch’s own sleep and steps. It has no heart-rate sensor, so this app cannot calculate daily strain or estimate recovery from it.", + "pairWearableLeadPebble": "Pebble 2 can fill your days with sleep and heart rate. Pebble 2 SE shows the watch’s own sleep and steps. It has no heart-rate sensor, so this app cannot calculate daily strain or estimate recovery from it.", "@pairWearableLeadPebble": { "description": "Pebble-family pairing lead: SE shows the watch’s own sleep and steps; no HR sensor means no app-calculated daily strain or recovery estimate from the SE alone." }, + "pairMainBandWhoopOnly": "Main band: WHOOP 4.0 or WHOOP 5.0/MG only. Other devices can be added as additional devices.", + "@pairMainBandWhoopOnly": { + "description": "Plain statement on the pairing screens: only WHOOP can be the main band; other devices are added as additional devices." + }, + "pairBandTitle": "Pair your band", + "@pairBandTitle": { + "description": "Title of the first-run list of bands." + }, + "pairBandSubtitle": "Pick the one you wear. We will look for it nearby.", + "@pairBandSubtitle": { + "description": "Subtitle of the first-run list of bands." + }, + "pairStrapOnlyLink": "I only have a heart-rate strap", + "@pairStrapOnlyLink": { + "description": "Text link under the band list for someone with only a heart-rate strap." + }, + "pairWhoopRowLine": "Sleep, recovery, strain, heart rate and more", + "@pairWhoopRowLine": { + "description": "Line under each WHOOP on the first-run list." + }, + "pairSetUpTitle": "Set up", + "@pairSetUpTitle": { + "description": "Top bar title of the first-run pairing screen." + }, + "capLabelSleep": "Sleep", + "@capLabelSleep": { + "description": "Name of a thing a device sends: sleep." + }, + "capLabelRecovery": "Recovery", + "@capLabelRecovery": { + "description": "Name of a thing a device sends: the morning recovery score." + }, + "capLabelStrain": "Strain", + "@capLabelStrain": { + "description": "Name of a thing a device sends: strain." + }, + "capLabelHrv": "Heart-rate variability", + "@capLabelHrv": { + "description": "Name of a thing a device sends: heart-rate variability." + }, + "capLabelSkinTemperature": "Skin temperature", + "@capLabelSkinTemperature": { + "description": "Name of a thing a device sends: skin temperature." + }, + "capLabelBloodOxygen": "Blood oxygen", + "@capLabelBloodOxygen": { + "description": "Name of a thing a device sends: blood oxygen (only a device’s own reading)." + }, + "capLabelWorkoutHeartRate": "Heart rate during workouts", + "@capLabelWorkoutHeartRate": { + "description": "Table row: heart rate during a workout." + }, + "capLabelWorkoutBeatToBeat": "Beat-to-beat timing during workouts", + "@capLabelWorkoutBeatToBeat": { + "description": "Table row: beat-to-beat timing during a workout." + }, + "capLabelSteps": "Steps", + "@capLabelSteps": { + "description": "Name of a thing a device sends: steps." + }, + "capReasonSkinTempNights": "After a few nights", + "@capReasonSkinTempNights": { + "description": "Caption under Skin temperature: it needs a few nights first." + }, + "capReasonEstimated": "An estimate, not a direct reading", + "@capReasonEstimated": { + "description": "Why a value is conditional: it is an estimate, not a direct reading." + }, + "capReasonEarly": "Early estimate; it firms up over the first weeks", + "@capReasonEarly": { + "description": "Why a value is conditional: it is an early estimate that firms up over the first weeks." + }, + "capVendorReported": "The device’s own reading", + "@capVendorReported": { + "description": "Tag on a value that is the device’s own reading, not calculated by this app." + }, + "slotSendsHeading": "Sends", + "@slotSendsHeading": { + "description": "Heading above the list of what a device sends." + }, + "slotDoesntSendHeading": "Doesn’t send", + "@slotDoesntSendHeading": { + "description": "Heading above the list of what a secondary sensor does not send." + }, + "pairSectionTitle": "Pair a device", + "@pairSectionTitle": { + "description": "Heading of the section in My sources that holds pairing." + }, + "pairCardBandBody": "WHOOP 4.0 or WHOOP 5.0/MG only. Sleep, recovery and strain, around the clock.", + "@pairCardBandBody": { + "description": "Body of the Your band card in Settings." + }, + "pairUnpairBand": "Unpair band", + "@pairUnpairBand": { + "description": "Red outline button that starts forgetting the paired band (a confirm dialog follows)." + }, + "capLabelHeartRate": "Heart rate and resting heart rate", + "@capLabelHeartRate": { + "description": "Table row: heart rate and resting heart rate, as one capability." + }, + "capLabelRespiration": "Respiration", + "@capLabelRespiration": { + "description": "Table row: breathing rate." + }, + "capReasonFirstNights": "Estimated for the first 14 nights", + "@capReasonFirstNights": { + "description": "Caption under Recovery for a ring or watch: its recovery is an estimate until 14 nights of baseline." + }, + "capReasonOwnStagesRing": "From the ring’s own sleep stages", + "@capReasonOwnStagesRing": { + "description": "Caption under Sleep for a ring: the sleep stages are the ring’s own." + }, + "capReasonOwnStages": "From the device’s own sleep stages", + "@capReasonOwnStages": { + "description": "Caption under Sleep for a watch or fitness band: the sleep stages are the device’s own." + }, + "capReasonLiveSessions": "During live sessions", + "@capReasonLiveSessions": { + "description": "Caption under Steps for WHOOP 4: it counts steps only while the app has a live connection." + }, + "slotEveryDay": "Every day", + "@slotEveryDay": { + "description": "Column and chip: the device is used every day (the main band, or the ring/watch that fills days)." + }, + "slotWorkoutsOnly": "Workouts only", + "@slotWorkoutsOnly": { + "description": "Column and chip: the device is used only during workouts." + }, + "pairWearableCardNote": "Fills days without your WHOOP. Experimental, so switch it on below.", + "@pairWearableCardNote": { + "description": "Note under a ring’s or watch’s table on its device page; the switch is below it." + }, + "pairWhatItSends": "What it sends", + "@pairWhatItSends": { + "description": "Heading above the table on a device page." + }, + "capReasonUnconfirmed": "If this device sends it, not confirmed", + "@capReasonUnconfirmed": { + "description": "Caption under a row the device may or may not send; nobody has confirmed it does." + }, + "capReasonPebble2Only": "Pebble 2 only. The 2 SE has no heart-rate sensor.", + "@capReasonPebble2Only": { + "description": "Caption under the heart rate, strain and recovery rows for Pebble: the shared Pebble entry covers the 2 SE, which has no heart-rate sensor." + }, + "capReasonPebble2OnlyEstimated": "Pebble 2 only, and an estimate, not a direct reading. The 2 SE has no heart-rate sensor.", + "@capReasonPebble2OnlyEstimated": { + "description": "Caption under Pebble's recovery row: Pebble 2 only (the 2 SE has no heart-rate sensor), and recovery is an estimate." + }, + "slotColumnReason": "{column}: {reason}", + "@slotColumnReason": { + "description": "Capability caption naming the column it applies to.", + "placeholders": { + "column": { + "type": "String" + }, + "reason": { + "type": "String" + } + } + }, + "slotCapabilityStatus": "{capability}, {column}: {status}", + "@slotCapabilityStatus": { + "description": "Accessible table result with capability, column and sends status.", + "placeholders": { + "capability": { + "type": "String" + }, + "column": { + "type": "String" + }, + "status": { + "type": "String" + } + } + }, "welcomeCoachKeyReentry": "Your coach API key stays in secure storage and was not backed up. Enter it again in AI settings to use the coach on this phone.", "welcomeSettingsSkipped": "{n, plural, =1{1 setting in the backup could not be read and was skipped} other{{n} settings in the backup could not be read and were skipped}}", "@welcomeSettingsSkipped": { @@ -16957,6 +17132,7 @@ "napAutoLogSaveFailed": "That setting could not be saved. Try again.", "pairSearchDevices": "Search for devices", "pairPrimaryCannotBeSensor": "This is already your main band. It cannot also be paired as a workout sensor.", + "capReasonSkinTempProvisional": "Provisional estimate; needs a few nights", "pairReplaceMyBand": "Replace my band", "healthWearNotUpdatedSince": "not updated since {time}", "@healthWearNotUpdatedSince": { diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index be47323da..ef4028a8a 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -3063,6 +3063,95 @@ "pairModeTitle": "Ponlo en modo de emparejamiento", "pairModeNoSite": "Un dispositivo genérico sin un único fabricante, así que no hay pasos del fabricante.", "pairOuraExistingKeyGuidance": "¿Ya usas la app de Oura? Mantén el anillo en esa app y emparéjalo con la clave que ya tiene. Omite los pasos de restablecimiento de abajo. Restablécelo solo si quieres una clave nueva.", + "pairAddDevice": "Añadir un dispositivo", + "pairKindAll": "Todos", + "pairKindStrap": "Bandas de pecho y brazo", + "pairKindRing": "Anillos", + "pairKindWatch": "Relojes", + "pairGoBack": "Volver", + "pairAddDeviceSub": "Anillos, relojes y bandas de frecuencia cardiaca", + "pairAddDeviceSubtitle": "Cada dispositivo muestra dónde encaja: todos los días o solo en entrenamientos.", + "pairBandFoundBody": "Hace mucho más todos los días que solo en los entrenamientos. ¿Qué prefieres?", + "pairBandFoundBodyHasBand": "Ya tienes una pulsera. Solo una puede ser tu pulsera a la vez.", + "pairIdentifiedBody": "Parecía una banda de frecuencia cardíaca, pero al conectar se identificó como {label}. No se guardó nada.", + "pairAsMyBand": "Emparejar como mi pulsera", + "pairSecondaryPaired": "Emparejado solo para entrenamientos.", + "pairBandNow": "Tu pulsera ahora: {name}. Tus datos se conservan al cambiar.", + "pairReplaceBand": "Vincular esta pulsera y después desconectar {name}", + "pairReplaceConfirmTitle": "¿Reemplazar {name} después de conectar esta pulsera?", + "pairReplaceConfirmBody": "Tu pulsera actual seguirá vinculada si falla la configuración o cancelas. Los datos ya guardados en este teléfono se conservan. Lo que aún no se haya sincronizado desde la pulsera anterior no se sincronizará con este teléfono tras el cambio.", + "pairReplaceConfirmYes": "Vincular reemplazo", + "pairCurrentBandFallback": "tu pulsera", + "pairWearableLead": "Puede completar tus días con sueño, recuperación y frecuencia cardiaca.", + "pairWearableNote": "Completa los días sin tu WHOOP. Es experimental, así que actívalo en Dispositivos.", + "pairStrapLead": "Añade la frecuencia cardiaca mientras entrenas. No registra sueño, recuperación ni esfuerzo diario.", + "pairStrapNote": "Activa «Usar durante los entrenamientos» para registrar la frecuencia cardiaca durante los entrenamientos.", + "pairDeviceNamed": "Emparejar {name}", + "pairUseForWorkouts": "Usarla solo para entrenamientos", + "pairReplaceUnpairFailed": "Tu pulsera nueva está emparejada, pero no se pudo quitar la anterior.", + "pairWearableLeadPebble": "Pebble 2 puede completar tus días con sueño y frecuencia cardiaca. Pebble 2 SE muestra el sueño y los pasos registrados por el propio reloj. No tiene sensor de frecuencia cardiaca, por lo que esta app no puede calcular la carga diaria ni estimar la recuperación a partir de sus datos.", + "pairMainBandWhoopOnly": "Pulsera principal: solo WHOOP 4.0 o WHOOP 5.0/MG. Los demás dispositivos se pueden añadir como dispositivos adicionales.", + "pairBandTitle": "Empareja tu pulsera", + "pairBandSubtitle": "Elige la que llevas puesta. La buscaremos cerca.", + "pairStrapOnlyLink": "Solo tengo una banda de frecuencia cardíaca", + "pairWhoopRowLine": "Sueño, recuperación, esfuerzo, frecuencia cardiaca y más", + "pairSetUpTitle": "Configurar", + "capLabelSleep": "Sueño", + "capLabelRecovery": "Recuperación", + "capLabelStrain": "Esfuerzo", + "capLabelHrv": "Variabilidad de la frecuencia cardíaca", + "capLabelSkinTemperature": "Temperatura de la piel", + "capLabelBloodOxygen": "Oxígeno en sangre", + "capLabelWorkoutHeartRate": "Frecuencia cardíaca durante los entrenamientos", + "capLabelWorkoutBeatToBeat": "Tiempo entre latidos durante los entrenamientos", + "capLabelSteps": "Pasos", + "capReasonSkinTempNights": "Tras algunas noches", + "capReasonEstimated": "Una estimación, no una medición directa", + "capReasonEarly": "Estimación inicial; mejora durante las primeras semanas", + "capVendorReported": "La medición propia del dispositivo", + "slotSendsHeading": "Envía", + "slotDoesntSendHeading": "No envía", + "pairSectionTitle": "Emparejar un dispositivo", + "pairCardBandBody": "Solo WHOOP 4.0 o WHOOP 5.0/MG. Sueño, recuperación y esfuerzo, todo el día.", + "pairUnpairBand": "Desemparejar pulsera", + "capLabelHeartRate": "Frecuencia cardiaca y en reposo", + "capLabelRespiration": "Respiración", + "capReasonFirstNights": "Estimada durante las primeras 14 noches", + "capReasonOwnStagesRing": "A partir de las fases de sueño del propio anillo", + "capReasonOwnStages": "A partir de las fases de sueño del propio dispositivo", + "capReasonLiveSessions": "Durante las sesiones en vivo", + "slotEveryDay": "Todos los días", + "slotWorkoutsOnly": "Solo entrenamientos", + "pairWearableCardNote": "Completa los días sin tu WHOOP. Es experimental, así que actívalo abajo.", + "pairWhatItSends": "Qué envía", + "capReasonUnconfirmed": "Si este dispositivo lo envía, sin confirmar", + "capReasonPebble2Only": "Solo Pebble 2. El 2 SE no tiene sensor de frecuencia cardiaca.", + "capReasonPebble2OnlyEstimated": "Solo Pebble 2, y es una estimación, no una medición directa. El 2 SE no tiene sensor de frecuencia cardiaca.", + "slotColumnReason": "{column}: {reason}", + "@slotColumnReason": { + "placeholders": { + "column": { + "type": "String" + }, + "reason": { + "type": "String" + } + } + }, + "slotCapabilityStatus": "{capability}, {column}: {status}", + "@slotCapabilityStatus": { + "placeholders": { + "capability": { + "type": "String" + }, + "column": { + "type": "String" + }, + "status": { + "type": "String" + } + } + }, "alarmNextLabel": "SIGUIENTE", "alarmScheduleGroup": "Horario semanal", "alarmWakeTimeRowTitle": "Hora de despertar", @@ -3386,40 +3475,14 @@ "whoopFirmwareWarningTitle": "Usuarios de WHOOP: no vuelvas a conectarte a la app de WHOOP", "whoopFirmwareWarningAction": "Si usas OpenStrap u otra app de código abierto, o piensas cambiarte a una más adelante, no vuelvas a conectar tu banda a la app oficial de WHOOP. Puede instalar actualizaciones de firmware automáticamente. Desinstala o desactiva la app de WHOOP para evitar que actualice tu banda.", "whoopFirmwareWarningDetails": "Hay informes de que el firmware 50.43.1.0 y 50.43.2.0 de WHOOP 5.0 / MG bloquea el acceso a los datos. Es posible que el Bluetooth siga conectándose. OpenStrap no puede emitir el token de membresía firmado por WHOOP que se necesita para desbloquear las bandas afectadas. Estamos trabajando en una solución, pero todavía no hay ningún arreglo disponible.", - "bandStatusFirmwareLockedTitle": "Probablemente el firmware de la banda está reteniendo sus datos", - "bandStatusFirmwareLockedReason": "Esta banda usa el firmware 50.43 de WHOOP, que puede conectarse y responder a la app sin enviar registros ni frecuencia cardíaca en vivo hasta que haya en ella un token de membresía firmado por WHOOP. Es una posible razón de que no lleguen datos. OpenStrap no puede emitir ese token. Todo lo que ya está guardado aquí está a salvo.", - "bandStatusFirmwareLockedFix": "Si es el firmware, la app no puede cambiarlo y el aviso desaparece cuando la banda vuelva a enviar registros", - "healthWearNotUpdatedSince": "sin actualizar desde {time}", - "dayStrainWornAsOf": "Llevada, a las {time}", - "dayStepsWhoop4NoCounter": "Una WHOOP 4.0 no tiene contador de pasos propio, así que solo cuenta pasos mientras esta app recibe sus datos en vivo.", - "pairAddDevice": "Añadir un dispositivo", - "pairKindAll": "Todos", - "pairKindStrap": "Bandas de pecho y brazo", - "pairKindRing": "Anillos", - "pairKindWatch": "Relojes", - "pairGoBack": "Volver", - "pairAddDeviceSub": "Anillos, relojes y bandas de frecuencia cardiaca", - "pairAddDeviceSubtitle": "Cada dispositivo muestra dónde encaja: todos los días o solo en entrenamientos.", - "pairBandFoundBody": "Hace mucho más todos los días que solo en los entrenamientos. ¿Qué prefieres?", - "pairBandFoundBodyHasBand": "Ya tienes una pulsera. Solo una puede ser tu pulsera a la vez.", - "pairIdentifiedBody": "Parecía una banda de frecuencia cardíaca, pero al conectar se identificó como {label}. No se guardó nada.", - "pairAsMyBand": "Emparejar como mi pulsera", - "pairSecondaryPaired": "Emparejado solo para entrenamientos.", - "pairBandNow": "Tu pulsera ahora: {name}. Tus datos se conservan al cambiar.", - "pairReplaceBand": "Vincular esta pulsera y después desconectar {name}", - "pairReplaceConfirmTitle": "¿Reemplazar {name} después de conectar esta pulsera?", - "pairReplaceConfirmBody": "Tu pulsera actual seguirá vinculada si falla la configuración o cancelas. Los datos ya guardados en este teléfono se conservan. Lo que aún no se haya sincronizado desde la pulsera anterior no se sincronizará con este teléfono tras el cambio.", - "pairReplaceConfirmYes": "Vincular reemplazo", - "pairCurrentBandFallback": "tu pulsera", - "pairWearableLead": "Puede completar tus días con sueño, recuperación y frecuencia cardiaca.", - "pairWearableNote": "Completa los días sin tu WHOOP. Es experimental, así que actívalo en Dispositivos.", - "pairStrapLead": "Añade la frecuencia cardiaca mientras entrenas. No registra sueño, recuperación ni esfuerzo diario.", - "pairStrapNote": "Ambos necesitan «Usar durante los entrenamientos» activado.", - "pairDeviceNamed": "Emparejar {name}", - "pairUseForWorkouts": "Usarla solo para entrenamientos", - "pairReplaceUnpairFailed": "Tu pulsera nueva está emparejada, pero no se pudo quitar la anterior.", - "pairWearableLeadPebble": "Pebble 2 puede completar tus días con sueño, recuperación y frecuencia cardiaca. Pebble 2 SE muestra el sueño y los pasos registrados por el propio reloj. No tiene sensor de frecuencia cardiaca, por lo que esta app no puede calcular la carga diaria ni estimar la recuperación a partir de sus datos.", "pairSearchDevices": "Buscar dispositivos", "pairPrimaryCannotBeSensor": "Esta ya es tu pulsera principal. No se puede emparejar también como sensor de entrenamiento.", - "pairReplaceMyBand": "Reemplazar mi pulsera" + "capReasonSkinTempProvisional": "Estimación provisional; requiere algunas noches", + "pairReplaceMyBand": "Reemplazar mi pulsera", + "dayStepsWhoop4NoCounter": "Una WHOOP 4.0 no tiene contador de pasos propio, así que solo cuenta pasos mientras esta app recibe sus datos en vivo.", + "healthWearNotUpdatedSince": "sin actualizar desde {time}", + "dayStrainWornAsOf": "Llevada, a las {time}", + "bandStatusFirmwareLockedTitle": "Probablemente el firmware de la banda está reteniendo sus datos", + "bandStatusFirmwareLockedReason": "Esta banda usa el firmware 50.43 de WHOOP, que puede conectarse y responder a la app sin enviar registros ni frecuencia cardíaca en vivo hasta que haya en ella un token de membresía firmado por WHOOP. Es una posible razón de que no lleguen datos. OpenStrap no puede emitir ese token. Todo lo que ya está guardado aquí está a salvo.", + "bandStatusFirmwareLockedFix": "Si es el firmware, la app no puede cambiarlo y el aviso desaparece cuando la banda vuelva a enviar registros" } diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 54f08cbe8..a19cf869b 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -3383,15 +3383,6 @@ "pairModeTitle": "Mettez-le en mode association", "pairModeNoSite": "Un appareil générique sans fabricant unique : il n’y a donc pas d’étapes du fabricant.", "pairOuraExistingKeyGuidance": "Vous utilisez déjà l’application Oura ? Gardez l’anneau associé dans cette application et associez-le avec sa clé actuelle. Passez les étapes de réinitialisation ci-dessous. Réinitialisez-le uniquement si vous voulez une nouvelle clé.", - "whoopFirmwareWarningTitle": "Utilisateurs WHOOP : ne vous reconnectez pas à l’application WHOOP", - "whoopFirmwareWarningAction": "Si vous utilisez OpenStrap ou une autre application open source, ou si vous comptez y passer plus tard, ne reconnectez pas votre bracelet à l’application WHOOP officielle. Elle peut installer des mises à jour du firmware automatiquement. Désinstallez ou désactivez l’application WHOOP pour l’empêcher de mettre à jour votre bracelet.", - "whoopFirmwareWarningDetails": "Des signalements concernant les firmwares 50.43.1.0 et 50.43.2.0 des WHOOP 5.0 / MG décrivent un accès aux données bloqué. Le Bluetooth peut encore se connecter. OpenStrap ne peut pas émettre le jeton d’abonnement signé par WHOOP nécessaire pour déverrouiller les bracelets concernés. Nous travaillons sur une solution, mais aucun correctif n’est encore disponible.", - "bandStatusFirmwareLockedTitle": "Le firmware du bracelet retient probablement ses données", - "bandStatusFirmwareLockedReason": "Ce bracelet utilise le firmware WHOOP 50.43, qui peut se connecter et répondre à l’application sans envoyer ni enregistrements ni fréquence cardiaque en direct tant qu’un jeton d’abonnement signé par WHOOP n’est pas présent sur le bracelet. C’est une raison possible pour laquelle aucune donnée n’arrive. OpenStrap ne peut pas émettre ce jeton. Tout ce qui est déjà enregistré ici est en sécurité.", - "bandStatusFirmwareLockedFix": "Si c’est le firmware, l’application n’y peut rien et ce message disparaît dès que le bracelet renvoie des enregistrements", - "healthWearNotUpdatedSince": "pas mis à jour depuis {time}", - "dayStrainWornAsOf": "Porté, à {time}", - "dayStepsWhoop4NoCounter": "Un WHOOP 4.0 n’a pas de podomètre intégré : il ne compte les pas que lorsque cette application reçoit ses données en direct.", "pairAddDevice": "Ajouter un appareil", "pairKindAll": "Tous", "pairKindStrap": "Ceintures et brassards", @@ -3414,12 +3405,84 @@ "pairWearableLead": "Il peut compléter vos journées avec le sommeil, la récupération et la fréquence cardiaque.", "pairWearableNote": "Complète les jours sans votre WHOOP. Expérimental : activez-le dans Appareils.", "pairStrapLead": "Il ajoute la fréquence cardiaque pendant l’entraînement. Il n’enregistre ni le sommeil, ni la récupération, ni l’effort quotidien.", - "pairStrapNote": "Les deux nécessitent « Utiliser pendant les entraînements » activé.", + "pairStrapNote": "Activez « Utiliser pendant les entraînements » pour enregistrer la fréquence cardiaque pendant vos entraînements.", "pairDeviceNamed": "Associer {name}", "pairUseForWorkouts": "L’utiliser seulement pour les entraînements", "pairReplaceUnpairFailed": "Votre nouveau bracelet est associé, mais l’ancien n’a pas pu être retiré.", - "pairWearableLeadPebble": "Pebble 2 peut compléter vos journées avec le sommeil, la récupération et la fréquence cardiaque. Pebble 2 SE affiche le sommeil et les pas enregistrés par la montre. Elle n’a pas de capteur de fréquence cardiaque, donc cette app ne peut pas calculer la charge quotidienne ni estimer la récupération à partir de ses données.", + "pairWearableLeadPebble": "Pebble 2 peut compléter vos journées avec le sommeil et la fréquence cardiaque. Pebble 2 SE affiche le sommeil et les pas enregistrés par la montre. Elle n’a pas de capteur de fréquence cardiaque, donc cette app ne peut pas calculer la charge quotidienne ni estimer la récupération à partir de ses données.", + "pairMainBandWhoopOnly": "Bracelet principal : uniquement WHOOP 4.0 ou WHOOP 5.0/MG. Les autres appareils peuvent être ajoutés comme appareils supplémentaires.", + "pairBandTitle": "Associez votre bracelet", + "pairBandSubtitle": "Choisissez celui que vous portez. Nous le chercherons à proximité.", + "pairStrapOnlyLink": "J’ai seulement une ceinture cardiaque", + "pairWhoopRowLine": "Sommeil, récupération, effort, fréquence cardiaque et plus", + "pairSetUpTitle": "Configuration", + "capLabelSleep": "Sommeil", + "capLabelRecovery": "Récupération", + "capLabelStrain": "Effort", + "capLabelHrv": "Variabilité de la fréquence cardiaque", + "capLabelSkinTemperature": "Température de la peau", + "capLabelBloodOxygen": "Oxygène dans le sang", + "capLabelWorkoutHeartRate": "Fréquence cardiaque pendant les séances", + "capLabelWorkoutBeatToBeat": "Intervalle entre les battements pendant les séances", + "capLabelSteps": "Pas", + "capReasonSkinTempNights": "Après quelques nuits", + "capReasonEstimated": "Une estimation, pas une mesure directe", + "capReasonEarly": "Estimation initiale ; elle s’affine au fil des premières semaines", + "capVendorReported": "La mesure propre à l’appareil", + "slotSendsHeading": "Envoie", + "slotDoesntSendHeading": "N’envoie pas", + "pairSectionTitle": "Associer un appareil", + "pairCardBandBody": "WHOOP 4.0 ou WHOOP 5.0/MG uniquement. Sommeil, récupération et effort, 24 h sur 24.", + "pairUnpairBand": "Dissocier le bracelet", + "capLabelHeartRate": "Fréquence cardiaque et au repos", + "capLabelRespiration": "Respiration", + "capReasonFirstNights": "Estimée pendant les 14 premières nuits", + "capReasonOwnStagesRing": "D’après les phases de sommeil de la bague", + "capReasonOwnStages": "D’après les phases de sommeil de l’appareil", + "capReasonLiveSessions": "Pendant les sessions en direct", + "slotEveryDay": "Tous les jours", + "slotWorkoutsOnly": "Entraînements seulement", + "pairWearableCardNote": "Complète les jours sans votre WHOOP. Expérimental : activez-le ci-dessous.", + "pairWhatItSends": "Ce qu’il envoie", + "capReasonUnconfirmed": "Si cet appareil l’envoie, non confirmé", + "capReasonPebble2Only": "Pebble 2 uniquement. La 2 SE n’a pas de capteur de fréquence cardiaque.", + "capReasonPebble2OnlyEstimated": "Pebble 2 uniquement, et c’est une estimation, pas une mesure directe. La 2 SE n’a pas de capteur de fréquence cardiaque.", + "slotColumnReason": "{column} : {reason}", + "@slotColumnReason": { + "placeholders": { + "column": { + "type": "String" + }, + "reason": { + "type": "String" + } + } + }, + "slotCapabilityStatus": "{capability}, {column} : {status}", + "@slotCapabilityStatus": { + "placeholders": { + "capability": { + "type": "String" + }, + "column": { + "type": "String" + }, + "status": { + "type": "String" + } + } + }, + "whoopFirmwareWarningTitle": "Utilisateurs WHOOP : ne vous reconnectez pas à l’application WHOOP", + "whoopFirmwareWarningAction": "Si vous utilisez OpenStrap ou une autre application open source, ou si vous comptez y passer plus tard, ne reconnectez pas votre bracelet à l’application WHOOP officielle. Elle peut installer des mises à jour du firmware automatiquement. Désinstallez ou désactivez l’application WHOOP pour l’empêcher de mettre à jour votre bracelet.", + "whoopFirmwareWarningDetails": "Des signalements concernant les firmwares 50.43.1.0 et 50.43.2.0 des WHOOP 5.0 / MG décrivent un accès aux données bloqué. Le Bluetooth peut encore se connecter. OpenStrap ne peut pas émettre le jeton d’abonnement signé par WHOOP nécessaire pour déverrouiller les bracelets concernés. Nous travaillons sur une solution, mais aucun correctif n’est encore disponible.", "pairSearchDevices": "Rechercher des appareils", "pairPrimaryCannotBeSensor": "C’est déjà votre bracelet principal. Il ne peut pas aussi être jumelé comme capteur d’entraînement.", - "pairReplaceMyBand": "Remplacer mon bracelet" + "capReasonSkinTempProvisional": "Estimation provisoire ; nécessite quelques nuits", + "pairReplaceMyBand": "Remplacer mon bracelet", + "dayStepsWhoop4NoCounter": "Un WHOOP 4.0 n’a pas de podomètre intégré : il ne compte les pas que lorsque cette application reçoit ses données en direct.", + "healthWearNotUpdatedSince": "pas mis à jour depuis {time}", + "dayStrainWornAsOf": "Porté, à {time}", + "bandStatusFirmwareLockedTitle": "Le firmware du bracelet retient probablement ses données", + "bandStatusFirmwareLockedReason": "Ce bracelet utilise le firmware WHOOP 50.43, qui peut se connecter et répondre à l’application sans envoyer ni enregistrements ni fréquence cardiaque en direct tant qu’un jeton d’abonnement signé par WHOOP n’est pas présent sur le bracelet. C’est une raison possible pour laquelle aucune donnée n’arrive. OpenStrap ne peut pas émettre ce jeton. Tout ce qui est déjà enregistré ici est en sécurité.", + "bandStatusFirmwareLockedFix": "Si c’est le firmware, l’application n’y peut rien et ce message disparaît dès que le bracelet renvoie des enregistrements" } diff --git a/lib/l10n/app_hi.arb b/lib/l10n/app_hi.arb index 81e005d33..6154a902b 100644 --- a/lib/l10n/app_hi.arb +++ b/lib/l10n/app_hi.arb @@ -3034,12 +3034,101 @@ "pairModeTitle": "इसे पेयरिंग मोड में डालें", "pairModeNoSite": "यह किसी एक निर्माता का नहीं, एक सामान्य डिवाइस है, इसलिए निर्माता के कोई चरण नहीं हैं।", "pairOuraExistingKeyGuidance": "क्या आप पहले से Oura ऐप इस्तेमाल करते हैं? रिंग को उस ऐप में पेयर रहने दें और उसकी मौजूदा कुंजी से पेयर करें। नीचे दिए रीसेट के चरण छोड़ दें। केवल नई कुंजी चाहिए तो ही रीसेट करें।", + "pairAddDevice": "डिवाइस जोड़ें", + "pairKindAll": "सभी", + "pairKindStrap": "चेस्ट स्ट्रैप और आर्मबैंड", + "pairKindRing": "रिंग", + "pairKindWatch": "घड़ियाँ", + "pairGoBack": "वापस जाएँ", + "pairAddDeviceSub": "रिंग, घड़ियाँ और हार्ट-रेट स्ट्रैप", + "pairAddDeviceSubtitle": "हर डिवाइस दिखाता है कि वह कहाँ फ़िट होता है: हर दिन, या केवल वर्कआउट में।", + "pairBandFoundBody": "यह सिर्फ़ वर्कआउट की तुलना में हर दिन कहीं ज़्यादा करता है। आप क्या चाहते हैं?", + "pairBandFoundBodyHasBand": "आपके पास पहले से एक बैंड है। एक समय में केवल एक ही आपका बैंड हो सकता है।", + "pairIdentifiedBody": "यह हार्ट-रेट स्ट्रैप जैसा दिखा, लेकिन कनेक्ट होने पर इसने खुद को {label} बताया। कुछ भी सहेजा नहीं गया।", + "pairAsMyBand": "इसे मेरे बैंड के रूप में पेयर करें", + "pairSecondaryPaired": "केवल वर्कआउट के लिए पेयर किया गया।", + "pairBandNow": "अभी आपका बैंड: {name}। बदलने पर आपका डेटा बना रहता है।", + "pairReplaceBand": "यह बैंड पेयर करें, फिर {name} को डिस्कनेक्ट करें", + "pairReplaceConfirmTitle": "यह बैंड कनेक्ट होने के बाद {name} को बदलें?", + "pairReplaceConfirmBody": "सेटअप विफल होने या रद्द करने पर आपका मौजूदा बैंड पेयर रहेगा। इस फ़ोन पर पहले से सहेजा गया डेटा बना रहेगा। पुराने बैंड पर जो डेटा अभी सिंक नहीं हुआ है, वह बदलाव के बाद इस फ़ोन पर सिंक नहीं होगा।", + "pairReplaceConfirmYes": "नया बैंड पेयर करें", + "pairCurrentBandFallback": "आपका बैंड", + "pairWearableLead": "यह आपके दिनों को नींद, रिकवरी और हृदय गति से भर सकता है।", + "pairWearableNote": "आपके WHOOP के बिना वाले दिनों को भरता है। प्रायोगिक है, इसलिए इसे डिवाइस में चालू करें।", + "pairStrapLead": "यह वर्कआउट के दौरान हृदय गति जोड़ता है। यह नींद, रिकवरी या दैनिक शारीरिक परिश्रम रिकॉर्ड नहीं करता।", + "pairStrapNote": "वर्कआउट के दौरान हृदय गति रिकॉर्ड करने के लिए “वर्कआउट के दौरान इस्तेमाल करें” चालू करें।", + "pairDeviceNamed": "{name} पेयर करें", + "pairUseForWorkouts": "इसे केवल वर्कआउट के लिए इस्तेमाल करें", + "pairReplaceUnpairFailed": "आपका नया बैंड पेयर हो गया है, लेकिन पुराना बैंड हटाया नहीं जा सका।", + "pairWearableLeadPebble": "Pebble 2 आपके दिनों को नींद और हृदय गति से भर सकता है। Pebble 2 SE घड़ी की अपनी नींद और कदमों की रीडिंग दिखाता है। उसमें हृदय गति सेंसर नहीं है, इसलिए यह ऐप उसके डेटा से रोज़ का शारीरिक भार नहीं निकाल सकता और न ही रिकवरी का अनुमान लगा सकता है।", + "pairMainBandWhoopOnly": "मुख्य बैंड: केवल WHOOP 4.0 या WHOOP 5.0/MG। दूसरे डिवाइस अतिरिक्त डिवाइस के रूप में जोड़े जा सकते हैं।", + "pairBandTitle": "अपना बैंड पेयर करें", + "pairBandSubtitle": "वही चुनें जो आप पहनते हैं। हम उसे आस-पास खोजेंगे।", + "pairStrapOnlyLink": "मेरे पास सिर्फ़ हार्ट-रेट स्ट्रैप है", + "pairWhoopRowLine": "नींद, रिकवरी, शारीरिक परिश्रम, हृदय गति और बहुत कुछ", + "pairSetUpTitle": "सेट अप", + "capLabelSleep": "नींद", + "capLabelRecovery": "रिकवरी", + "capLabelStrain": "शारीरिक परिश्रम", + "capLabelHrv": "हृदय गति में उतार-चढ़ाव (HRV)", + "capLabelSkinTemperature": "त्वचा का तापमान", + "capLabelBloodOxygen": "रक्त में ऑक्सीजन", + "capLabelWorkoutHeartRate": "वर्कआउट के दौरान हृदय गति", + "capLabelWorkoutBeatToBeat": "वर्कआउट के दौरान धड़कन-दर-धड़कन का समय", + "capLabelSteps": "कदम", + "capReasonSkinTempNights": "कुछ रातों के बाद", + "capReasonEstimated": "अनुमान है, सीधी माप नहीं", + "capReasonEarly": "शुरुआती अनुमान; पहले कुछ हफ़्तों में यह बेहतर होता जाता है", + "capVendorReported": "डिवाइस की अपनी माप", + "slotSendsHeading": "भेजता है", + "slotDoesntSendHeading": "नहीं भेजता", + "pairSectionTitle": "डिवाइस पेयर करें", + "pairCardBandBody": "केवल WHOOP 4.0 या WHOOP 5.0/MG। नींद, रिकवरी और शारीरिक परिश्रम, चौबीसों घंटे।", + "pairUnpairBand": "बैंड अनपेयर करें", + "capLabelHeartRate": "हृदय गति और आराम की हृदय गति", + "capLabelRespiration": "श्वसन", + "capReasonFirstNights": "पहली 14 रातों तक अनुमानित", + "capReasonOwnStagesRing": "रिंग के अपने नींद चरणों से", + "capReasonOwnStages": "डिवाइस के अपने नींद चरणों से", + "capReasonLiveSessions": "लाइव सत्रों के दौरान", + "slotEveryDay": "हर दिन", + "slotWorkoutsOnly": "केवल वर्कआउट", + "pairWearableCardNote": "आपके WHOOP के बिना वाले दिनों को भरता है। प्रायोगिक है, इसलिए इसे नीचे चालू करें।", + "pairWhatItSends": "यह क्या भेजता है", + "capReasonUnconfirmed": "अगर यह डिवाइस इसे भेजता है, पुष्टि नहीं हुई", + "capReasonPebble2Only": "केवल Pebble 2। 2 SE में हृदय गति सेंसर नहीं है।", + "capReasonPebble2OnlyEstimated": "केवल Pebble 2, और यह अनुमान है, सीधी माप नहीं। 2 SE में हृदय गति सेंसर नहीं है।", + "slotColumnReason": "{column}: {reason}", + "@slotColumnReason": { + "placeholders": { + "column": { + "type": "String" + }, + "reason": { + "type": "String" + } + } + }, + "slotCapabilityStatus": "{capability}, {column}: {status}", + "@slotCapabilityStatus": { + "placeholders": { + "capability": { + "type": "String" + }, + "column": { + "type": "String" + }, + "status": { + "type": "String" + } + } + }, "whoopFirmwareWarningTitle": "WHOOP उपयोगकर्ता: WHOOP ऐप से दोबारा कनेक्ट न करें", "whoopFirmwareWarningAction": "अगर आप OpenStrap या कोई दूसरा ओपन-सोर्स ऐप इस्तेमाल करते हैं, या बाद में किसी पर जाने की सोच रहे हैं, तो अपना बैंड आधिकारिक WHOOP ऐप से दोबारा कनेक्ट न करें। वह फ़र्मवेयर अपडेट अपने-आप इंस्टॉल कर सकता है। WHOOP ऐप को अनइंस्टॉल या अक्षम कर दें, ताकि वह आपके बैंड को अपडेट न कर सके।", "whoopFirmwareWarningDetails": "WHOOP 5.0 / MG के फ़र्मवेयर 50.43.1.0 और 50.43.2.0 के बारे में रिपोर्टें बताती हैं कि डेटा तक पहुँच रोक दी जाती है। ब्लूटूथ फिर भी कनेक्ट हो सकता है। प्रभावित बैंड को अनलॉक करने के लिए WHOOP द्वारा साइन किया गया मेंबरशिप टोकन चाहिए, जिसे OpenStrap जारी नहीं कर सकता। हम समाधान पर काम कर रहे हैं, लेकिन अभी कोई उपाय उपलब्ध नहीं है।", - "bandStatusFirmwareLockedTitle": "बैंड का फ़र्मवेयर शायद उसका डेटा रोक रहा है", - "bandStatusFirmwareLockedReason": "यह बैंड WHOOP फ़र्मवेयर 50.43 पर चल रहा है, जो कनेक्ट होकर ऐप को जवाब दे सकता है, लेकिन जब तक बैंड पर WHOOP द्वारा साइन किया गया सदस्यता टोकन न हो, तब तक हो सकता है कि कोई रिकॉर्डिंग या लाइव हृदय गति न भेजे। डेटा न आने का एक संभावित कारण यह हो सकता है। OpenStrap वह टोकन जारी नहीं कर सकता। यहाँ पहले से सहेजा गया सब कुछ सुरक्षित है।", - "bandStatusFirmwareLockedFix": "अगर वजह फ़र्मवेयर है, तो ऐप इसे बदल नहीं सकता और बैंड के फिर से रिकॉर्डिंग भेजते ही यह संदेश हट जाएगा", + "pairSearchDevices": "डिवाइस खोजें", + "pairPrimaryCannotBeSensor": "यह पहले से आपका मुख्य बैंड है। इसे वर्कआउट सेंसर के रूप में भी पेयर नहीं किया जा सकता।", + "capReasonSkinTempProvisional": "अस्थायी अनुमान; कुछ रातों का डेटा चाहिए", "alarmNextLabel": "अगला", "alarmScheduleGroup": "साप्ताहिक शेड्यूल", "alarmWakeTimeRowTitle": "जागने का समय", @@ -3389,37 +3478,11 @@ "stepCalSaveFailed": "वह कैलिब्रेशन सहेजा नहीं जा सका।", "stepCalDoneGait": "सहेजा गया। आपने {count} कदम गिने और बैंड ने {band} कदम देखे। अब से इस तरह की चाल {pct}% से ठीक की जाएगी।", "stepCalDoneHousehold": "सहेजा गया। बैंड द्वारा देखे गए {band} कदमों में से आपके फ़ोन ने {count} कदम गिने। घर के कामों की हलचल अब {gain} के अनुपात में समायोजित होगी।", + "pairReplaceMyBand": "मेरा बैंड बदलें", + "dayStepsWhoop4NoCounter": "WHOOP 4.0 में अपना कोई स्टेप काउंटर नहीं है, इसलिए यह कदम तभी गिनता है जब यह ऐप उसका लाइव डेटा प्राप्त कर रहा हो।", "healthWearNotUpdatedSince": "{time} से अपडेट नहीं हुआ", "dayStrainWornAsOf": "पहना, {time} तक का आंकड़ा", - "dayStepsWhoop4NoCounter": "WHOOP 4.0 में अपना कोई स्टेप काउंटर नहीं है, इसलिए यह कदम तभी गिनता है जब यह ऐप उसका लाइव डेटा प्राप्त कर रहा हो।", - "pairAddDevice": "डिवाइस जोड़ें", - "pairKindAll": "सभी", - "pairKindStrap": "चेस्ट स्ट्रैप और आर्मबैंड", - "pairKindRing": "रिंग", - "pairKindWatch": "घड़ियाँ", - "pairGoBack": "वापस जाएँ", - "pairAddDeviceSub": "रिंग, घड़ियाँ और हार्ट-रेट स्ट्रैप", - "pairAddDeviceSubtitle": "हर डिवाइस दिखाता है कि वह कहाँ फ़िट होता है: हर दिन, या केवल वर्कआउट में।", - "pairBandFoundBody": "यह सिर्फ़ वर्कआउट की तुलना में हर दिन कहीं ज़्यादा करता है। आप क्या चाहते हैं?", - "pairBandFoundBodyHasBand": "आपके पास पहले से एक बैंड है। एक समय में केवल एक ही आपका बैंड हो सकता है।", - "pairIdentifiedBody": "यह हार्ट-रेट स्ट्रैप जैसा दिखा, लेकिन कनेक्ट होने पर इसने खुद को {label} बताया। कुछ भी सहेजा नहीं गया।", - "pairAsMyBand": "इसे मेरे बैंड के रूप में पेयर करें", - "pairSecondaryPaired": "केवल वर्कआउट के लिए पेयर किया गया।", - "pairBandNow": "अभी आपका बैंड: {name}। बदलने पर आपका डेटा बना रहता है।", - "pairReplaceBand": "यह बैंड पेयर करें, फिर {name} को डिस्कनेक्ट करें", - "pairReplaceConfirmTitle": "यह बैंड कनेक्ट होने के बाद {name} को बदलें?", - "pairReplaceConfirmBody": "सेटअप विफल होने या रद्द करने पर आपका मौजूदा बैंड पेयर रहेगा। इस फ़ोन पर पहले से सहेजा गया डेटा बना रहेगा। पुराने बैंड पर जो डेटा अभी सिंक नहीं हुआ है, वह बदलाव के बाद इस फ़ोन पर सिंक नहीं होगा।", - "pairReplaceConfirmYes": "नया बैंड पेयर करें", - "pairCurrentBandFallback": "आपका बैंड", - "pairWearableLead": "यह आपके दिनों को नींद, रिकवरी और हृदय गति से भर सकता है।", - "pairWearableNote": "आपके WHOOP के बिना वाले दिनों को भरता है। प्रायोगिक है, इसलिए इसे डिवाइस में चालू करें।", - "pairStrapLead": "यह वर्कआउट के दौरान हृदय गति जोड़ता है। यह नींद, रिकवरी या दैनिक शारीरिक परिश्रम रिकॉर्ड नहीं करता।", - "pairStrapNote": "दोनों के लिए “वर्कआउट के दौरान इस्तेमाल करें” चालू होना चाहिए।", - "pairDeviceNamed": "{name} पेयर करें", - "pairUseForWorkouts": "इसे केवल वर्कआउट के लिए इस्तेमाल करें", - "pairReplaceUnpairFailed": "आपका नया बैंड पेयर हो गया है, लेकिन पुराना बैंड हटाया नहीं जा सका।", - "pairWearableLeadPebble": "Pebble 2 आपके दिनों को नींद, रिकवरी और हृदय गति से भर सकता है। Pebble 2 SE घड़ी की अपनी नींद और कदमों की रीडिंग दिखाता है। उसमें हृदय गति सेंसर नहीं है, इसलिए यह ऐप उसके डेटा से रोज़ का शारीरिक भार नहीं निकाल सकता और न ही रिकवरी का अनुमान लगा सकता है।", - "pairSearchDevices": "डिवाइस खोजें", - "pairPrimaryCannotBeSensor": "यह पहले से आपका मुख्य बैंड है। इसे वर्कआउट सेंसर के रूप में भी पेयर नहीं किया जा सकता।", - "pairReplaceMyBand": "मेरा बैंड बदलें" + "bandStatusFirmwareLockedTitle": "बैंड का फ़र्मवेयर शायद उसका डेटा रोक रहा है", + "bandStatusFirmwareLockedReason": "यह बैंड WHOOP फ़र्मवेयर 50.43 पर चल रहा है, जो कनेक्ट होकर ऐप को जवाब दे सकता है, लेकिन जब तक बैंड पर WHOOP द्वारा साइन किया गया सदस्यता टोकन न हो, तब तक हो सकता है कि कोई रिकॉर्डिंग या लाइव हृदय गति न भेजे। डेटा न आने का एक संभावित कारण यह हो सकता है। OpenStrap वह टोकन जारी नहीं कर सकता। यहाँ पहले से सहेजा गया सब कुछ सुरक्षित है।", + "bandStatusFirmwareLockedFix": "अगर वजह फ़र्मवेयर है, तो ऐप इसे बदल नहीं सकता और बैंड के फिर से रिकॉर्डिंग भेजते ही यह संदेश हट जाएगा" } diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index 125493439..f3187b858 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -8213,7 +8213,7 @@ "pairWearableLead": "Он может заполнять ваши дни данными о сне, восстановлении и пульсе.", "pairWearableNote": "Заполняет дни без вашего WHOOP. Экспериментально, поэтому включите это в разделе «Устройства».", "pairStrapLead": "Он добавляет пульс во время тренировки. Сон, восстановление и дневную нагрузку он не записывает.", - "pairStrapNote": "Для обоих нужно включить «Использовать во время тренировок».", + "pairStrapNote": "Включите «Использовать во время тренировок», чтобы записывать пульс во время тренировок.", "pairDeviceNamed": "Подключить {name}", "@pairDeviceNamed": { "placeholders": { @@ -8224,9 +8224,72 @@ }, "pairUseForWorkouts": "Использовать только для тренировок", "pairReplaceUnpairFailed": "Новый браслет сопряжён, но старый удалить не удалось.", - "pairWearableLeadPebble": "Pebble 2 может заполнять ваши дни данными о сне, восстановлении и пульсе. Pebble 2 SE показывает сон и шаги по данным самих часов. У него нет датчика пульса, поэтому приложение не может рассчитать дневную нагрузку или оценить восстановление по его данным.", + "pairWearableLeadPebble": "Pebble 2 может заполнять ваши дни данными о сне и пульсе. Pebble 2 SE показывает сон и шаги по данным самих часов. У него нет датчика пульса, поэтому приложение не может рассчитать дневную нагрузку или оценить восстановление по его данным.", + "pairMainBandWhoopOnly": "Основной браслет: только WHOOP 4.0 или WHOOP 5.0/MG. Другие устройства можно добавить как дополнительные.", + "pairBandTitle": "Подключите браслет", + "pairBandSubtitle": "Выберите то, что вы носите. Мы поищем его поблизости.", + "pairStrapOnlyLink": "У меня только пульсовой ремень", + "pairWhoopRowLine": "Сон, восстановление, нагрузка, пульс и многое другое", + "pairSetUpTitle": "Настройка", + "capLabelSleep": "Сон", + "capLabelRecovery": "Восстановление", + "capLabelStrain": "Нагрузка", + "capLabelHrv": "Вариабельность пульса", + "capLabelSkinTemperature": "Температура кожи", + "capLabelBloodOxygen": "Кислород в крови", + "capLabelWorkoutHeartRate": "Пульс во время тренировок", + "capLabelWorkoutBeatToBeat": "Интервалы между ударами во время тренировок", + "capLabelSteps": "Шаги", + "capReasonSkinTempNights": "Через несколько ночей", + "capReasonEstimated": "Оценка, а не прямое измерение", + "capReasonEarly": "Предварительная оценка; за первые недели она становится точнее", + "capVendorReported": "Собственное измерение устройства", + "slotSendsHeading": "Передаёт", + "slotDoesntSendHeading": "Не передаёт", + "pairSectionTitle": "Подключить устройство", + "pairCardBandBody": "Только WHOOP 4.0 или WHOOP 5.0/MG. Сон, восстановление и нагрузка круглые сутки.", + "pairUnpairBand": "Удалить сопряжение с браслетом", + "capLabelHeartRate": "Пульс и пульс в покое", + "capLabelRespiration": "Дыхание", + "capReasonFirstNights": "Первые 14 ночей — оценка", + "capReasonOwnStagesRing": "По фазам сна самого кольца", + "capReasonOwnStages": "По фазам сна самого устройства", + "capReasonLiveSessions": "Во время сеансов в реальном времени", + "slotEveryDay": "Каждый день", + "slotWorkoutsOnly": "Только тренировки", + "pairWearableCardNote": "Заполняет дни без вашего WHOOP. Экспериментально, поэтому включите это ниже.", + "pairWhatItSends": "Что передаёт", + "capReasonUnconfirmed": "Если устройство это передаёт, не подтверждено", + "capReasonPebble2Only": "Только Pebble 2. У 2 SE нет датчика пульса.", + "capReasonPebble2OnlyEstimated": "Только Pebble 2, и это оценка, а не прямое измерение. У 2 SE нет датчика пульса.", + "slotColumnReason": "{column}: {reason}", + "@slotColumnReason": { + "placeholders": { + "column": { + "type": "String" + }, + "reason": { + "type": "String" + } + } + }, + "slotCapabilityStatus": "{capability}, {column}: {status}", + "@slotCapabilityStatus": { + "placeholders": { + "capability": { + "type": "String" + }, + "column": { + "type": "String" + }, + "status": { + "type": "String" + } + } + }, "pairSearchDevices": "Найти устройства", "pairPrimaryCannotBeSensor": "Это уже ваш основной браслет. Его нельзя также подключить как датчик для тренировок.", + "capReasonSkinTempProvisional": "Предварительная оценка; нужны данные за несколько ночей", "pairReplaceMyBand": "Заменить мой браслет", "dayStepsWhoop4NoCounter": "У WHOOP 4.0 нет собственного шагомера, поэтому он считает шаги только пока это приложение получает его данные в реальном времени.", "healthWearNotUpdatedSince": "не обновлялось с {time}", diff --git a/lib/l10n/app_th.arb b/lib/l10n/app_th.arb index a93612e91..d337fad44 100644 --- a/lib/l10n/app_th.arb +++ b/lib/l10n/app_th.arb @@ -16739,7 +16739,7 @@ "@pairStrapLead": { "description": "Sheet lead for a heart-rate strap or sensor." }, - "pairStrapNote": "ทั้งสองอย่างต้องเปิด “ใช้ระหว่างออกกำลังกาย”", + "pairStrapNote": "เปิด “ใช้ระหว่างออกกำลังกาย” เพื่อบันทึกอัตราการเต้นของหัวใจระหว่างออกกำลังกาย", "@pairStrapNote": { "description": "Note under a strap’s table: both workout rows need the switch. Quotes deviceUseWorkoutsTitle." }, @@ -16760,9 +16760,177 @@ "@pairReplaceUnpairFailed": { "description": "Shown when unpairing the old band failed during “Unpair (your band) and pair this one”; nothing else ran." }, - "pairWearableLeadPebble": "Pebble 2 เติมข้อมูลการนอน การฟื้นตัว และอัตราการเต้นของหัวใจให้แต่ละวันได้ Pebble 2 SE แสดงข้อมูลการนอนและจำนวนก้าวที่นาฬิกาบันทึกเอง รุ่นนี้ไม่มีเซ็นเซอร์วัดอัตราการเต้นของหัวใจ แอปจึงคำนวณภาระร่างกายรายวันหรือประเมินการฟื้นตัวจากข้อมูลของรุ่นนี้ไม่ได้", + "pairWearableLeadPebble": "Pebble 2 เติมข้อมูลการนอนและอัตราการเต้นของหัวใจให้แต่ละวันได้ Pebble 2 SE แสดงข้อมูลการนอนและจำนวนก้าวที่นาฬิกาบันทึกเอง รุ่นนี้ไม่มีเซ็นเซอร์วัดอัตราการเต้นของหัวใจ แอปจึงคำนวณภาระร่างกายรายวันหรือประเมินการฟื้นตัวจากข้อมูลของรุ่นนี้ไม่ได้", + "pairMainBandWhoopOnly": "สายรัดหลัก: WHOOP 4.0 หรือ WHOOP 5.0/MG เท่านั้น อุปกรณ์อื่นเพิ่มเป็นอุปกรณ์เสริมได้", + "@pairMainBandWhoopOnly": { + "description": "Plain statement on the pairing screens: only WHOOP can be the main band; other devices are added as additional devices." + }, + "pairBandTitle": "จับคู่สายรัดของคุณ", + "@pairBandTitle": { + "description": "Title of the first-run list of bands." + }, + "pairBandSubtitle": "เลือกอันที่คุณสวมอยู่ เราจะค้นหาในบริเวณใกล้เคียง", + "@pairBandSubtitle": { + "description": "Subtitle of the first-run list of bands." + }, + "pairStrapOnlyLink": "ฉันมีแค่สายคาดวัดหัวใจ", + "@pairStrapOnlyLink": { + "description": "Text link under the band list for someone with only a heart-rate strap." + }, + "pairWhoopRowLine": "การนอน การฟื้นตัว ความหนัก อัตราการเต้นของหัวใจ และอื่นๆ", + "@pairWhoopRowLine": { + "description": "Line under each WHOOP on the first-run list." + }, + "pairSetUpTitle": "ตั้งค่า", + "@pairSetUpTitle": { + "description": "Top bar title of the first-run pairing screen." + }, + "capLabelSleep": "การนอน", + "@capLabelSleep": { + "description": "Name of a thing a device sends: sleep." + }, + "capLabelRecovery": "การฟื้นตัว", + "@capLabelRecovery": { + "description": "Name of a thing a device sends: the morning recovery score." + }, + "capLabelStrain": "ความหนัก", + "@capLabelStrain": { + "description": "Name of a thing a device sends: strain." + }, + "capLabelHrv": "ความแปรปรวนของอัตราการเต้นหัวใจ", + "@capLabelHrv": { + "description": "Name of a thing a device sends: heart-rate variability." + }, + "capLabelSkinTemperature": "อุณหภูมิผิว", + "@capLabelSkinTemperature": { + "description": "Name of a thing a device sends: skin temperature." + }, + "capLabelBloodOxygen": "ออกซิเจนในเลือด", + "@capLabelBloodOxygen": { + "description": "Name of a thing a device sends: blood oxygen (only a device’s own reading)." + }, + "capLabelWorkoutHeartRate": "อัตราการเต้นหัวใจขณะออกกำลังกาย", + "@capLabelWorkoutHeartRate": { + "description": "Table row: heart rate during a workout." + }, + "capLabelWorkoutBeatToBeat": "ช่วงเวลาระหว่างจังหวะหัวใจขณะออกกำลังกาย", + "@capLabelWorkoutBeatToBeat": { + "description": "Table row: beat-to-beat timing during a workout." + }, + "capLabelSteps": "ก้าว", + "@capLabelSteps": { + "description": "Name of a thing a device sends: steps." + }, + "capReasonSkinTempNights": "หลังจากผ่านไปสองสามคืน", + "@capReasonSkinTempNights": { + "description": "Caption under Skin temperature: it needs a few nights first." + }, + "capReasonEstimated": "เป็นค่าประมาณ ไม่ใช่ค่าที่วัดได้โดยตรง", + "@capReasonEstimated": { + "description": "Why a value is conditional: it is an estimate, not a direct reading." + }, + "capReasonEarly": "ค่าประมาณช่วงแรก จะแม่นยำขึ้นในช่วงสัปดาห์แรกๆ", + "@capReasonEarly": { + "description": "Why a value is conditional: it is an early estimate that firms up over the first weeks." + }, + "capVendorReported": "ค่าที่อุปกรณ์วัดเอง", + "@capVendorReported": { + "description": "Tag on a value that is the device’s own reading, not calculated by this app." + }, + "slotSendsHeading": "ส่ง", + "@slotSendsHeading": { + "description": "Heading above the list of what a device sends." + }, + "slotDoesntSendHeading": "ไม่ส่ง", + "@slotDoesntSendHeading": { + "description": "Heading above the list of what a secondary sensor does not send." + }, + "pairSectionTitle": "จับคู่อุปกรณ์", + "@pairSectionTitle": { + "description": "Heading of the section in My sources that holds pairing." + }, + "pairCardBandBody": "เฉพาะ WHOOP 4.0 หรือ WHOOP 5.0/MG การนอน การฟื้นตัว และความหนัก ตลอดวัน", + "@pairCardBandBody": { + "description": "Body of the Your band card in Settings." + }, + "pairUnpairBand": "ยกเลิกการจับคู่สายรัด", + "@pairUnpairBand": { + "description": "Red outline button that starts forgetting the paired band (a confirm dialog follows)." + }, + "capLabelHeartRate": "อัตราการเต้นของหัวใจและขณะพัก", + "@capLabelHeartRate": { + "description": "Table row: heart rate and resting heart rate, as one capability." + }, + "capLabelRespiration": "การหายใจ", + "@capLabelRespiration": { + "description": "Table row: breathing rate." + }, + "capReasonFirstNights": "เป็นค่าประมาณใน 14 คืนแรก", + "@capReasonFirstNights": { + "description": "Caption under Recovery for a ring or watch: its recovery is an estimate until 14 nights of baseline." + }, + "capReasonOwnStagesRing": "จากระยะการนอนที่แหวนบันทึกเอง", + "@capReasonOwnStagesRing": { + "description": "Caption under Sleep for a ring: the sleep stages are the ring’s own." + }, + "capReasonOwnStages": "จากระยะการนอนที่อุปกรณ์บันทึกเอง", + "@capReasonOwnStages": { + "description": "Caption under Sleep for a watch or fitness band: the sleep stages are the device’s own." + }, + "capReasonLiveSessions": "ระหว่างเซสชันสด", + "@capReasonLiveSessions": { + "description": "Caption under Steps for WHOOP 4: it counts steps only while the app has a live connection." + }, + "slotEveryDay": "ทุกวัน", + "@slotEveryDay": { + "description": "Column and chip: the device is used every day (the main band, or the ring/watch that fills days)." + }, + "slotWorkoutsOnly": "เฉพาะตอนออกกำลังกาย", + "@slotWorkoutsOnly": { + "description": "Column and chip: the device is used only during workouts." + }, + "pairWearableCardNote": "เติมวันที่ไม่มี WHOOP ของคุณ ยังเป็นฟีเจอร์ทดลอง จึงต้องเปิดเองด้านล่าง", + "@pairWearableCardNote": { + "description": "Note under a ring’s or watch’s table on its device page; the switch is below it." + }, + "pairWhatItSends": "สิ่งที่ส่งมา", + "@pairWhatItSends": { + "description": "Heading above the table on a device page." + }, + "capReasonUnconfirmed": "หากอุปกรณ์นี้ส่งข้อมูลนี้ ยังไม่ได้ยืนยัน", + "@capReasonUnconfirmed": { + "description": "Caption under a row the device may or may not send; nobody has confirmed it does." + }, + "capReasonPebble2Only": "เฉพาะ Pebble 2 รุ่น 2 SE ไม่มีเซ็นเซอร์วัดอัตราการเต้นของหัวใจ", + "capReasonPebble2OnlyEstimated": "เฉพาะ Pebble 2 และเป็นค่าประมาณ ไม่ใช่ค่าที่วัดได้โดยตรง รุ่น 2 SE ไม่มีเซ็นเซอร์วัดอัตราการเต้นของหัวใจ", + "slotColumnReason": "{column}: {reason}", + "@slotColumnReason": { + "placeholders": { + "column": { + "type": "String" + }, + "reason": { + "type": "String" + } + } + }, + "slotCapabilityStatus": "{capability}, {column}: {status}", + "@slotCapabilityStatus": { + "placeholders": { + "capability": { + "type": "String" + }, + "column": { + "type": "String" + }, + "status": { + "type": "String" + } + } + }, "pairSearchDevices": "ค้นหาอุปกรณ์", "pairPrimaryCannotBeSensor": "นี่คือสายรัดหลักของคุณอยู่แล้ว จึงไม่สามารถจับคู่เป็นเซ็นเซอร์ออกกำลังกายด้วยได้", + "capReasonSkinTempProvisional": "ค่าประมาณที่ยังเป็นข้อมูลเบื้องต้น ต้องมีข้อมูลหลายคืน", "pairReplaceMyBand": "เปลี่ยนสายรัดของฉัน", "dayStepsWhoop4NoCounter": "WHOOP 4.0 ไม่มีตัวนับก้าวในตัว จึงนับก้าวได้เฉพาะตอนที่แอปนี้กำลังรับข้อมูลสดจากสายรัดเท่านั้น", "healthWearNotUpdatedSince": "ไม่ได้อัปเดตตั้งแต่ {time}", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 0b589bf08..67b0adec0 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -3034,12 +3034,99 @@ "pairModeTitle": "让它进入配对模式", "pairModeNoSite": "这是没有单一厂商的通用设备,因此没有厂商步骤可循。", "pairOuraExistingKeyGuidance": "已经在用 Oura 应用?请保留戒指在该应用中的配对,并使用戒指现有的密钥配对。跳过下面的重置步骤。只有想使用新密钥时才重置戒指。", + "pairAddDevice": "添加设备", + "pairKindAll": "全部", + "pairKindStrap": "胸带和臂带", + "pairKindRing": "戒指", + "pairKindWatch": "手表", + "pairGoBack": "返回", + "pairAddDeviceSub": "戒指、手表和心率带", + "pairAddDeviceSubtitle": "每个设备都会标明适合的用法:每天,或仅运动时。", + "pairBandFoundBody": "每天佩戴比仅在运动时使用能提供多得多的数据。你想怎么用?", + "pairBandFoundBodyHasBand": "你已经有一个手环。同一时间只能有一个作为你的手环。", + "pairIdentifiedBody": "它看起来像心率带,但连接后它表明自己是 {label}。没有保存任何内容。", + "pairAsMyBand": "配对为我的手环", + "pairSecondaryPaired": "已配对,仅在运动时使用。", + "pairBandNow": "当前手环:{name}。更换后你的数据仍会保留。", + "pairReplaceBand": "先配对此手环,再断开 {name}", + "pairReplaceConfirmTitle": "此手环连接成功后替换 {name}?", + "pairReplaceConfirmBody": "如果设置失败或取消,当前手环仍保持配对。已保存在这部手机上的数据会保留。旧手环上尚未同步的数据,在更换后不会再同步到这部手机。", + "pairReplaceConfirmYes": "配对新手环", + "pairCurrentBandFallback": "你的手环", + "pairWearableLead": "它可以为你的每一天补上睡眠、恢复和心率。", + "pairWearableNote": "填补没有 WHOOP 数据的日子。这是实验功能,请在“设备”中开启。", + "pairStrapLead": "它在你运动时提供心率,不记录睡眠、恢复或每日负荷。", + "pairStrapNote": "开启“在锻炼时使用”,即可在锻炼时记录心率。", + "pairDeviceNamed": "配对 {name}", + "pairUseForWorkouts": "仅在运动时使用", + "pairReplaceUnpairFailed": "新手环已配对,但无法移除旧手环。", + "pairWearableLeadPebble": "Pebble 2 可以为你的每一天补上睡眠和心率。Pebble 2 SE 显示手表自身记录的睡眠和步数。它没有心率传感器,因此本应用无法根据它的数据计算每日身体负荷或估算恢复。", + "pairMainBandWhoopOnly": "主手环:仅支持 WHOOP 4.0 或 WHOOP 5.0/MG。其他设备可作为附加设备添加。", + "pairBandTitle": "配对你的手环", + "pairBandSubtitle": "选择你佩戴的那一个,我们会在附近寻找它。", + "pairStrapOnlyLink": "我只有心率带", + "pairWhoopRowLine": "睡眠、恢复、负荷、心率等", + "pairSetUpTitle": "设置", + "capLabelSleep": "睡眠", + "capLabelRecovery": "恢复", + "capLabelStrain": "负荷", + "capLabelHrv": "心率变异性", + "capLabelSkinTemperature": "皮肤温度", + "capLabelBloodOxygen": "血氧", + "capLabelWorkoutHeartRate": "锻炼时的心率", + "capLabelWorkoutBeatToBeat": "锻炼时的逐次心跳间隔", + "capLabelSteps": "步数", + "capReasonSkinTempNights": "几晚之后", + "capReasonEstimated": "估算值,不是直接测量", + "capReasonEarly": "初步估算,前几周会越来越准", + "capVendorReported": "设备自己的读数", + "slotSendsHeading": "提供", + "slotDoesntSendHeading": "不提供", + "pairSectionTitle": "配对设备", + "pairCardBandBody": "仅限 WHOOP 4.0 或 WHOOP 5.0/MG。全天候记录睡眠、恢复和负荷。", + "pairUnpairBand": "取消配对手环", + "capLabelHeartRate": "心率和静息心率", + "capLabelRespiration": "呼吸", + "capReasonFirstNights": "前 14 晚为估算值", + "capReasonOwnStagesRing": "来自戒指自身的睡眠分期", + "capReasonOwnStages": "来自设备自身的睡眠分期", + "capReasonLiveSessions": "仅在实时连接期间", + "slotEveryDay": "每天", + "slotWorkoutsOnly": "仅运动时", + "pairWearableCardNote": "填补没有 WHOOP 数据的日子。这是实验功能,请在下方开启。", + "pairWhatItSends": "它提供的数据", + "capReasonUnconfirmed": "如果此设备发送该数据,尚未确认", + "capReasonPebble2Only": "仅限 Pebble 2。2 SE 没有心率传感器。", + "capReasonPebble2OnlyEstimated": "仅限 Pebble 2,且是估算值,不是直接测量。2 SE 没有心率传感器。", + "slotColumnReason": "{column}:{reason}", + "@slotColumnReason": { + "placeholders": { + "column": { + "type": "String" + }, + "reason": { + "type": "String" + } + } + }, + "slotCapabilityStatus": "{capability},{column}:{status}", + "@slotCapabilityStatus": { + "placeholders": { + "capability": { + "type": "String" + }, + "column": { + "type": "String" + }, + "status": { + "type": "String" + } + } + }, "whoopFirmwareWarningTitle": "WHOOP 用户:请勿重新连接 WHOOP 应用", "whoopFirmwareWarningAction": "如果你在使用 OpenStrap 或其他开源应用,或打算以后改用,请不要再把手环连接到 WHOOP 官方应用。它可能会自动安装固件更新。请卸载或停用 WHOOP 应用,以免它更新你的手环。", "whoopFirmwareWarningDetails": "有报告称,WHOOP 5.0 / MG 固件 50.43.1.0 和 50.43.2.0 会阻止访问数据。蓝牙可能仍能连接。解锁受影响的手环需要由 WHOOP 签名的会员令牌,OpenStrap 无法签发。我们正在寻找解决办法,但目前还没有可用的修复。", - "bandStatusFirmwareLockedTitle": "手环固件可能正在扣留它的数据", - "bandStatusFirmwareLockedReason": "这个手环运行的是 WHOOP 固件 50.43:它可以连接并响应应用,但在手环上没有 WHOOP 签名的会员令牌之前,可能不会发送任何记录或实时心率。这可能是收不到数据的原因之一。OpenStrap 无法签发这个令牌。已保存在这里的所有数据都是安全的。", - "bandStatusFirmwareLockedFix": "如果是固件的原因,应用无法更改,手环重新发送记录后此提示会自动消失", + "pairSearchDevices": "搜索设备", "alarmNextLabel": "下一次", "alarmScheduleGroup": "每周计划", "alarmWakeTimeRowTitle": "起床时间", @@ -3389,37 +3476,13 @@ "stepCalSaveFailed": "无法保存此次校准。", "stepCalDoneGait": "已保存。你数了 {count} 步,腕带记录了 {band} 步。今后这类走路将按 {pct}% 进行校正。", "stepCalDoneHousehold": "已保存。在腕带记录的 {band} 步中,你的手机记录了 {count} 步。居家活动现在将按 {gain} 进行缩放。", + "pairPrimaryCannotBeSensor": "这已经是你的主手环,不能同时配对为运动传感器。", + "capReasonSkinTempProvisional": "暂定估算;需要几晚的数据", + "pairReplaceMyBand": "更换我的手环", + "dayStepsWhoop4NoCounter": "WHOOP 4.0 没有自带计步器,因此只有在本应用接收其实时数据时才会计步。", "healthWearNotUpdatedSince": "自 {time} 起未更新", "dayStrainWornAsOf": "佩戴(截至 {time} 的数据)", - "dayStepsWhoop4NoCounter": "WHOOP 4.0 没有自带计步器,因此只有在本应用接收其实时数据时才会计步。", - "pairAddDevice": "添加设备", - "pairKindAll": "全部", - "pairKindStrap": "胸带和臂带", - "pairKindRing": "戒指", - "pairKindWatch": "手表", - "pairGoBack": "返回", - "pairAddDeviceSub": "戒指、手表和心率带", - "pairAddDeviceSubtitle": "每个设备都会标明适合的用法:每天,或仅运动时。", - "pairBandFoundBody": "每天佩戴比仅在运动时使用能提供多得多的数据。你想怎么用?", - "pairBandFoundBodyHasBand": "你已经有一个手环。同一时间只能有一个作为你的手环。", - "pairIdentifiedBody": "它看起来像心率带,但连接后它表明自己是 {label}。没有保存任何内容。", - "pairAsMyBand": "配对为我的手环", - "pairSecondaryPaired": "已配对,仅在运动时使用。", - "pairBandNow": "当前手环:{name}。更换后你的数据仍会保留。", - "pairReplaceBand": "先配对此手环,再断开 {name}", - "pairReplaceConfirmTitle": "此手环连接成功后替换 {name}?", - "pairReplaceConfirmBody": "如果设置失败或取消,当前手环仍保持配对。已保存在这部手机上的数据会保留。旧手环上尚未同步的数据,在更换后不会再同步到这部手机。", - "pairReplaceConfirmYes": "配对新手环", - "pairCurrentBandFallback": "你的手环", - "pairWearableLead": "它可以为你的每一天补上睡眠、恢复和心率。", - "pairWearableNote": "填补没有 WHOOP 数据的日子。这是实验功能,请在“设备”中开启。", - "pairStrapLead": "它在你运动时提供心率,不记录睡眠、恢复或每日负荷。", - "pairStrapNote": "两项都需要开启“在锻炼时使用”。", - "pairDeviceNamed": "配对 {name}", - "pairUseForWorkouts": "仅在运动时使用", - "pairReplaceUnpairFailed": "新手环已配对,但无法移除旧手环。", - "pairWearableLeadPebble": "Pebble 2 可以为你的每一天补上睡眠、恢复和心率。Pebble 2 SE 显示手表自身记录的睡眠和步数。它没有心率传感器,因此本应用无法根据它的数据计算每日身体负荷或估算恢复。", - "pairSearchDevices": "搜索设备", - "pairPrimaryCannotBeSensor": "这已经是你的主手环,不能同时配对为运动传感器。", - "pairReplaceMyBand": "更换我的手环" + "bandStatusFirmwareLockedTitle": "手环固件可能正在扣留它的数据", + "bandStatusFirmwareLockedReason": "这个手环运行的是 WHOOP 固件 50.43:它可以连接并响应应用,但在手环上没有 WHOOP 签名的会员令牌之前,可能不会发送任何记录或实时心率。这可能是收不到数据的原因之一。OpenStrap 无法签发这个令牌。已保存在这里的所有数据都是安全的。", + "bandStatusFirmwareLockedFix": "如果是固件的原因,应用无法更改,手环重新发送记录后此提示会自动消失" } diff --git a/lib/state/alarm_schedule.dart b/lib/state/alarm_schedule.dart index ca8c6050a..8711497c6 100644 --- a/lib/state/alarm_schedule.dart +++ b/lib/state/alarm_schedule.dart @@ -33,6 +33,37 @@ Future bindAlarmEpochToBand(SharedPreferences prefs, String remoteId) asyn return prefs.setString(kAlarmRemoteId, remoteId); } +/// Persist the armed [epoch] under its owner, in an order that never leaves a +/// window where the epoch reads as another band's arm: a previous owner's +/// epoch is removed first, then the owner is written, then the new epoch. +/// Every write is checked; on a failure this throws and no new epoch is saved. +/// Both the foreground and the headless writer use it. +/// +/// [stillCurrent] answers "has a newer arm or a clear superseded this one?". +/// It is asked before anything is written and again, synchronously, right +/// before the epoch write: the removes/writes above await, and a clear or a +/// newer arm that ran in those gaps must not have its result overwritten by +/// this older epoch. Returns false when superseded (nothing more is written). +Future saveArmedAlarmEpoch( + SharedPreferences prefs, int epoch, String? remoteId, + {bool Function()? stillCurrent}) async { + if (stillCurrent != null && !stillCurrent()) return false; + if (remoteId != null && prefs.getString(kAlarmRemoteId) != remoteId) { + if (prefs.getInt('alarm_epoch') != null && + !await prefs.remove('alarm_epoch')) { + throw StateError('Could not clear the previous alarm.'); + } + if (!await prefs.setString(kAlarmRemoteId, remoteId)) { + throw StateError('Could not record which band holds the alarm.'); + } + } + if (stillCurrent != null && !stillCurrent()) return false; + if (!await prefs.setInt('alarm_epoch', epoch)) { + throw StateError('Could not save the armed alarm.'); + } + return true; +} + /// One weekday's slot in the schedule. Immutable — callers build a new one to /// change a field. class AlarmScheduleEntry { diff --git a/lib/state/app_state.dart b/lib/state/app_state.dart index f7664e09a..d97c580c7 100644 --- a/lib/state/app_state.dart +++ b/lib/state/app_state.dart @@ -4201,8 +4201,13 @@ class AppState extends ChangeNotifier { static const String _kLiveSessionCheckpoint = 'live_session_checkpoint'; Future _checkpointLiveSession() async { - final resetGeneration = ResetGate.generation; if (_gaitRuns.isEmpty) return; + // The runs were collected under THEIR generation, not the one current now: + // a reset that began or finished since must not have its deleted steps + // written back (and recovered after the next connect). Refused up front + // and again after the reads below. + final resetGeneration = _gaitRunsGeneration ?? ResetGate.generation; + if (ResetGate.changedSince(resetGeneration)) return; try { final prefs = await SharedPreferences.getInstance(); final calibration = await _liveStepCalibrationRuns(); @@ -4904,6 +4909,17 @@ class AppState extends ChangeNotifier { var committed = false; var started = false; try { + // The primary peripheral must never also hold a secondary connection. A + // candidate that is already a workout sensor here would be saved as the + // primary with its secondary row and link still alive, and the sensor + // link would reconnect the same peripheral. Refuse before anything starts. + if (replacing && + (await LocalDb.deviceRows()).any((r) => + r['remote_id'] == remoteId && + r['id'] != LocalDb.kPrimaryDeviceId)) { + throw Exception( + 'That device is already paired as a sensor. Forget it there first.'); + } final confirmed = await _sync.connectForPairing( PairedDevice(remoteId, serial), replacingRemoteId: replacing ? existing?.remoteId : null, @@ -5318,6 +5334,10 @@ class AppState extends ChangeNotifier { } notifyListeners(); } + // The band that receives this SET. unpair()/replacement can finish while + // the write waits for its reply; the result then belongs to a band that + // is no longer the paired one (see [_onArmed]). + final armedFor = paired?.remoteId; final result = await armNextScheduledOccurrence( engine: engine, schedule: _schedule, @@ -5335,7 +5355,7 @@ class AppState extends ChangeNotifier { final epoch = result.epoch; if (epoch == null) return true; await _onArmed(DateTime.fromMillisecondsSinceEpoch(epoch * 1000), epoch, - echoed: result.echoed); + echoed: result.echoed, armedFor: armedFor); return true; } catch (e) { _log('[alarm] weekly-schedule arm failed: $e'); @@ -5463,6 +5483,7 @@ class AppState extends ChangeNotifier { // rich 20-byte firing form (a hardcoded 0 subsec would still fire, but the // engine owns the exact on-wire layout). Persist the wall instant the // engine reports armed (null = write never reached the band). + final armedFor = paired?.remoteId; final (:armed, :echoed) = await engine.armAlarm(when); if (armed == null) { // Do NOT persist or start the confirmation machine, or we'd strand a @@ -5476,7 +5497,7 @@ class AppState extends ChangeNotifier { throw Exception('Alarm not set'); } await _onArmed(armed, armed.millisecondsSinceEpoch ~/ 1000, - echoed: echoed); + echoed: echoed, armedFor: armedFor); } /// Shared bookkeeping for anything that just armed the band: optimistic @@ -5487,7 +5508,19 @@ class AppState extends ChangeNotifier { /// /// [echoed]: the strap's reply already reported this exact wake time, so the /// arm is confirmed now; event 56 stays as later corroboration. - Future _onArmed(DateTime when, int epoch, {bool echoed = false}) async { + /// + /// [armedFor] is the band that received the SET, captured BEFORE the write. + /// If it is no longer the paired band (a forget or replacement finished while + /// the reply was pending), this arm is dropped: persisting it would save an + /// ownerless epoch that any later band reads as its own and is then never + /// armed. + Future _onArmed(DateTime when, int epoch, + {bool echoed = false, required String? armedFor}) async { + if (armedFor != paired?.remoteId) { + _log('[alarm] the band that took this alarm is no longer paired; ' + 'not recording it.'); + return; + } final gen = ++_armGen; _savedAlarm = epoch; device.alarmEpoch = epoch; // optimistic display @@ -5499,8 +5532,11 @@ class AppState extends ChangeNotifier { final prefs = await SharedPreferences.getInstance(); // A newer arm (or a clear) during the await owns what is persisted now. if (_disposed || _armGen != gen) return; - if (!await prefs.setInt('alarm_epoch', epoch)) { - throw StateError('Could not save the armed alarm.'); + // Asked again right before the epoch write: the helper awaits, and a clear + // or newer arm in those gaps must not be overwritten by this older epoch. + if (!await saveArmedAlarmEpoch(prefs, epoch, armedFor, + stillCurrent: () => !_disposed && _armGen == gen)) { + return; } if (_disposed || _armGen != gen) return; await prefs.setInt('alarm_set_at_ms', setAtMs); @@ -5508,13 +5544,6 @@ class AppState extends ChangeNotifier { // Not confirmed yet — event 56 (below, in _handleAlarmEvent) flips this. await prefs.setBool('alarm_epoch_confirmed', echoed); if (_disposed || _armGen != gen) return; - final remoteId = paired?.remoteId; - // After a replacement the key can still name the OLD band: an unchecked - // failed write would report success with the new epoch under the old owner. - if (remoteId != null && !await prefs.setString(kAlarmRemoteId, remoteId)) { - throw StateError('Could not record which band holds the alarm.'); - } - if (_disposed || _armGen != gen) return; if (echoed) { await _finishEchoConfirmed(prefs, gen); return; diff --git a/lib/state/sync_controller.dart b/lib/state/sync_controller.dart index cb435d28d..430316d67 100644 --- a/lib/state/sync_controller.dart +++ b/lib/state/sync_controller.dart @@ -571,7 +571,17 @@ class SyncController { if (superseded != null) { try { await superseded.timeout(const Duration(seconds: 15)); - } catch (_) {} + } on TimeoutException { + // A timeout is NOT "the burst stopped": a slow commit can keep it + // alive, and it would resume on the candidate's session (its + // isConnected check passes) and request history from the wrong + // band. Stop here; the caller keeps the old pairing and recovers. + _log('Pairing: the previous sync burst is still running; ' + 'not connecting the candidate under it.'); + return false; + } catch (_) { + // The burst failed: it is over either way. + } } if (!current()) return false; } diff --git a/lib/sync/background_sync.dart b/lib/sync/background_sync.dart index 230768eb6..560949fdf 100644 --- a/lib/sync/background_sync.dart +++ b/lib/sync/background_sync.dart @@ -97,12 +97,9 @@ Future headlessArmAndConfirm(Future Function() arm, // The strap's own reply already named this wake time: no wait needed. final confirmed = result.echoed || await awaitAlarmLatch(() => latchedSince(armedAtMs)); - if (!await prefs.setInt('alarm_epoch', result.epoch!)) { - throw StateError('Could not save the armed alarm.'); - } + await saveArmedAlarmEpoch(prefs, result.epoch!, remoteId); await prefs.setInt('alarm_set_at_ms', armedAtMs); await prefs.setBool('alarm_epoch_confirmed', confirmed); - if (remoteId != null) await prefs.setString(kAlarmRemoteId, remoteId); } } diff --git a/lib/ui2/pairing/category_filter_pills.dart b/lib/ui2/pairing/category_filter_pills.dart index eaff7a790..5b629e48f 100644 --- a/lib/ui2/pairing/category_filter_pills.dart +++ b/lib/ui2/pairing/category_filter_pills.dart @@ -1,4 +1,4 @@ -// K3: filter pills over a device list ("All · WHOOP · Rings · Watches · +// filter pills over a device list ("All · WHOOP · Rings · Watches · // Straps"). One widget, one file, so the list grouping can be swapped for // another style (accordions, plain headers) without touching a screen. import 'package:flutter/material.dart'; diff --git a/lib/ui2/pairing/device_picker.dart b/lib/ui2/pairing/device_picker.dart index 03c928d00..71bd2d8d0 100644 --- a/lib/ui2/pairing/device_picker.dart +++ b/lib/ui2/pairing/device_picker.dart @@ -54,11 +54,13 @@ import '../../state/app_state.dart'; import '../onboarding/pairing.dart' show PairingScreen; import '../ui2.dart'; import 'add_device_flow.dart'; +import 'pair_band_view.dart'; import 'category_filter_pills.dart'; import 'pair_dispatch.dart'; import 'pair_text.dart' - show PairFilter, pairFilterOf; + show PairFilter, pairFilterOf, pairL10n, slotPill; import 'whoop_firmware_warning.dart'; +import '../../ble/slot_comparison.dart' show slotComparisonFor; import '../profile/devices.dart' show kPairableSensors, @@ -68,6 +70,21 @@ import '../profile/devices.dart' import '../profile/pair_sensor.dart' show PairSensorScreen; import '../profile/profile.dart' show SetRow; +/// Refreshes the sensor list once a pairing has been SAVED. The pairing is +/// already durable here, so a failing refresh must not surface as "could not +/// pair" (the caller's catch would say exactly that). The list reloads on its +/// next load. Returns whether the refresh worked. +@visibleForTesting +Future refreshAfterPair(Future Function() refresh) async { + try { + await refresh(); + return true; + } catch (e) { + debugPrint('[pair] sensor list refresh failed after a saved pairing: $e'); + return false; + } +} + class DevicePickerScreen extends StatefulWidget { /// Walk past pairing entirely. Non-null only at true first-run onboarding /// — a re-pair or add-a-sensor push always has a screen underneath to pop @@ -100,7 +117,7 @@ class DevicePickerScreen extends StatefulWidget { } class _DevicePickerScreenState extends State - implements AddDeviceIo { + implements AddDeviceIo, PairBandHost { final _query = TextEditingController(); String _q = ''; @@ -284,8 +301,10 @@ class _DevicePickerScreenState extends State } } + @override void pickBand(BandEntry entry) => unawaited(_browseEntry(entry, modelKnown: true)); + @override void strapOnlyConfirmed() => unawaited(_browseEntry(kBleHrs, confirmed: true)); /// The pairing operation itself, for [AddDeviceFlow]. @@ -401,7 +420,7 @@ class _DevicePickerScreenState extends State Future _afterPair() async { // Neither sub-flow tells AppState a `device` row changed underneath it. - if (mounted) await context.read().refreshSensors(); + if (mounted) await refreshAfterPair(context.read().refreshSensors); // A framed pair changes `AppState.isPaired`, which nothing here watches // directly — the pushed `PairingScreen` closes itself on success, and the // gate (or `RePair`) reacts to the flag underneath. @@ -416,7 +435,13 @@ class _DevicePickerScreenState extends State @override Widget build(BuildContext c) { final l = AppLocalizations.of(c); - final entries = [if (widget.includeBand) kWhoopGen4, ..._notifyEntries]; + if (widget.includeBand) { + return PairBandView( + entries: firstRunBandEntries(), host: this, onSkip: widget.onSkip, + onBack: widget.onBack, problem: _problem, + ); + } + final entries = _notifyEntries; return DevicePickerView( query: _query, title: l?.pairAddDevice ?? 'Add a device', @@ -484,7 +509,7 @@ class DevicePickerView extends StatelessWidget { final VoidCallback? onSkip; final VoidCallback? onBack; - /// The filter pills over the results (K3): the chosen kind (null = All) and + /// The filter pills over the results: the chosen kind (null = All) and /// its setter. Null [kindSelection] draws no pills. The owner listens and /// rebuilds this view when it changes. final ValueNotifier? kindSelection; @@ -642,6 +667,7 @@ class DevicePickerView extends StatelessWidget { ? null : () => onOpenEntry?.call(categories[i].entry), ), + ?_slotChip(c, categories[i].entry), if (i < categories.length - 1) Divider(color: p.line, height: 1), ], @@ -811,13 +837,30 @@ class _NearbySection extends StatelessWidget { chevron: !busy, onTap: busy || onTap == null ? null : () => onTap!(cand), ); - return row; + final entry = cand.alsoBand?.entry ?? + kBandRegistry.where((e) => e.id == cand.entryId).firstOrNull; + final chip = entry == null ? null : _slotChip(c, entry); + if (chip == null) return row; + return Column(children: [row, chip]); } } /// The "Every day" / "Workouts only" chip under a device row, or null when /// the device fits neither column. +Widget? _slotChip(BuildContext c, BandEntry e) { + final slot = slotComparisonFor(e).slot; + if (slot == null) return null; + return Align( + key: ValueKey('row-slot-${e.id}'), + alignment: AlignmentDirectional.centerStart, + child: Padding( + padding: const EdgeInsets.only(bottom: S.x3), + child: slotPill(pairL10n(c), slot), + ), + ); +} + /// The one-line description under each device in the picker, localised. String deviceCategoryBlurb(AppLocalizations? l, BandEntry e) { return localizedText(l, switch (e.id) { diff --git a/lib/ui2/pairing/device_slot_card.dart b/lib/ui2/pairing/device_slot_card.dart new file mode 100644 index 000000000..5c246ec6c --- /dev/null +++ b/lib/ui2/pairing/device_slot_card.dart @@ -0,0 +1,59 @@ +// a paired device's own card, said plainly: where it fits ("Every day" or +// "Workouts only"), and THE table the pairing sheets show, with the column it +// is not in faded. The note says which switch it waits for; the switch itself +// sits right under the card (DeviceUseSwitch). +import 'package:flutter/material.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; + +import '../../ble/adapters/_registry.dart'; +import '../../ble/slot_comparison.dart'; +import '../ui2.dart'; +import 'pair_text.dart'; +import 'pair_widgets.dart'; +import 'slot_comparison_view.dart'; + +/// The column [e] goes into when it is paired beside (or instead of) the +/// band: a ring or a watch fills every day, a workout sensor workouts only. +/// Null for a WHOOP (its own page), a Coros watch or a scale. +DeviceSlot? pairedDeviceSlot(BandEntry e) => + e.canBeMainDevice ? null : slotComparisonFor(e).slot; + +class DeviceSlotCard extends StatelessWidget { + final BandEntry entry; + final DeviceSlot slot; + + const DeviceSlotCard({super.key, required this.entry, required this.slot}); + + @override + Widget build(BuildContext c) { + final p = P.of(c); + final l = pairL10n(c); + final other = slot == DeviceSlot.everyDay + ? DeviceSlot.workoutsOnly + : DeviceSlot.everyDay; + return Column( + key: const ValueKey('device-slot-card'), + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + // A Wrap, not a Row: at 2x text the chip drops under the heading + // instead of overflowing beside it. + Wrap( + alignment: WrapAlignment.spaceBetween, + crossAxisAlignment: WrapCrossAlignment.center, + spacing: S.x2, + runSpacing: S.x2, + children: [ + Text(l.pairWhatItSends, style: F.head.copyWith(color: p.ink)), + slotPill(l, slot, key: const ValueKey('device-slot-pill')), + ], + ), + const SizedBox(height: S.x3), + SlotTable(comparison: slotComparisonFor(entry), dim: other), + slot == DeviceSlot.everyDay + ? PairNote(LucideIcons.flaskConical, l.pairWearableCardNote, + color: C.orange) + : PairNote(LucideIcons.info, l.pairStrapNote), + ], + ); + } +} diff --git a/lib/ui2/pairing/pair_band_view.dart b/lib/ui2/pairing/pair_band_view.dart new file mode 100644 index 000000000..0830b053a --- /dev/null +++ b/lib/ui2/pairing/pair_band_view.dart @@ -0,0 +1,197 @@ +// First-run "Pair your band": the devices that can be the user's main band, +// each marked "Every day", the always-open "Trouble connecting?" card, and +// the ways out (a heart-rate strap only, skip). +import 'package:flutter/material.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; + +import '../../ble/adapters/_registry.dart'; +import '../../ble/slot_comparison.dart'; +import '../../l10n/display_text.dart'; +import '../ui2.dart'; +import 'category_filter_pills.dart'; +import 'pair_help.dart'; +import 'pair_sheets.dart'; +import 'pair_text.dart'; +import 'pair_widgets.dart'; +import 'whoop_firmware_warning.dart'; + +/// The devices the first run offers as the main band, in registry order. +List firstRunBandEntries() => [ + for (final e in kBandRegistry) + if (e.canBeMainDevice) e, +]; + +/// What the first-run list asks of the screen around it. +abstract interface class PairBandHost { + /// A device row was tapped. + void pickBand(BandEntry entry); + + /// The user confirmed pairing a heart-rate strap as a sensor (no band). + void strapOnlyConfirmed(); +} + +class PairBandView extends StatefulWidget { + final List entries; + final PairBandHost host; + + /// Non-null only at true first run: walk past pairing. + final VoidCallback? onSkip; + + /// Where the back chevron goes when there is no route underneath to pop + /// (first-run onboarding); null keeps the default `Navigator.maybePop`. + final VoidCallback? onBack; + + /// The last failure, in a sentence. + final String? problem; + final PairLinkOpener openLink; + + const PairBandView({ + super.key, + required this.entries, + required this.host, + this.onSkip, + this.onBack, + this.problem, + this.openLink = const SystemLinkOpener(), + }); + + @override + State createState() => _PairBandViewState(); +} + +class _PairBandViewState extends State { + final _group = ValueNotifier(null); + + @override + void initState() { + super.initState(); + _group.addListener(() => setState(() {})); + } + + @override + void dispose() { + _group.dispose(); + super.dispose(); + } + + Future _strapOnly() async { + if (await showStrapSheet(context, sensor: kBleHrs)) { + widget.host.strapOnlyConfirmed(); + } + } + + @override + Widget build(BuildContext c) { + final p = P.of(c); + final l = pairL10n(c); + final shown = filterByGroup(widget.entries, _group.value); + return Scaffold( + backgroundColor: p.bg, + body: SafeArea( + child: Column(children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: S.x4), + child: NavBar(l.pairSetUpTitle, onBack: widget.onBack), + ), + Expanded( + child: ListView( + padding: const EdgeInsets.fromLTRB(S.x4, S.x2, S.x4, S.x10), + children: [ + const WhoopFirmwareWarning(), + const SizedBox(height: S.x4), + Text(l.pairBandTitle, + key: const ValueKey('pair-band-title'), + style: F.t1.copyWith(color: p.ink)), + const SizedBox(height: S.x2), + Text(l.pairBandSubtitle, style: F.body.copyWith(color: p.ink2)), + const SizedBox(height: S.x2), + Text(l.pairMainBandWhoopOnly, + key: const ValueKey('main-band-whoop-only-note'), + style: F.cap.copyWith(color: p.ink3)), + const SizedBox(height: S.x4), + CategoryFilterPills( + kinds: [for (final e in widget.entries) e.kind], + selection: _group, + ), + if (shown.isNotEmpty) const SizedBox(height: S.x3), + for (var i = 0; i < shown.length; i++) ...[ + if (i > 0) const SizedBox(height: S.x3), + _BandRow( + entry: shown[i], + onTap: () => widget.host.pickBand(shown[i]), + ), + ], + if (widget.problem != null) ...[ + const SizedBox(height: S.x4), + StatusCard(l.pairSensorThatDidNotWork, widget.problem!, + icon: LucideIcons.circleAlert), + ], + const SizedBox(height: S.x4), + TroubleConnectingCard( + entries: widget.entries, openLink: widget.openLink), + TextLinkButton(l.pairStrapOnlyLink, onTap: _strapOnly), + if (widget.onSkip != null) ...[ + BigButton(l.pairingSkipForNow, + color: C.blue, soft: true, onTap: widget.onSkip), + const SizedBox(height: S.x2), + Text(l.pairingSkipNote, + style: F.cap.copyWith(color: p.ink3)), + ], + ], + ), + ), + ]), + ), + ); + } +} + +/// The line under a row says what a WHOOP sends. It is WHOOP copy, so another +/// main-band entry added later gets no line until it has its own. +bool _isWhoop(BandEntry e) => e.id == kWhoopGen4.id || e.id == kWhoopGen5.id; + +class _BandRow extends StatelessWidget { + final BandEntry entry; + final VoidCallback onTap; + const _BandRow({required this.entry, required this.onTap}); + + @override + Widget build(BuildContext c) { + final p = P.of(c); + final l = pairL10n(c); + final slot = slotComparisonFor(entry).slot; + return Surface( + key: ValueKey('band-row-${entry.id}'), + onTap: onTap, + child: Row(children: [ + Container( + width: 48, + height: 48, + alignment: Alignment.center, + decoration: BoxDecoration(color: p.card2, borderRadius: R.rMd), + child: Icon(deviceKindIcon(entry.kind), size: 22, color: p.ink2), + ), + const SizedBox(width: S.x3), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(uiText(c, entry.label), + style: F.body + .copyWith(color: p.ink, fontWeight: FontWeight.w600)), + if (_isWhoop(entry)) ...[ + const SizedBox(height: 2), + Text(l.pairWhoopRowLine, + style: F.cap.copyWith(color: p.ink2)), + ], + if (slot != null) ...[ + const SizedBox(height: S.x2), + slotPill(l, slot), + ], + ]), + ), + Icon(LucideIcons.chevronRight, size: 18, color: p.ink3), + ]), + ); + } +} diff --git a/lib/ui2/pairing/pair_choice_sheet.dart b/lib/ui2/pairing/pair_choice_sheet.dart index eeb661a92..c298f3da6 100644 --- a/lib/ui2/pairing/pair_choice_sheet.dart +++ b/lib/ui2/pairing/pair_choice_sheet.dart @@ -4,8 +4,10 @@ // only in words, so there is one sheet. import 'package:flutter/material.dart'; +import '../../ble/slot_comparison.dart'; import '../ui2.dart'; import 'pair_widgets.dart'; +import 'slot_comparison_view.dart'; /// What the user picked on a [PairChoiceSheet]. enum PairChoice { primary, secondary, back } @@ -17,7 +19,10 @@ class PairChoiceSheet extends StatelessWidget { final String title; final String? lead; + final SlotComparison comparison; + /// The column the device goes into; washed on the table. + final DeviceSlot? focus; /// Icon-and-caption notes under the table. final List notes; @@ -38,6 +43,8 @@ class PairChoiceSheet extends StatelessWidget { required this.deviceName, required this.title, this.lead, + required this.comparison, + this.focus, this.notes = const [], this.pairingMode, required this.primaryLabel, @@ -82,6 +89,7 @@ class PairChoiceSheet extends StatelessWidget { Text(lead!, style: F.body.copyWith(color: p.ink2)), ], const SizedBox(height: S.x4), + SlotTable(comparison: comparison, focus: focus), ...notes, if (pairingMode != null) ...[ const SizedBox(height: S.x5), @@ -109,6 +117,8 @@ Future showPairChoiceSheet(BuildContext c, PairChoiceSheet sheet) { context: c, backgroundColor: p.card, isScrollControlled: true, + // Honours Reduce Motion like every other modal sheet in ui2. + sheetAnimationStyle: sheetMotion(c), // A full-height sheet must not slide under the status bar or a notch. useSafeArea: true, showDragHandle: true, diff --git a/lib/ui2/pairing/pair_sheets.dart b/lib/ui2/pairing/pair_sheets.dart index 1b3278047..457064687 100644 --- a/lib/ui2/pairing/pair_sheets.dart +++ b/lib/ui2/pairing/pair_sheets.dart @@ -9,6 +9,7 @@ import 'package:flutter/material.dart'; import 'package:lucide_icons_flutter/lucide_icons.dart'; import '../../ble/adapters/_registry.dart'; +import '../../ble/slot_comparison.dart'; import '../../l10n/display_text.dart'; import '../ui2.dart'; import 'pair_choice_sheet.dart'; @@ -21,7 +22,7 @@ enum BandSheetChoice { /// Pair it as the main band (no band paired yet). asBand, - /// Unpair the band paired now, then pair this one as the main band. Only + /// Pair the replacement before retiring the current main band. Only /// offered with a band paired; the caller confirms once before acting. replaceBand, @@ -46,12 +47,13 @@ Future showBandFoundSheet( }) async { final l = pairL10n(c); final label = modelKnown ? uiText(c, band.label) : 'WHOOP'; + final cmp = slotComparisonFor(band, modelKnown: modelKnown); final icon = deviceKindIcon(band.kind); final name = deviceName ?? label; if (!band.canBeMainDevice) { // A ring or a watch: it fills every day as the active wearable, behind // its own switch; a Coros watch fits neither column. - final wearable = band.category == DeviceCategory.wearable; + final wearable = cmp.slot == DeviceSlot.everyDay; final choice = await showPairChoiceSheet( c, PairChoiceSheet( @@ -65,6 +67,8 @@ Future showBandFoundSheet( ? l.pairWearableLeadPebble : l.pairWearableLead : null, + comparison: cmp, + focus: cmp.slot, notes: [ wearable ? PairNote(LucideIcons.flaskConical, l.pairWearableNote, @@ -91,6 +95,8 @@ Future showBandFoundSheet( : hasMainBand ? l.pairBandFoundBodyHasBand : l.pairBandFoundBody, + comparison: cmp, + focus: DeviceSlot.everyDay, notes: [ if (hasMainBand) PairNote(LucideIcons.watch, l.pairBandNow(current)), ], @@ -112,8 +118,8 @@ Future showBandFoundSheet( }; } -/// The one confirm before replacing the band: "Unpair (your band) and pair this -/// band instead? Your data stays." True only on the explicit yes. +/// Confirm replacement while preserving the old pairing on failed setup. +/// True only on the explicit yes. Future showReplaceBandConfirm(BuildContext c, {String? mainBandName}) async { final l = pairL10n(c); final name = mainBandName ?? l.pairCurrentBandFallback; @@ -161,6 +167,7 @@ Future showStrapSheet(BuildContext c, {required BandEntry sensor, String? deviceName}) async { final l = pairL10n(c); final label = uiText(c, sensor.label); + final cmp = slotComparisonFor(sensor); final choice = await showPairChoiceSheet( c, PairChoiceSheet( @@ -168,6 +175,8 @@ Future showStrapSheet(BuildContext c, deviceName: deviceName ?? label, title: deviceSheetTitle(l, sensor), lead: l.pairStrapLead, + comparison: cmp, + focus: DeviceSlot.workoutsOnly, notes: [PairNote(LucideIcons.info, l.pairStrapNote)], pairingMode: PairingModeSection(entry: sensor), primaryLabel: l.pairDeviceNamed(label), diff --git a/lib/ui2/pairing/pair_text.dart b/lib/ui2/pairing/pair_text.dart index 1952ceec7..efa7b6bcd 100644 --- a/lib/ui2/pairing/pair_text.dart +++ b/lib/ui2/pairing/pair_text.dart @@ -5,14 +5,73 @@ import 'package:flutter/material.dart'; import 'package:lucide_icons_flutter/lucide_icons.dart'; import '../../ble/adapters/_registry.dart'; +import '../../ble/slot_comparison.dart'; import '../../l10n/app_localizations.dart'; +import '../ui2.dart'; /// Localizations for [c]; English when none are mounted (a bare test widget), /// the same fallback the rest of the pairing copy has. AppLocalizations pairL10n(BuildContext c) => AppLocalizations.of(c) ?? lookupAppLocalizations(const Locale('en')); -/// The filter pills' groups (K3): what the user would call the device. +String capabilityLabel(AppLocalizations l, DeviceCapability c) => switch (c) { + DeviceCapability.sleep => l.capLabelSleep, + DeviceCapability.recovery => l.capLabelRecovery, + DeviceCapability.strain => l.capLabelStrain, + DeviceCapability.heartRate => l.capLabelHeartRate, + DeviceCapability.hrv => l.capLabelHrv, + DeviceCapability.respiration => l.capLabelRespiration, + DeviceCapability.skinTemperature => l.capLabelSkinTemperature, + DeviceCapability.steps => l.capLabelSteps, + DeviceCapability.bloodOxygen => l.capLabelBloodOxygen, + DeviceCapability.workoutHeartRate => l.capLabelWorkoutHeartRate, + DeviceCapability.workoutBeatToBeat => l.capLabelWorkoutBeatToBeat, +}; + +/// The one-line caption under a capability, or null when it has none. +String? capabilityReason(AppLocalizations l, CapabilityStatus s) => + switch (s.kind) { + CapabilityKind.native => null, + CapabilityKind.vendorReported => l.capVendorReported, + CapabilityKind.conditional => switch (s.reasonKey) { + kReasonSkinTempNights => l.capReasonSkinTempNights, + kReasonSkinTempProvisional => l.capReasonSkinTempProvisional, + kReasonEstimated => l.capReasonEstimated, + kReasonEarly => l.capReasonEarly, + kReasonFirstNights => l.capReasonFirstNights, + kReasonOwnStagesRing => l.capReasonOwnStagesRing, + kReasonOwnStages => l.capReasonOwnStages, + kReasonLiveSessions => l.capReasonLiveSessions, + kReasonUnconfirmed => l.capReasonUnconfirmed, + kReasonPebble2Only => l.capReasonPebble2Only, + kReasonPebble2OnlyEstimated => l.capReasonPebble2OnlyEstimated, + _ => null, + }, + }; + +/// The column's name: "Every day" or "Workouts only". +String slotLabel(AppLocalizations l, DeviceSlot s) => switch (s) { + DeviceSlot.everyDay => l.slotEveryDay, + DeviceSlot.workoutsOnly => l.slotWorkoutsOnly, +}; + +/// Each column's colour and icon, the same on the table, the chips and the +/// device card. +Color slotColor(DeviceSlot s) => switch (s) { + DeviceSlot.everyDay => C.teal, + DeviceSlot.workoutsOnly => C.purple, +}; + +IconData slotIcon(DeviceSlot s) => switch (s) { + DeviceSlot.everyDay => LucideIcons.sun, + DeviceSlot.workoutsOnly => LucideIcons.dumbbell, +}; + +/// The chip that says where a device fits. +Widget slotPill(AppLocalizations l, DeviceSlot s, {Key? key}) => + Pill(slotLabel(l, s), slotColor(s), icon: slotIcon(s), key: key); + +/// The filter pills' groups: what the user would call the device. /// A WHOOP is its own group; a Mi Band sits with the watches. Scales and /// thermometers have no group and show under All only. enum PairFilter { whoop, rings, watches, straps } diff --git a/lib/ui2/pairing/slot_comparison_view.dart b/lib/ui2/pairing/slot_comparison_view.dart new file mode 100644 index 000000000..f16088d77 --- /dev/null +++ b/lib/ui2/pairing/slot_comparison_view.dart @@ -0,0 +1,174 @@ +// THE table of what a device gives "Every day" and "Workouts only": a row +// per capability, a check on a tint where it sends, a muted cross where it +// does not (never a dash). The pairing sheets wash the column the device goes +// into; the device page fades the column it is not in. One widget, one file, +// so the comparison style can be swapped without touching a screen. The facts +// come from `slotComparisonFor`; this only draws. +import 'package:flutter/material.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; + +import '../../ble/slot_comparison.dart'; +import '../ui2.dart'; +import 'pair_text.dart'; + +/// One table row: null in a column means that column does not send it. +typedef SlotRow = ({ + DeviceCapability capability, + CapabilityStatus? everyDay, + CapabilityStatus? workouts, +}); + +/// The rows of [c]: every row of the table ([kTableRows]), in order. +List slotRowsFor(SlotComparison c) => [ + for (final k in kTableRows) + ( + capability: k, + everyDay: c.everyDay.sends[k], + workouts: c.workoutsOnly.sends[k], + ), +]; + +class SlotTable extends StatelessWidget { + final SlotComparison comparison; + + /// The column the device goes into, washed in its colour (the sheets). + final DeviceSlot? focus; + + /// The column the device is not in, faded (the device page). + final DeviceSlot? dim; + + const SlotTable({super.key, required this.comparison, this.focus, this.dim}); + + static const double colWidth = 104; + + @override + Widget build(BuildContext c) { + final p = P.of(c); + final l = pairL10n(c); + Widget cell(DeviceSlot s, Widget child) => Container( + key: ValueKey('slot-cell-${s.name}'), + width: colWidth, + alignment: Alignment.center, + color: focus == s ? p.wash(slotColor(s), strength: .55) : null, + child: Opacity(opacity: dim == s ? .28 : 1, child: child), + ); + Widget line(Widget label, Widget a, Widget b, + {Key? key, bool top = true, double v = S.x3}) => + Container( + key: key, + decoration: BoxDecoration( + border: top ? Border(top: BorderSide(color: p.line)) : null), + child: IntrinsicHeight( + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.fromLTRB(S.x4, v, S.x2, v), + child: Align( + alignment: AlignmentDirectional.centerStart, + child: label), + ), + ), + cell(DeviceSlot.everyDay, a), + cell(DeviceSlot.workoutsOnly, b), + ]), + ), + ); + Widget head(DeviceSlot s) => Padding( + // Room above the icons, so they do not sit on the table's edge. + padding: const EdgeInsets.fromLTRB(S.x1, S.x3, S.x1, S.x2), + child: Column(mainAxisSize: MainAxisSize.min, children: [ + Icon(slotIcon(s), size: 16, color: p.on(slotColor(s))), + const SizedBox(height: 3), + Text(slotLabel(l, s), + key: ValueKey('slot-head-${s.name}'), + textAlign: TextAlign.center, + style: F.cap.copyWith(color: p.ink, fontWeight: FontWeight.w700)), + ]), + ); + Widget row(SlotRow r) { + final k = r.capability.name; + final reasons = []; + for (final (slot, status) in [ + (DeviceSlot.everyDay, r.everyDay), + (DeviceSlot.workoutsOnly, r.workouts), + ]) { + final reason = status == null ? null : capabilityReason(l, status); + if (reason != null) { + reasons.add(l.slotColumnReason(slotLabel(l, slot), reason)); + } + } + return line( + key: ValueKey('slot-row-$k'), + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text(capabilityLabel(l, r.capability), + style: F.body.copyWith(color: p.ink)), + for (final reason in reasons) + Padding( + padding: const EdgeInsets.only(top: 2), + child: Text(reason, style: F.cap.copyWith(color: p.ink3)), + ), + ]), + SlotMark(r.everyDay != null, capability: r.capability, + slot: DeviceSlot.everyDay, reason: r.everyDay?.kind == CapabilityKind.conditional + ? capabilityReason(l, r.everyDay!) : null, key: ValueKey('slot-everyDay-$k')), + SlotMark(r.workouts != null, capability: r.capability, + slot: DeviceSlot.workoutsOnly, reason: r.workouts?.kind == CapabilityKind.conditional + ? capabilityReason(l, r.workouts!) : null, key: ValueKey('slot-workoutsOnly-$k')), + ); + } + + final rows = slotRowsFor(comparison); + return Container( + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + color: p.card2, borderRadius: R.rLg, border: Border.all(color: p.line)), + child: Column(children: [ + line(const SizedBox.shrink(), head(DeviceSlot.everyDay), + head(DeviceSlot.workoutsOnly), + top: false, v: S.x2), + // The workout rows name themselves ("… during workouts"); no group + // row. + for (final r in rows) row(r), + ]), + ); + } +} + +/// A check on a green tint where the column sends the row, a muted cross where +/// it does not. Announces the capability, column and status to a screen reader. +class SlotMark extends StatelessWidget { + final bool sends; + final DeviceCapability capability; + final DeviceSlot slot; + final String? reason; + const SlotMark(this.sends, + {super.key, required this.capability, required this.slot, this.reason}); + + @override + Widget build(BuildContext c) { + final p = P.of(c); + final l = pairL10n(c); + final status = sends ? l.slotSendsHeading : l.slotDoesntSendHeading; + return Semantics( + label: l.slotCapabilityStatus(capabilityLabel(l, capability), + slotLabel(l, slot), reason == null ? status : '$status. $reason'), + excludeSemantics: true, + child: sends + ? Container( + width: 24, + height: 24, + alignment: Alignment.center, + decoration: + BoxDecoration(color: p.wash(C.green), shape: BoxShape.circle), + child: Icon(LucideIcons.check, size: 15, color: p.on(C.green)), + ) + : SizedBox( + width: 24, + height: 24, + child: Icon(LucideIcons.x, size: 16, color: p.ink3)), + ); + } +} + diff --git a/lib/ui2/profile/devices.dart b/lib/ui2/profile/devices.dart index d9b575095..b4fe9ba2e 100644 --- a/lib/ui2/profile/devices.dart +++ b/lib/ui2/profile/devices.dart @@ -85,6 +85,10 @@ import '../../sync/paired_device.dart' show cleanDeviceLabel; import '../../state/app_state.dart'; import '../../state/clock_format.dart' show formatClockOf; import '../pairing/device_picker.dart' show DevicePickerScreen; +import '../pairing/pair_text.dart' show pairL10n, slotPill; +import '../../ble/slot_comparison.dart' show DeviceSlot; +import '../pairing/device_slot_card.dart' + show DeviceSlotCard, pairedDeviceSlot; import 'firmware_flash_screen.dart' show FirmwareFlashScreen; import '../onboarding/profile_setup.dart' show formatDay; import '../ui2.dart'; @@ -1132,8 +1136,9 @@ class MyDevices extends StatelessWidget { } Widget _build(BuildContext c, AppState app, Set liveAdapterIds) { + final sources = rankSources(liveSources(app, liveAdapterIds: liveAdapterIds)); return MyDevicesView( - sources: rankSources(liveSources(app, liveAdapterIds: liveAdapterIds)), + sources: sources, // The band row's dot says connected or not. That covers six different // problems with six different fixes, and a user cannot fix a problem the // app will not name — so the engine's own verdict rides alongside it. @@ -1147,6 +1152,10 @@ class MyDevices extends StatelessWidget { // way back to pairing. So push it. onPair: () => goto(c, const RePair()), onAddSensor: () => addSensor(c), + onUnpair: () { + final band = sources.where((s) => s.isBand).firstOrNull; + _confirmForget(c, app, band?.displayName(c) ?? ''); + }, contendedSignals: contendedSignals(app), onSignalPriority: () => goto(c, const SignalPriorityScreen()), ); @@ -1470,6 +1479,9 @@ class MyDevicesView extends StatelessWidget { final List sources; final VoidCallback? onPair, onAddSensor; + /// "Unpair band" on the already-paired card; null hides the button. + final VoidCallback? onUnpair; + /// The band's own state, from `bandStatusFor`. Null when nothing is paired. final BandStatus? status; @@ -1484,6 +1496,7 @@ class MyDevicesView extends StatelessWidget { this.sources = const [], this.onPair, this.onAddSensor, + this.onUnpair, this.status, this.contendedSignals = const [], this.onSignalPriority, @@ -1506,7 +1519,6 @@ class MyDevicesView extends StatelessWidget { // the toggle sits on while a denied READ permission returns nothing. So // "a source exists" was the wrong test for this card: it told a user // whose phone was measuring nothing that "the phone counts steps". - final phoneCounting = sources.any((s) => !s.isBand && s.connected); final l = AppLocalizations.of(c); return Scaffold( backgroundColor: p.bg, @@ -1520,31 +1532,10 @@ class MyDevicesView extends StatelessWidget { child: ListView( padding: const EdgeInsets.fromLTRB(S.x4, 0, S.x4, S.x10), children: [ - // FIRST, in the tier-2 slot the missing band would occupy — - // not appended under the phone. Someone who has just forgotten - // a band is here to add one, and the row they can see is not - // the one they came for. - if (!hasBand) ...[ - StatusCard( - phoneCounting - ? (l?.devicesNoBandPaired ?? 'No band is paired') - : (l?.devicesNothingMeasuringYet ?? - 'Nothing is measuring yet'), - phoneCounting - ? (l?.devicesPhoneCountingBody ?? - 'The phone counts steps and nothing else. Heart ' - 'rate, sleep, recovery and temperature all abstain ' - 'until a band is paired.') - : (l?.devicesNothingMeasuringBody ?? - 'No band is paired and no phone steps are arriving, ' - 'so every metric in the app will abstain rather ' - 'than estimate.'), - fix: l?.devicesPairABand ?? 'Pair a band', - icon: LucideIcons.watch, - onFix: onPair, - ), - if (sources.isNotEmpty) const SizedBox(height: S.x3), - ], + // "Pair a device": the band first (or who it is, when one is + // paired), then "Add a device" for anything else. + ..._pairSection(c, hasBand), + if (sources.isNotEmpty) const SizedBox(height: S.x3), // LIVE — the first of the two buckets. Only drawn when there is // something in it: a heading over nothing is the empty rung // problem again, one level up. @@ -1562,19 +1553,6 @@ class MyDevicesView extends StatelessWidget { ], const SizedBox(height: S.x3), ], - // At the foot of LIVE, because that is what it adds to. Not - // gated on having a band: a sensor is a second source, and - // someone with no band at all is exactly who benefits most - // from being able to pair one. - if (onAddSensor != null) - Surface( - pad: const EdgeInsets.symmetric(horizontal: S.x4), - child: SetRow(LucideIcons.plus, C.green, - l?.pairAddDevice ?? 'Add a device', - sub: l?.pairAddDeviceSub ?? - 'A heart-rate strap or a ring, alongside the band', - onTap: onAddSensor), - ), // ONLY when something can actually contend. A reorder screen // over one device is a control with nothing to order, which is // the empty-rung problem this screen already refuses (§6.5). @@ -1617,6 +1595,162 @@ class MyDevicesView extends StatelessWidget { } } +extension _PairSection on MyDevicesView { + /// The "Pair a device" section. Empty when there is nothing to show (a + /// fixture with no callbacks and no band). + List _pairSection(BuildContext c, bool hasBand) { + final l = pairL10n(c); + final band = sources.where((s) => s.isBand).firstOrNull; + // What having no band costs. The phone row is listed whenever its toggle + // is on, so "a source exists" is not the test: only steps actually being + // banked is (see the note above `hasBand`). + // Only the PHONE counts here: a connected ring or strap is not phone + // steps, so it must not select the "phone counts steps" message. + final phoneCounting = + sources.any((s) => s.tier == SourceTier.phone && s.connected); + // A connected ring or watch fills the everyday columns without a band, so + // "every metric abstains" would be wrong while one is active. + final everyDayWearable = sources.any((s) => + !s.isBand && + s.connected && + slotDeviceOf(s)?.slot == DeviceSlot.everyDay); + final al = AppLocalizations.of(c); + final children = [ + // ONE card for the band, paired or not, so the section keeps its + // height when the state flips: the status and the action in one box. + if ((!hasBand && onPair != null) || (hasBand && band != null)) + _YourBandCard( + bandName: hasBand ? band?.displayName(c) : null, + bandState: hasBand && band != null + ? _localizedSourceState(c, band) + : null, + onPair: onPair, + onUnpair: onUnpair, + consequence: hasBand || everyDayWearable + ? null + : phoneCounting + ? (al?.devicesPhoneCountingBody ?? + 'The phone counts steps and nothing else. Heart ' + 'rate, sleep, recovery and temperature all abstain ' + 'until a band is paired.') + : (al?.devicesNothingMeasuringBody ?? + 'No band is paired and no phone steps are arriving, ' + 'so every metric in the app will abstain rather ' + 'than estimate.'), + ), + if (onAddSensor != null) + Surface( + pad: const EdgeInsets.symmetric(horizontal: S.x4), + child: SetRow(LucideIcons.plus, C.green, l.pairAddDevice, + sub: l.pairAddDeviceSub, onTap: onAddSensor), + ), + ]; + if (children.isEmpty) return const []; + return [ + Section(l.pairSectionTitle, Column(children: [ + for (var i = 0; i < children.length; i++) ...[ + if (i > 0) const SizedBox(height: S.x3), + children[i], + ], + ])), + const SizedBox(height: S.x3), + ]; + } +} + +/// A paired device that fits one of the two columns: a ring or a watch +/// (every day, as the active wearable) or a workout sensor such as a +/// heart-rate strap (workouts only). Null for the band, the phone, a scale, a +/// thermometer or a Coros watch. A WHOOP the user kept for workouts is stored +/// under the heart-rate-sensor adapter, so it is a workout sensor too. +({BandEntry entry, DeviceSlot slot})? slotDeviceOf(HealthSource s) { + if (s.isBand || s.deviceId == null) return null; + final e = kBandRegistry.where((e) => e.id == s.family).firstOrNull; + final slot = e == null ? null : pairedDeviceSlot(e); + return slot == null ? null : (entry: e!, slot: slot); +} + +/// The column chip a source row carries: the band is every day; a paired +/// device its own column. +DeviceSlot? sourceSlot(HealthSource s) => + s.isBand ? DeviceSlot.everyDay : slotDeviceOf(s)?.slot; + +/// "Your band": no band yet ("No band is paired", the WHOOP-only line and +/// "Pair your band"), or the paired band (its name, its state and "Unpair +/// band"). Both states keep the same shape: a heading row, two lines, one +/// button. +class _YourBandCard extends StatelessWidget { + /// The paired band's name; null when no band is paired. + final String? bandName; + final String? bandState; + final VoidCallback? onPair, onUnpair; + + /// Unpaired only: what the app can and cannot measure without a band, in + /// the same card so the section says it once. + final String? consequence; + const _YourBandCard( + {this.bandName, + this.bandState, + this.onPair, + this.onUnpair, + this.consequence}); + + @override + Widget build(BuildContext c) { + final p = P.of(c); + final l = pairL10n(c); + final paired = bandName != null; + return Surface( + key: ValueKey(paired ? 'band-paired-card' : 'pair-band-card'), + child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + Wrap( + alignment: WrapAlignment.spaceBetween, + crossAxisAlignment: WrapCrossAlignment.center, + spacing: S.x2, + runSpacing: S.x2, + children: [ + Text(l.devicesYourBand, style: F.head.copyWith(color: p.ink)), + slotPill(l, DeviceSlot.everyDay), + ], + ), + const SizedBox(height: S.x2), + Text(paired ? bandName! : l.devicesNoBandPaired, + key: const ValueKey('your-band-status'), + style: F.body.copyWith(color: p.ink, fontWeight: FontWeight.w600)), + const SizedBox(height: 2), + paired + ? Text(bandState ?? '', style: F.cap.copyWith(color: p.ink2)) + : Text(l.pairCardBandBody, + key: const ValueKey('main-band-whoop-only-note'), + style: F.cap.copyWith(color: p.ink2)), + if (!paired && consequence != null) ...[ + const SizedBox(height: S.x2), + Text(consequence!, + key: const ValueKey('no-band-consequence'), + style: F.cap.copyWith(color: p.ink2)), + ], + if (paired ? onUnpair != null : onPair != null) ...[ + const SizedBox(height: S.x4), + paired + ? BigButton(l.pairUnpairBand, + icon: LucideIcons.unlink, + color: C.red, + soft: true, + onTap: onUnpair) + : BigButton(l.pairBandTitle, + icon: LucideIcons.bluetooth, onTap: onPair), + ], + ]), + ); + } +} + +@visibleForTesting +Future debugConfirmForgetBand( + BuildContext c, AppState app, String name) => + _confirmForget(c, app, name); + + /// The one line under a source's name. /// /// "Not connected" is a statement about a radio link, and the phone has none: @@ -1631,7 +1765,10 @@ String sourceState(HealthSource s) { // resting state and not a fault — and a sensor whose tier could not be named // falls back to the phone's rung, where this function would otherwise have // told the user their chest strap was reporting steps. - if (s.deviceId != null) { + // A ring or watch fills whole days, so a workout never arms it: it reads + // as a band does, by sync and link, below. + final wearable = slotDeviceOf(s)?.slot == DeviceSlot.everyDay; + if (s.deviceId != null && !wearable) { if (s.connected) return 'Streaming beats'; // A source with no rung supplies no signal, so there is nothing for a // workout to arm and nothing being derived. Say that, rather than promise @@ -1647,7 +1784,7 @@ String sourceState(HealthSource s) { String _localizedSourceState(BuildContext c, HealthSource s) { final l = AppLocalizations.of(c); - if (s.deviceId != null) { + if (s.deviceId != null && slotDeviceOf(s)?.slot != DeviceSlot.everyDay) { if (s.connected) return l?.devicesStreamingBeats ?? 'Streaming beats'; return s.tier == null ? (l?.devicesStoringWhatItSends ?? 'Paired · storing what it sends') @@ -1675,7 +1812,11 @@ class SourceRow extends StatelessWidget { final p = P.of(c); final battery = s.batteryPct; final stacked = bigText(c); - final tierBadge = s.tier == null + // A secondary sensor is named by its role on its own page; a rung and an + // "Experimental" word on the row said nothing about what it sends. + final slot = sourceSlot(s); + final secondary = slotDeviceOf(s) != null; + final tierBadge = s.tier == null || secondary ? null : Pill( AppLocalizations.of(c)?.devicesTierRank(s.tier!.rank) ?? @@ -1746,11 +1887,16 @@ class SourceRow extends StatelessWidget { // IN THE WRAP, not a second trailing pill: this line already // wraps at accessibility sizes, and a pill column beside it does // not. The band's own page carries the explanation. - if (s.experimental) + if (s.experimental && !secondary) Text(AppLocalizations.of(c)?.devicesExperimental ?? 'Experimental', style: F.over.copyWith(color: p.on(C.orange))), ], ), + if (slot != null) ...[ + const SizedBox(height: S.x2), + slotPill(pairL10n(c), slot, + key: ValueKey('source-slot-${slot.name}')), + ], if (stacked && tierBadge != null) ...[ const SizedBox(height: S.x1), tierBadge, @@ -2436,7 +2582,12 @@ class DeviceDetailView extends StatelessWidget { fix: fault.fix ?? '', icon: LucideIcons.bluetoothOff), const SizedBox(height: S.x5), ], - if (s.tier case final t?) ...[ + if (slotDeviceOf(s) case final d?) ...[ + DeviceSlotCard(entry: d.entry, slot: d.slot), + const SizedBox(height: S.x4), + // The switch the card's note names, right under it. + DeviceUseSwitch(deviceId: s.deviceId!, adapterId: d.entry.id), + ] else if (s.tier case final t?) ...[ TierRow(t, filled: true), const SizedBox(height: S.x5), ], @@ -2452,23 +2603,28 @@ class DeviceDetailView extends StatelessWidget { Surface( pad: const EdgeInsets.symmetric(horizontal: S.x4), child: Column(children: [ - SetRow(LucideIcons.flaskConical, C.orange, - l?.devicesSupport ?? 'Support', - value: l?.devicesExperimental ?? 'Experimental', - sub: l?.devicesSensorExperimentalSub ?? - 'Decoded from the protocol, never checked ' - 'against the hardware — nobody here owns one.', - chevron: false), - Divider(color: p.line, height: 1), - SetRow(LucideIcons.database, C.teal, - l?.devicesWhatItDoes ?? 'What it does', - sub: s.tier == null - ? (l?.devicesWhatItDoesStored ?? - 'Everything it sends is saved under its name. Scores from it are experimental and off until it’s been checked against the hardware.') - : (l?.devicesWhatItDoesBeats ?? - 'Heartbeat timing is saved under its name, during workouts and a few minutes after. Scoring workouts from it is experimental and off for now.'), - chevron: false), - Divider(color: p.line, height: 1), + if (slotDeviceOf(s) == null) ...[ + SetRow(LucideIcons.flaskConical, C.orange, + l?.devicesSupport ?? 'Support', + value: l?.devicesExperimental ?? 'Experimental', + sub: l?.devicesSensorExperimentalSub ?? + 'Decoded from the protocol, never checked ' + 'against the hardware — nobody here owns one.', + chevron: false), + Divider(color: p.line, height: 1), + ], + // The every-day card above already describes wearables. + if (slotDeviceOf(s)?.slot != DeviceSlot.everyDay) ...[ + SetRow(LucideIcons.database, C.teal, + l?.devicesWhatItDoes ?? 'What it does', + sub: s.tier == null + ? (l?.devicesWhatItDoesStored ?? + 'Everything it sends is saved under its name. Scores from it are experimental and off until it’s been checked against the hardware.') + : (l?.devicesWhatItDoesBeats ?? + 'Heartbeat timing is saved under its name, during workouts and a few minutes after. Scoring workouts from it is experimental and off for now.'), + chevron: false), + Divider(color: p.line, height: 1), + ], SetRow(LucideIcons.refreshCw, C.purple, l?.devicesLastData ?? 'Last data', value: last == null ? '' : formatDayTime(last, l), @@ -2521,7 +2677,8 @@ class DeviceDetailView extends StatelessWidget { ), ), const SizedBox(height: S.x5), - if (s.family case final family?) + if (s.family case final family? + when slotDeviceOf(s) == null) DeviceUseSwitch( deviceId: s.deviceId!, adapterId: family), ], diff --git a/lib/ui2/profile/pair_sensor.dart b/lib/ui2/profile/pair_sensor.dart index df697b343..1f4df6057 100644 --- a/lib/ui2/profile/pair_sensor.dart +++ b/lib/ui2/profile/pair_sensor.dart @@ -405,15 +405,18 @@ class _PairSensorScreenState extends State @override Future pair(BandCandidate cand, BandEntry entry, PairConfirmation? confirmation) async { + // Read before the await: if pairing throws after this screen is gone, the + // catch below must not touch a disposed context. + final l = AppLocalizations.of(context); try { return await pairRegisteredEntry(entry, cand.device, label: cand.label, earlierBand: cand.alsoBand, confirmation: confirmation); } catch (e) { - return PairOutcome.failed(AppLocalizations.of(context) - ?.pairSensorCouldNotPair(e.toString()) ?? - 'Could not pair that device: $e'); + return PairOutcome.failed( + l?.pairSensorCouldNotPair(e.toString()) ?? + 'Could not pair that device: $e'); } } diff --git a/test/alarm_epoch_owner_write_test.dart b/test/alarm_epoch_owner_write_test.dart new file mode 100644 index 000000000..fda0d2586 --- /dev/null +++ b/test/alarm_epoch_owner_write_test.dart @@ -0,0 +1,146 @@ +// The armed alarm epoch is stored with the band that holds it. The owner must +// be written BEFORE the epoch and every write checked: if the owner write +// fails the epoch must not be saved under the previous owner, where it would +// read back as the previous band's arm and as nothing for the band that took it. +import 'package:flutter_test/flutter_test.dart'; +import 'package:openstrap_edge/state/alarm_schedule.dart'; +import 'package:openstrap_edge/ui2/pairing/device_picker.dart' show refreshAfterPair; +import 'package:shared_preferences/shared_preferences.dart'; +// ignore: depend_on_referenced_packages +import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart'; + +import 'support/failing_preferences_store.dart'; + +void main() { + late SharedPreferencesStorePlatform original; + + setUp(() { + original = SharedPreferencesStorePlatform.instance; + }); + tearDown(() => SharedPreferencesStorePlatform.instance = original); + + Future prefsWith(Map values) async { + SharedPreferences.setMockInitialValues(values); + return SharedPreferences.getInstance(); + } + + group('saveArmedAlarmEpoch', () { + test('a new band takes the arm: old epoch cleared, owner then epoch written', + () async { + final prefs = await prefsWith({'alarm_epoch': 100, kAlarmRemoteId: 'A'}); + await saveArmedAlarmEpoch(prefs, 200, 'B'); + expect(prefs.getString(kAlarmRemoteId), 'B'); + expect(persistedAlarmEpoch(prefs, 'B'), 200); + expect(persistedAlarmEpoch(prefs, 'A'), isNull); + }); + + test('the same band just refreshes its epoch', () async { + final prefs = await prefsWith({'alarm_epoch': 100, kAlarmRemoteId: 'A'}); + await saveArmedAlarmEpoch(prefs, 200, 'A'); + expect(persistedAlarmEpoch(prefs, 'A'), 200); + }); + + test('a failed owner write throws and never saves the epoch under the old owner', + () async { + final prefs = await prefsWith({'alarm_epoch': 100, kAlarmRemoteId: 'A'}); + SharedPreferencesStorePlatform.instance = FailingPreferencesStore( + SharedPreferencesStorePlatform.instance, + key: kAlarmRemoteId, + throws: false); + await expectLater(saveArmedAlarmEpoch(prefs, 200, 'B'), throwsStateError); + expect(prefs.getInt('alarm_epoch'), isNull, + reason: 'neither the old nor the new epoch is left behind'); + expect(persistedAlarmEpoch(prefs, 'A'), isNull, + reason: 'the previous band is not handed a different band\'s epoch'); + }); + + test('a failed clear of the previous epoch throws before the owner changes', + () async { + final prefs = await prefsWith({'alarm_epoch': 100, kAlarmRemoteId: 'A'}); + SharedPreferencesStorePlatform.instance = FailingPreferencesStore( + SharedPreferencesStorePlatform.instance, + key: 'alarm_epoch', + throws: false); + await expectLater(saveArmedAlarmEpoch(prefs, 200, 'B'), throwsStateError); + expect(prefs.getString(kAlarmRemoteId), 'A', + reason: 'the owner is only changed after the old epoch is gone'); + }); + + test('a clear that lands during the owner change stops the older epoch', () async { + final prefs = await prefsWith({'alarm_epoch': 100, kAlarmRemoteId: 'A'}); + var current = true; + SharedPreferencesStorePlatform.instance = _OnWrite( + SharedPreferencesStorePlatform.instance, + 'flutter.$kAlarmRemoteId', + () => current = false); // a clear/newer arm starts during the write + final saved = await saveArmedAlarmEpoch(prefs, 200, 'B', + stillCurrent: () => current); + expect(saved, isFalse); + expect(prefs.getInt('alarm_epoch'), isNull, + reason: 'the superseded epoch must not be written after the clear'); + }); + + test('superseded before anything is written: nothing is touched', () async { + final prefs = await prefsWith({'alarm_epoch': 100, kAlarmRemoteId: 'A'}); + final saved = await saveArmedAlarmEpoch(prefs, 200, 'B', + stillCurrent: () => false); + expect(saved, isFalse); + expect(prefs.getInt('alarm_epoch'), 100); + expect(prefs.getString(kAlarmRemoteId), 'A'); + }); + + test('with no paired band the epoch is saved untagged, as before', () async { + final prefs = await prefsWith({}); + await saveArmedAlarmEpoch(prefs, 200, null); + expect(prefs.getInt('alarm_epoch'), 200); + expect(prefs.getString(kAlarmRemoteId), isNull); + }); + }); + + group('bindAlarmEpochToBand', () { + test('tags an untagged epoch with the band being left', () async { + final prefs = await prefsWith({'alarm_epoch': 100}); + expect(await bindAlarmEpochToBand(prefs, 'A'), isTrue); + expect(persistedAlarmEpoch(prefs, 'B'), isNull); + expect(persistedAlarmEpoch(prefs, 'A'), 100); + }); + + test('leaves another band\'s tagged epoch alone', () async { + final prefs = await prefsWith({'alarm_epoch': 100, kAlarmRemoteId: 'X'}); + expect(await bindAlarmEpochToBand(prefs, 'A'), isTrue); + expect(prefs.getString(kAlarmRemoteId), 'X'); + }); + }); + + group('refreshAfterPair', () { + test('a failing refresh does not turn a saved pairing into a failure', () async { + expect(await refreshAfterPair(() async => throw StateError('db busy')), + isFalse); + }); + + test('a working refresh reports success', () async { + var ran = false; + expect(await refreshAfterPair(() async => ran = true), isTrue); + expect(ran, isTrue); + }); + }); +} + +// Runs [onWrite] when the matching key is written, then lets the write through. +class _OnWrite extends SharedPreferencesStorePlatform { + _OnWrite(this.delegate, this.key, this.onWrite); + final SharedPreferencesStorePlatform delegate; + final String key; + final void Function() onWrite; + @override + Future> getAll() => delegate.getAll(); + @override + Future clear() => delegate.clear(); + @override + Future remove(String key) => delegate.remove(key); + @override + Future setValue(String type, String key, Object value) { + if (key == this.key) onWrite(); + return delegate.setValue(type, key, value); + } +} diff --git a/test/app_state_pairing_confirmation_test.dart b/test/app_state_pairing_confirmation_test.dart index bd2fa3748..88697e0e2 100644 --- a/test/app_state_pairing_confirmation_test.dart +++ b/test/app_state_pairing_confirmation_test.dart @@ -450,6 +450,31 @@ void main() { reason: 'the old band must not be reconnected after the save'); })); + // WHY: the primary peripheral must never also be a secondary sensor. A + // candidate that already has a workout-only row would be saved as primary + // with that row (and its link) still alive. + // catches: replacing onto a band that is already a secondary sensor. + test('replacement refuses a candidate that is already a secondary sensor', + syncCase((rig, timers) async { + await PairedDevice.save(kRemoteId, kSerial, generation: 'gen4'); + await rig.openAndSettle(); + await LocalDb.upsertDevice( + id: 'ble_hrs-$replacementId', + adapterId: 'ble_hrs', + remoteId: replacementId, + label: 'Chest strap'); + rig.engine.events.clear(); + await expectLater( + rig.app.replaceWith(BluetoothDevice.fromId(replacementId)), + throwsA(isA())); + expect((await PairedDevice.load())?.remoteId, kRemoteId, + reason: 'the current band stays paired'); + expect(rig.engine.only('connect'), isEmpty, + reason: 'nothing starts before the refusal'); + expect((await LocalDb.deviceRows()).where((r) => r['remote_id'] == replacementId), + hasLength(1), reason: 'the sensor row is untouched'); + })); + // WHY: an upgraded install can hold an armed epoch with no owner tag, which // every band reads as its own. After a forget, a new band would be treated // as already armed and never receive SET_ALARM. @@ -548,6 +573,60 @@ void main() { reason: 'the replacement must not be saved after the reset'); })); + // WHY: setAlarm waits for the band's reply. If the band is forgotten while + // it waits, the arm must not be saved afterwards: with no paired band the + // epoch would be written ownerless, and any later band reads it as its own. + // catches: persisting an arm for a band that is no longer paired. + test('an alarm arm pending while the band is forgotten is not recorded', + syncCase((rig, timers) async { + await PairedDevice.save(kRemoteId, kSerial, generation: 'gen4'); + await rig.openAndSettle(); + final prefs = await SharedPreferences.getInstance(); + await prefs.remove('alarm_epoch'); + await prefs.remove(kAlarmRemoteId); + final gate = Completer(); + rig.engine.armGate = gate; + final arming = rig.app.setAlarm(DateTime.now().add(const Duration(hours: 8))); + await rig.waitFor(() => rig.engine.events.any((e) => e.startsWith('armAlarm'))); + await rig.app.unpair(); + rig.engine.armGate = null; + gate.complete(); + await arming; + expect(prefs.getInt('alarm_epoch'), isNull, + reason: 'an ownerless epoch would be read as armed by the next band'); + expect(persistedAlarmEpoch(prefs, replacementId), isNull); + expect(rig.app.alarmEpoch, isNull); + })); + + // WHY: waiting out the old burst is bounded, but a timeout is not "the burst + // stopped": it could resume on the candidate's session and request history + // from the wrong band. Pairing must stop instead of connecting under it. + // catches: treating the wait's timeout as permission to connect. + test('replacement stops when the superseded sync burst outlives the wait', + syncCase((rig, timers) async { + await PairedDevice.save(kRemoteId, kSerial, generation: 'gen4'); + await rig.openAndSettle(); + rig.engine.events.clear(); + final gate = Completer(); + rig.engine.syncGate = gate; + final burst = rig.app.syncNow(); + await rig.waitFor(() => rig.engine.events.any((e) => e.startsWith('runSync'))); + final replacing = rig.app.replaceWith(BluetoothDevice.fromId(replacementId)); + final failed = expectLater(replacing, throwsA(isA())); + await settleMs(60); + final waits = timers.activeOneShot(const Duration(seconds: 15)); + expect(waits, hasLength(1), reason: 'the bounded wait for the old burst'); + waits.single.fire(); + await failed; + expect(rig.engine.only('connect'), isNot(contains('connect:$replacementId:-')), + reason: 'the candidate must not connect under a still-running burst'); + expect((await PairedDevice.load())?.remoteId, kRemoteId, + reason: 'the old pairing is kept'); + rig.engine.syncGate = null; + gate.complete(); + await burst; + })); + // WHY: a lost band's retry must finish before candidate bootstrap starts. // catches: rejecting replacement because the old loop is reconnecting, // or clearing its flag without waiting for its in-flight connect. diff --git a/test/backup/settings_audit_guard_test.dart b/test/backup/settings_audit_guard_test.dart index 3c657b085..6e3171a1e 100644 --- a/test/backup/settings_audit_guard_test.dart +++ b/test/backup/settings_audit_guard_test.dart @@ -114,8 +114,6 @@ const _indirectKeys = >{ 'health_import_profile_at', 'health_import_workouts_at'], 'lib/notify/notification_prefs.dart:_kBatteryPct': ['notif_battery_pct'], 'lib/state/app_state.dart:_kHealthSync': ['health_sync'], - 'lib/state/app_state.dart:kAlarmRemoteId': ['alarm_remote_id'], - 'lib/sync/background_sync.dart:kAlarmRemoteId': ['alarm_remote_id'], 'lib/sync/paired_device.dart:_kWornOn': ['paired_worn_on'], 'lib/sync/paired_device.dart:key': [ 'paired_remote_id', 'paired_serial', 'paired_generation'], diff --git a/test/band_identity_test.dart b/test/band_identity_test.dart index 53ea64c85..4cc332f1e 100644 --- a/test/band_identity_test.dart +++ b/test/band_identity_test.dart @@ -8,6 +8,7 @@ import 'package:openstrap_edge/ble/band_identity.dart'; import 'package:openstrap_edge/ble/hrs_link.dart'; import 'package:openstrap_edge/ui2/pairing/pair_outcome_text.dart'; import 'package:openstrap_edge/sync/paired_device.dart' show kBandSourceTier; +import 'package:openstrap_edge/ui2/pairing/add_device_flow.dart' show addDeviceScanEntries; import 'package:openstrap_protocol/openstrap_protocol.dart'; BandEntry? _id(List svc, [String? name]) => @@ -135,6 +136,30 @@ void main() { rssi: -55, ); + test('the Add a device scan covers the framed WHOOP entries: a WHOOP-only advertisement is a candidate', () { + // WHY: a WHOOP that advertises only its own band service matched no + // sensor entry and was dropped, so the band could never be discovered + // from "Add a device". + final entries = addDeviceScanEntries(); + expect(entries.map((e) => e.id), containsAll(['gen4', 'gen5', 'ble_hrs', 'oura'])); + expect(entries.map((e) => e.id).toSet().length, kBandRegistry.length); + // (A by-name entry makes the OS filter empty: every advertisement is heard.) + final filter = HrsLink.scanServiceFilter(entries); + expect(filter.isEmpty || filter.contains(Guid(kWhoopGen5.service)), isTrue); + final c = HrsLink.candidateFromAd( + entries: entries, + device: BluetoothDevice.fromId('AA:BB:CC:DD:EE:21'), + serviceUuids: [Guid(kWhoopGen5.service)], + advName: 'WHOOP 5A1B', + platformName: '', + rssi: -50, + ); + expect(c, isNotNull); + expect(c!.entryId, 'gen5'); + // Control: the same advertisement against the sensor list alone is dropped. + expect(cand([kWhoopGen5.service], 'WHOOP 5A1B'), isNull); + }); + test('a WHOOP advertising 0x180D is a ble_hrs hit flagged alsoBand=gen4', () { // WHY: the picker needs both facts: it matched the HR scan AND is a band. final c = cand([kHeartRateServiceUuid, kWhoopGen4.service], 'WHOOP 4C01'); diff --git a/test/device_sources_test.dart b/test/device_sources_test.dart index a2e33f480..980184bd2 100644 --- a/test/device_sources_test.dart +++ b/test/device_sources_test.dart @@ -95,7 +95,7 @@ void main() { )); await t.pumpAndSettle(); // The card that offers to pair a BAND is still there, because one is not. - expect(find.text('Pair a band'), findsOneWidget); + expect(find.byKey(const ValueKey('pair-band-card')), findsOneWidget); expect(find.text('Polar H10'), findsOneWidget); }); diff --git a/test/guards/pairing_reset_steps_guard_test.dart b/test/guards/pairing_reset_steps_guard_test.dart index 7dc5f97d6..a41242258 100644 --- a/test/guards/pairing_reset_steps_guard_test.dart +++ b/test/guards/pairing_reset_steps_guard_test.dart @@ -65,6 +65,12 @@ void main() { } }); + test('Hindi physical strain is distinct from stress', () { + // WHY: the comparison table must not label physical strain as stress. + final hi = _arb(File('lib/l10n/app_hi.arb')); + expect(hi['capLabelStrain'], 'शारीरिक परिश्रम'); + }); + test('every registry entry declares reset steps', () { // WHY: an undeclared device would show a user stuck at pairing nothing. final missing = [ @@ -110,7 +116,7 @@ void main() { group('unverified', () { test('an unverified entry carries an officialUrl on its pinned host', () { // WHY: unsourced steps point at the vendor's own help page, never a - // search engine or a look-alike host. DT8: zero unverified entries is + // search engine or a look-alike host. zero unverified entries is // allowed (the goal), so the registry loop may be empty; the fixture // controls below prove the check can bite. for (final e in _of(ResetKind.unverified)) { @@ -119,7 +125,7 @@ void main() { }); test('control: the unverified check passes a good fixture and fails bad ones', () { - // WHY (DT8): a fixture, not a real registry entry, is the positive control. + // WHY: a fixture, not a real registry entry, is the positive control. const good = ResetSteps.unverified(officialUrl: 'https://support.whoop.com/x'); const search = ResetSteps.unverified( officialUrl: 'https://www.google.com/search?q=whoop'); @@ -170,7 +176,7 @@ void main() { final actual = {for (final e in _of(ResetKind.noOfficialSite)) e.id}; expect(expected, {'thermometer'}, reason: 'only the thermometer is a registry entry on this branch'); - // DT11: the generic HR profile has no maker either (no research row). + // the generic HR profile has no maker either (no research row). expect(actual, {...expected, 'ble_hrs'}); expect(kBleHrs.resetSteps?.reason, 'Generic Bluetooth heart-rate profile; maker unknown'); }); diff --git a/test/live_step_runs_test.dart b/test/live_step_runs_test.dart index 0e6ef67ce..5d488a146 100644 --- a/test/live_step_runs_test.dart +++ b/test/live_step_runs_test.dart @@ -441,6 +441,46 @@ void main() { expect(await db.query('live_coverage'), isNotEmpty); }); + test('control: without a reset the walk is checkpointed', () async { + SharedPreferences.setMockInitialValues({}); + final app = AppState.forTesting(); + addTearDown(app.dispose); + const recTs = 1787100000; + for (var f = 0; f < 700; f++) { + app.debugFeedLiveAccel(_walkFrame(f, 10), + recTs: recTs, atMs: recTs * 1000 + f * 100); + } + await Future.delayed(const Duration(milliseconds: 50)); + final prefs = await SharedPreferences.getInstance(); + expect(prefs.containsKey('live_session_checkpoint'), isTrue); + }); + + test('a reset after the steps were collected is not checkpointed back', + () async { + SharedPreferences.setMockInitialValues({}); + final app = AppState.forTesting(); + addTearDown(app.dispose); + const recTs = 1787000000; + // One full walking minute: runs are buffered and a first checkpoint lands. + for (var f = 0; f < 700; f++) { + app.debugFeedLiveAccel(_walkFrame(f, 10), + recTs: recTs, atMs: recTs * 1000 + f * 100); + } + await Future.delayed(const Duration(milliseconds: 50)); + final prefs = await SharedPreferences.getInstance(); + await prefs.remove('live_session_checkpoint'); + ResetGate.enter(); + ResetGate.leave(); + // The next minute completes AFTER the reset; the buffered runs predate it. + for (var f = 700; f < 1400; f++) { + app.debugFeedLiveAccel(_walkFrame(f, 10), + recTs: recTs, atMs: recTs * 1000 + f * 100); + } + await Future.delayed(const Duration(milliseconds: 50)); + expect(prefs.containsKey('live_session_checkpoint'), isFalse, + reason: 'runs from before the reset must not be written back'); + }); + test('a reset after the steps were collected keeps them out of storage', () async { final app = await walked(); diff --git a/test/no_gen4_default_test.dart b/test/no_gen4_default_test.dart index d73415a5c..6e66f35f2 100644 --- a/test/no_gen4_default_test.dart +++ b/test/no_gen4_default_test.dart @@ -18,6 +18,8 @@ const _bandProfileGen4Defaults = 6; final _pureComment = RegExp(r'^\s*(///|//|\*|/\*)'); +RegExp _assignmentOf(String symbol) => RegExp('(?])=\\s*${RegExp.escape(symbol)}\\b'); + int _countMatches(RegExp pattern) { var total = 0; for (final f in Directory('lib') @@ -33,10 +35,24 @@ int _countMatches(RegExp pattern) { } void main() { + // WHY: a model comparison added by the pairing screen is not a fallback. + // catches: counting the second '=' in == or the '=' in !=/<=/>=. + test('the default counter distinguishes assignment from comparisons', () { + for (final symbol in ['kWhoopGen4', 'BandProfile.gen4']) { + final assignment = _assignmentOf(symbol); + expect(assignment.hasMatch('BandEntry entry = $symbol;'), isTrue); + for (final operator in ['==', '!=', '<=', '>=']) { + expect(assignment.hasMatch('entry $operator $symbol.id'), isFalse, + reason: '$operator is a comparison, not an assignment'); + } + } + }); + + test('kWhoopGen4 default-fallback count only goes down', () { // `?? kWhoopGen4` sites plus the one field default (`= kWhoopGen4`). final count = _countMatches(RegExp(r'\?\?\s*kWhoopGen4')) + - _countMatches(RegExp(r'=\s*kWhoopGen4\b')); + _countMatches(_assignmentOf('kWhoopGen4')); expect(count, _kWhoopGen4Defaults, reason: 'kWhoopGen4-default count drifted from the tracked value. ' 'If a commit just retired a site, lower _kWhoopGen4Defaults in ' @@ -47,7 +63,7 @@ void main() { // `?? BandProfile.gen4` sites plus the one field/parameter default // (`= BandProfile.gen4`). final count = _countMatches(RegExp(r'\?\?\s*BandProfile\.gen4')) + - _countMatches(RegExp(r'=\s*BandProfile\.gen4\b')); + _countMatches(_assignmentOf('BandProfile.gen4')); expect(count, _bandProfileGen4Defaults, reason: 'BandProfile.gen4-default count drifted from the tracked ' 'value. If a commit just retired a site, lower ' diff --git a/test/pairing_copy_test.dart b/test/pairing_copy_test.dart new file mode 100644 index 000000000..5b40ee094 --- /dev/null +++ b/test/pairing_copy_test.dart @@ -0,0 +1,65 @@ +// Two pieces of pairing copy that made claims the app cannot back: +// - the strap note said "Both need ..." on a sheet that shows no table, so +// "both" had nothing to point at; +// - the Pebble 2 lead promised recovery, but the adapter decodes heart rate, +// steps and sleep only, and readiness needs two inputs it does not provide. +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; + +const _locales = ['en', 'de', 'es', 'fr', 'hi', 'ru', 'th', 'zh']; + +// The word for "recovery" in each locale's own copy. +const _recovery = { + 'en': 'recovery', + 'de': 'Erholung', + 'es': 'recuperación', + 'fr': 'récupération', + 'hi': 'रिकवरी', + 'ru': 'восстановлен', + 'th': 'การฟื้นตัว', + 'zh': '恢复', +}; + +// Words that only make sense with a table in view. +const _both = { + 'en': 'Both', + 'de': 'beides', + 'es': 'Ambos', + 'fr': 'Les deux', + 'hi': 'दोनों', + 'ru': 'обоих', + 'th': 'ทั้งสองอย่าง', + 'zh': '两项', +}; + +Map _arb(String l) => + jsonDecode(File('lib/l10n/app_$l.arb').readAsStringSync()) as Map; + +void main() { + for (final l in _locales) { + group(l, () { + test('the strap note stands alone: no "both", and it names the switch', () { + final note = _arb(l)['pairStrapNote'] as String; + expect(note.contains(_both[l]!), isFalse, + reason: '"$note" refers to a table this sheet does not show'); + // It quotes the localized name of the switch it tells the user to turn on. + final switchName = + RegExp('[“«„](.+?)[”»“]').firstMatch(note)?.group(1) ?? + RegExp('« (.+?) »').firstMatch(note)?.group(1); + expect(switchName, isNotNull, reason: 'the note must name the switch: $note'); + expect(note, contains(switchName!)); + }); + + test('the Pebble 2 lead does not promise recovery', () { + final lead = _arb(l)['pairWearableLeadPebble'] as String; + // Only the part before "Pebble 2 SE" describes what Pebble 2 provides. + // What follows says what an SE (no heart-rate sensor) cannot give. + final first = lead.split('Pebble 2 SE').first; + expect(first.contains(_recovery[l]!), isFalse, + reason: 'Pebble 2 supplies at most one readiness input: "$first"'); + }); + }); + } +} diff --git a/test/pairing_stack_review_test.dart b/test/pairing_stack_review_test.dart index 7ac372a71..9c9b3f212 100644 --- a/test/pairing_stack_review_test.dart +++ b/test/pairing_stack_review_test.dart @@ -29,6 +29,7 @@ class _App extends AppState { Completer? supported; Completer? scanned; String? scannedGeneration; + String? scannedRemoteId; Object? pickerError; var replacements = 0; var pickers = 0; @@ -41,6 +42,7 @@ class _App extends AppState { String? generation, }) async { scannedGeneration = generation; + scannedRemoteId = remoteId; return scanned == null ? null : await scanned!.future; } @@ -153,42 +155,29 @@ void main() { expect(find.text('Bluetooth thermometer'), findsOneWidget); }); - // WHY: callbacks may already be queued before the disabled rows rebuild. - // catches: guarding only _flow.running, which category navigation never sets. - testWidgets( - 'category and nearby taps share a lock until navigation returns', - (t) async { - final app = _App(); - addTearDown(app.dispose); - await _screen(t, app, const DevicePickerScreen()); - final view = t.widget(find.byType(DevicePickerView)); - view.onOpenEntry!(kWhoopGen4); - view.onOpenEntry!(kWhoopGen4); - view.onPickNearby!(( - device: BluetoothDevice.fromId('new'), - label: 'WHOOP', - rssi: -50, - entryId: 'gen5', - alsoBand: null, - )); - await t.pumpAndSettle(); - expect(find.byType(PairingScreen, skipOffstage: false), findsOneWidget); - expect(find.byType(BottomSheet), findsNothing); - Navigator.of(t.element(find.byType(PairingScreen))).pop(); - await t.pumpAndSettle(); - final unlocked = t.widget( - find.byType(DevicePickerView), - ); - expect(unlocked.locked, isFalse); - unlocked.onOpenEntry!(kWhoopGen4); - await t.pumpAndSettle(); - expect( - find.byType(PairingScreen), - findsOneWidget, - reason: 'next deliberate tap is accepted', - ); - }, - ); + // WHY: first-run callbacks may already be queued before navigation covers + // the picker. Returning from the route must allow the next deliberate tap. + testWidgets('first-run taps stay locked until navigation returns', (t) async { + final app = _App(); + addTearDown(app.dispose); + await _screen(t, app, const DevicePickerScreen()); + final dynamic host = t.state(find.byType(DevicePickerScreen)); + host.pickBand(kWhoopGen4); + host.pickBand(kWhoopGen4); + host.strapOnlyConfirmed(); + await t.pumpAndSettle(); + expect(find.byType(PairingScreen, skipOffstage: false), findsOneWidget); + expect(find.byType(BottomSheet), findsNothing); + Navigator.of(t.element(find.byType(PairingScreen))).pop(); + await t.pumpAndSettle(); + host.pickBand(kWhoopGen4); + await t.pumpAndSettle(); + expect( + find.byType(PairingScreen), + findsOneWidget, + reason: 'next deliberate tap is accepted', + ); + }); // WHY: the host callbacks used by first-run must obey the same lock as // category and nearby taps, without losing the selected WHOOP model. @@ -211,17 +200,19 @@ void main() { expect(app.scannedGeneration, 'gen5'); }); - // WHY: the single WHOOP category stands for gen4 and gen5 while still - // carrying WHOOP reset help. Only a scanned candidate establishes its model. - // catches: forwarding the category representative gen4 as a scan filter. - testWidgets('WHOOP category keeps help while scanning across generations', ( + // WHY: a name-only candidate establishes the remote id, but not a model. + // The representative entry supplies safe help without filtering out gen5. + testWidgets('name-only WHOOP handoff keeps help and the exact candidate', ( t, ) async { final app = _App(); addTearDown(app.dispose); await _screen(t, app, const DevicePickerScreen()); - t.widget(find.byType(DevicePickerView)).onOpenEntry!( + final io = t.state(find.byType(DevicePickerScreen)) as AddDeviceIo; + final opened = io.openBandFlow( kWhoopGen4, + remoteId: 'picked', + modelKnown: false, ); await t.pumpAndSettle(); expect( @@ -231,6 +222,10 @@ void main() { await t.tap(find.text('Find my band')); await t.pumpAndSettle(); expect(app.scannedGeneration, isNull); + expect(app.scannedRemoteId, 'picked'); + Navigator.of(t.element(find.byType(PairingScreen))).pop(); + await t.pumpAndSettle(); + await opened; }); for (final waitingOnSupport in [false, true]) { @@ -271,7 +266,7 @@ void main() { final app = _App(); addTearDown(app.dispose); final probe = Completer(); - await _screen(t, app, DevicePickerScreen(debugScanHeldBackReason: () => probe.future)); + await _screen(t, app, DevicePickerScreen(includeBand: false, debugScanHeldBackReason: () => probe.future)); final view = t.widget(find.byType(DevicePickerView)); view.onScan!(); view.onOpenEntry!(kWhoopGen4); diff --git a/test/russian_review_findings_test.dart b/test/russian_review_findings_test.dart index 8a8bcf66a..532c57f22 100644 --- a/test/russian_review_findings_test.dart +++ b/test/russian_review_findings_test.dart @@ -335,7 +335,7 @@ void main() { addTearDown(app.dispose); await t.pumpWidget(ChangeNotifierProvider.value( value: app, - child: page(const DevicePickerScreen()), + child: page(const DevicePickerScreen(includeBand: false)), )); await t.pumpAndSettle(); final entry = kBleHrs; diff --git a/test/slot_comparison_test.dart b/test/slot_comparison_test.dart new file mode 100644 index 000000000..a4018aa1d --- /dev/null +++ b/test/slot_comparison_test.dart @@ -0,0 +1,324 @@ +// Slot comparison: what a device gives "Every day" (the main band, or the +// active wearable) and "Workouts only" (a workout-armed sensor). Capabilities +// come from the compute layer's eligibility rules: the metric x device +// columns (canonical.dart columnFor/capabilities), the native WHOOP pipeline, +// and the workout-armed sensor set. +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter_test/flutter_test.dart'; +import 'package:openstrap_edge/ble/adapters/_registry.dart'; +import 'package:openstrap_edge/ble/slot_comparison.dart'; +import 'package:openstrap_edge/compute/inputs/canonical.dart' + show MetricClass, capabilities, columnFor, kWorkoutArmedSensors; + +typedef C = DeviceCapability; +typedef K = CapabilityKind; + +// The table's rows, in the order the sheets draw them (owner-approved r4 +// mockup): the whole-day rows, then the workout rows. Never blood oxygen. +const _dayRows = [ + C.sleep, + C.recovery, + C.strain, + C.heartRate, + C.hrv, + C.respiration, + C.skinTemperature, + C.steps, +]; +const _workoutRows = [C.workoutHeartRate, C.workoutBeatToBeat]; + +Set _keys(SlotSide s) => s.sends.keys.toSet(); + +List _columnEntries() => + [for (final e in kBandRegistry) if (columnFor(e.id) != null) e]; + +void main() { + test('the table rows are the eight whole-day rows, then the two workout rows', () { + // WHY: every sheet and the device card draw the same rows in the same + // order; a drifting list changes every table at once. + expect(kDayCapabilities, _dayRows); + expect(kSessionCapabilities.toList(), _workoutRows); + expect(kTableRows, [..._dayRows, ..._workoutRows]); + expect(kTableRows, isNot(contains(C.bloodOxygen))); + }); + + group('WHOOP', () { + for (final e in [kWhoopGen4, kWhoopGen5]) { + test('${e.id}: every day, as the main band, sends every row', () { + // WHY: the native pipeline (onehz_pipeline.dart) computes sleep, + // recovery, strain, resting HR, HRV, respiration and skin temperature, + // and the band records workouts. + final cmp = slotComparisonFor(e); + expect(cmp.slot, DeviceSlot.everyDay); + final d = cmp.everyDay.sends; + expect(d.keys.toSet(), {..._dayRows, ..._workoutRows}); + for (final c in [C.sleep, C.recovery, C.strain, C.heartRate, C.hrv, + C.respiration, C.workoutHeartRate, C.workoutBeatToBeat]) { + expect(d[c]?.kind, K.native, reason: '${e.id} $c'); + } + // a nightly mean, >= 3 prior nights, baseline spread >= 1. + expect(d[C.skinTemperature]?.kind, K.conditional); + expect(d[C.skinTemperature]?.reasonKey, kReasonSkinTempNights); + }); + + test('${e.id}: workouts only, read as a heart-rate sensor', () { + // WHY: a WHOOP kept for workouts is paired under ble_hrs, so it sends + // heart rate, and beat timing only if the band sends RR intervals. + final w = slotComparisonFor(e).workoutsOnly.sends; + expect(w.keys.toSet(), _workoutRows.toSet()); + expect(w[C.workoutHeartRate]?.kind, K.native); + expect(w[C.workoutBeatToBeat]?.kind, K.conditional); + expect(w[C.workoutBeatToBeat]?.reasonKey, kReasonUnconfirmed); + }); + } + + test('steps: WHOOP 4 only during live sessions, WHOOP 5 from its own counter', () { + // WHY: gen4 has no on-chip counter (derivation_engine.dart + // _stepCounterModulus), so its steps come only from the strap's 100 Hz + // pedometer over a live link (live_step_runs.dart). gen5's cumulative + // counter rides every synced row (decoded_onehz.step_count). + final g4 = slotComparisonFor(kWhoopGen4).everyDay.sends[C.steps]; + expect(g4?.kind, K.conditional); + expect(g4?.reasonKey, kReasonLiveSessions); + expect(slotComparisonFor(kWhoopGen5).everyDay.sends[C.steps]?.kind, + K.native); + }); + }); + + group('wearables fill every day (the active wearable)', () { + test('the six columned entries are found (control for the loops below)', () { + expect({for (final e in _columnEntries()) e.id}, + {'garmin', 'pebble', 'miband234', 'ultrahuman', 'colmi', 'oura'}); + }); + + test('Oura: the rows read off kOuraColumn, with their captions', () { + // WHY: oura_inputs.dart: sleep off the ring's own stages, readiness + // provisional until 14 nights of baseline, skin temperature after a few + // nights, strain and steps not decoded; not workout-armed. + final cmp = slotComparisonFor(kOura); + expect(cmp.slot, DeviceSlot.everyDay); + final d = cmp.everyDay.sends; + expect(d.keys.toSet(), {C.sleep, C.recovery, C.heartRate, C.hrv, + C.respiration, C.skinTemperature}); + expect(d[C.sleep]?.reasonKey, kReasonOwnStagesRing); + expect(d[C.recovery]?.reasonKey, kReasonFirstNights); + expect(d[C.skinTemperature]?.reasonKey, kReasonSkinTempProvisional); + for (final c in [C.heartRate, C.hrv, C.respiration]) { + expect(d[c]?.kind, K.native, reason: '$c'); + } + expect(cmp.workoutsOnly.sends, isEmpty); + }); + + test('every columned wearable: every-day rows follow capabilities(column)', () { + // WHY: ours -> native (or a stated condition), device -> the device's own + // reading, estimated -> conditional, unavailable -> not sent. + for (final e in _columnEntries()) { + final col = columnFor(e.id)!; + final cls = capabilities(col); + final cmp = slotComparisonFor(e); + expect(cmp.slot, DeviceSlot.everyDay, reason: e.id); + expect(cmp.workoutsOnly.sends, isEmpty, reason: e.id); + final sends = cmp.everyDay.sends; + for (final m in kCapabilityRow.entries) { + final c = cls[m.value]; + final got = sends[m.key]; + final why = '${e.id} ${m.key} ($c)'; + switch (c) { + case null || MetricClass.unavailable: + expect(got, isNull, reason: why); + case MetricClass.device: + expect(got?.kind, K.vendorReported, reason: why); + case MetricClass.estimated: + expect(got?.kind, K.conditional, reason: why); + case MetricClass.ours: + expect(got, isNotNull, reason: why); + expect(got!.kind, isNot(K.vendorReported), reason: why); + } + if (got?.kind == K.conditional) { + expect(got!.reasonKey?.trim() ?? '', isNotEmpty, reason: why); + } + } + expect(sends.keys.toSet().intersection(_workoutRows.toSet()), isEmpty, + reason: '${e.id}: a wearable is no workout session source'); + } + }); + + test('Pebble HR rows are Pebble 2 only; SE keeps reported sleep and steps', () { + final cmp = slotComparisonFor(kPebble); + final d = cmp.everyDay.sends; + expect(d.keys.toSet(), {C.sleep, C.recovery, C.strain, C.heartRate, C.steps}); + for (final c in [C.recovery, C.strain, C.heartRate]) { + expect(d[c]?.kind, K.conditional, reason: 'SE has no HR sensor: $c'); + } + expect(d[C.strain]?.reasonKey, 'capReasonPebble2Only'); + expect(d[C.heartRate]?.reasonKey, 'capReasonPebble2Only'); + // WHY: Pebble 2's recovery is an estimate; the + // Pebble 2 only caption must not drop that. + expect(d[C.recovery]?.reasonKey, 'capReasonPebble2OnlyEstimated'); + expect(d[C.sleep]?.reasonKey, kReasonOwnStages); + expect(d[C.steps]?.kind, K.vendorReported); + expect(cmp.workoutsOnly.sends, isEmpty); + }); + + test('hand-read anchors: Garmin', () { + // garmin_inputs.dart: HRV the watch's own unless a strap gave beats, + // readiness an estimate without a strap, strain ours, no skin temp. + final g = slotComparisonFor(kGarmin).everyDay.sends; + expect(g.containsKey(C.skinTemperature), isFalse); + expect(g[C.hrv]?.kind, K.vendorReported); + expect(g[C.recovery]?.kind, K.conditional); + expect(g[C.strain]?.kind, K.native); + }); + }); + + group('workout sensors fill workouts only', () { + test('a chest strap: heart rate; beat timing if the strap sends it', () { + // WHY: kWorkoutArmedSensors arms ble_hrs; RR intervals are optional in + // the Heart Rate Service. + final cmp = slotComparisonFor(kBleHrs); + expect(cmp.slot, DeviceSlot.workoutsOnly); + expect(cmp.everyDay.sends, isEmpty); + final w = cmp.workoutsOnly.sends; + expect(w[C.workoutHeartRate]?.kind, K.native); + expect(w[C.workoutBeatToBeat]?.reasonKey, kReasonUnconfirmed); + expect(cmp.workoutsOnly.doesNotSend, _dayRows.toSet()); + }); + + test('Polar PMD: its PPI stream is beats, so no "not confirmed" caption', () { + final w = slotComparisonFor(kPolarPmd).workoutsOnly.sends; + expect(w[C.workoutBeatToBeat]?.kind, K.native); + expect(w[C.workoutHeartRate]?.reasonKey, isNull); + expect(slotComparisonFor(kPolarPmd).slot, DeviceSlot.workoutsOnly); + }); + + test('only the armed sensors and a WHOOP send anything for workouts', () { + expect(kWorkoutArmedSensors, {'ble_hrs', 'polar_pmd'}); + for (final e in kBandRegistry) { + final w = _keys(slotComparisonFor(e).workoutsOnly); + final armed = {'ble_hrs', 'polar_pmd', 'gen4', 'gen5'}.contains(e.id); + expect(w, armed ? _workoutRows.toSet() : isEmpty, reason: e.id); + } + }); + }); + + test('"not confirmed" only where the device may not send it: a generic strap, a WHOOP read as one', () { + // WHY: devices people use (Oura, Polar) carry only factual + // captions; the unconfirmed one is for RR from the generic profile. + final unconfirmed = { + for (final e in kBandRegistry) + for (final s in DeviceSlot.values) + for (final m in slotComparisonFor(e).side(s).sends.entries) + if (m.value.reasonKey == kReasonUnconfirmed) '${e.id}:${m.key.name}', + }; + expect(unconfirmed, { + 'ble_hrs:workoutBeatToBeat', + 'gen4:workoutBeatToBeat', + 'gen5:workoutBeatToBeat', + }); + }); + + test('Coros, scales and thermometers fit neither column', () { + // WHY: canonical.dart wearableEnabled() is false for Coros and it has no + // column; nothing arms it for workouts. + expect(declaredSignals('coros').map((s) => s.name), contains('rrIntervals'), + reason: 'positive control: Coros does declare beats'); + for (final e in [kCoros, kThermometer, kMiScale2, kMiScaleComposition]) { + final cmp = slotComparisonFor(e); + expect(cmp.slot, isNull, reason: e.id); + expect(cmp.everyDay.sends, isEmpty, reason: e.id); + expect(cmp.workoutsOnly.sends, isEmpty, reason: e.id); + } + }); + + test('no registry entry claims blood oxygen, in either column', () { + expect(capabilities(columnFor('oura')!)['spo2'], MetricClass.device, + reason: 'positive control: a column does offer a vendor spo2'); + for (final e in kBandRegistry) { + final cmp = slotComparisonFor(e); + for (final s in DeviceSlot.values) { + expect(cmp.side(s).sends.containsKey(C.bloodOxygen), isFalse, + reason: '${e.id} $s'); + expect(cmp.side(s).doesNotSend.contains(C.bloodOxygen), isFalse, + reason: '${e.id} $s'); + expect(capabilityTrace(e, C.bloodOxygen, slot: s), isNull, + reason: '${e.id} $s'); + } + } + }); + + test('doesNotSend is the table rows minus sends, for every entry and column', () { + for (final e in kBandRegistry) { + final cmp = slotComparisonFor(e); + for (final s in DeviceSlot.values) { + final side = cmp.side(s); + expect(side.doesNotSend, kTableRows.toSet().difference(_keys(side)), + reason: '${e.id} $s'); + } + } + }); + + group('nothing fabricated', () { + test('every claim traces to an eligibility rule in an existing file', () { + var claims = 0; + for (final e in kBandRegistry) { + final cmp = slotComparisonFor(e); + for (final s in DeviceSlot.values) { + for (final c in cmp.side(s).sends.keys) { + claims++; + final t = capabilityTrace(e, c, slot: s); + final why = '${e.id} $s $c'; + expect(t, isNotNull, reason: why); + expect(t!.rule.trim(), isNotEmpty, reason: why); + expect(File(t.source).existsSync(), isTrue, reason: '$why: ${t.source}'); + } + } + } + expect(claims, greaterThan(20), reason: 'vacuity control'); + }); + + test('an every-day claim needs a column or the native WHOOP pipeline', () { + for (final e in kBandRegistry) { + final eligible = + columnFor(e.id) != null || e.id == 'gen4' || e.id == 'gen5'; + if (!eligible) { + expect(slotComparisonFor(e).everyDay.sends, isEmpty, reason: e.id); + } + } + }); + + test('every whole-day capability has a column row', () { + final rows = {for (final e in _columnEntries()) ...columnFor(e.id)!.keys}; + for (final c in _dayRows) { + expect(kCapabilityRow[c], isNotNull, reason: '$c'); + expect(rows, contains(kCapabilityRow[c]), reason: '$c'); + } + }); + }); + + test('every label and reason key the table can show has text in every locale', () { + final keys = {for (final c in kTableRows) kCapabilityLabelKey[c]!}; + for (final e in kBandRegistry) { + final cmp = slotComparisonFor(e); + for (final s in DeviceSlot.values) { + for (final st in cmp.side(s).sends.values) { + if (st.reasonKey != null) keys.add(st.reasonKey!); + } + } + } + expect(keys.length, greaterThan(kTableRows.length + 4), + reason: 'vacuity control: some reason keys were found'); + final arbs = Directory('lib/l10n').listSync().whereType().where( + (f) => RegExp(r'app_\w+\.arb$').hasMatch(f.path)); + expect(arbs.length, 8); + for (final f in arbs) { + final arb = jsonDecode(f.readAsStringSync()) as Map; + final bad = [ + for (final k in keys) + if (arb[k] is! String || (arb[k] as String).trim().isEmpty) k, + ]; + expect(bad, isEmpty, reason: '${f.path}: $bad'); + } + }); +} diff --git a/test/support/app_state_sync_harness.dart b/test/support/app_state_sync_harness.dart index 234cc435e..ceaca3dd8 100644 --- a/test/support/app_state_sync_harness.dart +++ b/test/support/app_state_sync_harness.dart @@ -170,6 +170,9 @@ class SyncFakeEngine extends BleEngine { /// Holds every runSync until completed. Completer? syncGate; + /// Holds every armAlarm reply until completed. + Completer? armGate; + /// Runs inside runSync before it answers (to move the durable frontier). Future Function()? onRunSync; @@ -278,6 +281,7 @@ class SyncFakeEngine extends BleEngine { Future<({DateTime? armed, bool echoed})> armAlarm(DateTime when, {int index = 0, List? haptics}) async { events.add('armAlarm:${when.millisecondsSinceEpoch ~/ 1000}'); + if (armGate != null) await armGate!.future; return (armed: when, echoed: true); } diff --git a/test/ui2_device_slot_card_test.dart b/test/ui2_device_slot_card_test.dart new file mode 100644 index 000000000..7ca98e8eb --- /dev/null +++ b/test/ui2_device_slot_card_test.dart @@ -0,0 +1,249 @@ +// The device slot card and how a paired device reads on the sources list +// and its detail page. +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; +import 'package:openstrap_edge/ble/adapters/_registry.dart'; +import 'package:openstrap_edge/ble/slot_comparison.dart'; +import 'package:openstrap_edge/ui2/pairing/device_slot_card.dart'; +import 'package:openstrap_edge/ui2/profile/devices.dart'; +import 'package:openstrap_edge/ui2/profile/wearable_numbers.dart' show DeviceUseSwitch; + +import 'support/pair_ui_support.dart'; + +HealthSource _src(String family, {String name = 'Polar H10', bool isBand = false}) => + HealthSource( + name: name, + kind: 'Bluetooth heart rate sensor', + tier: SourceTier.beatToBeat, + icon: LucideIcons.heartPulse, + isBand: isBand, + deviceId: '$family-0a1b2c3d', + family: family, + ); + +Widget _card(BandEntry e, DeviceSlot slot) => Scaffold( + body: SingleChildScrollView( + padding: const EdgeInsets.all(16), + child: DeviceSlotCard(entry: e, slot: slot))); + +bool _icon(WidgetTester t, Finder within, IconData icon) => t + .widgetList(find.descendant(of: within, matching: find.byType(Icon))) + .any((i) => i.icon == icon); + +Finder _mark(String side, DeviceCapability c) => + find.byKey(ValueKey('slot-$side-${c.name}')); + +double _opacityOf(WidgetTester t, String side) => t + .widget(find.descendant( + of: find.byKey(ValueKey('slot-cell-$side')).first, + matching: find.byType(Opacity)) + .first) + .opacity; + +void main() { + test('a ring reads as a band does, not as a sensor waiting for a workout', () { + expect(sourceState(_src('oura', name: 'Oura Ring')), 'Not connected'); + expect(sourceState(_src('ble_hrs')), 'Waiting for a workout'); + }); + + group('which sources get the card', () { + test('a strap, a Polar sensor and a ring, not a band, a scale or a Coros watch', () { + expect(slotDeviceOf(_src('ble_hrs'))?.entry.id, 'ble_hrs'); + expect(slotDeviceOf(_src('ble_hrs'))?.slot, DeviceSlot.workoutsOnly); + expect(slotDeviceOf(_src('polar_pmd'))?.entry.id, 'polar_pmd'); + expect(slotDeviceOf(_src('polar_pmd'))?.slot, DeviceSlot.workoutsOnly); + // A columned wearable fills every day. + expect(slotDeviceOf(_src('oura'))?.slot, DeviceSlot.everyDay); + expect(slotDeviceOf(_src('colmi'))?.slot, DeviceSlot.everyDay); + expect(slotDeviceOf(_src('thermometer')), isNull); + expect(slotDeviceOf(_src('miscale2')), isNull); + expect(slotDeviceOf(_src('coros')), isNull); + // The primary band is never a slot device (it is every day by itself). + expect(slotDeviceOf(_src('gen5', isBand: true)), isNull); + expect(sourceSlot(_src('gen5', isBand: true)), DeviceSlot.everyDay); + // The phone has no device row. + const phone = HealthSource( + name: 'This phone', + kind: 'Motion coprocessor', + tier: SourceTier.phone, + icon: Icons.phone_android); + expect(slotDeviceOf(phone), isNull); + expect(sourceSlot(phone), isNull); + }); + }); + + group('DeviceSlotCard', () { + testWidgets('a strap: Workouts only chip, the Every day column faded, the other not', (t) async { + await pumpPair(t, _card(kBleHrs, DeviceSlot.workoutsOnly), size: const Size(412, 1100)); + expect(find.text('What it sends'), findsOneWidget); + final pill = find.byKey(const ValueKey('device-slot-pill')); + expect(find.descendant(of: pill, matching: find.text('Workouts only')), findsOneWidget); + expect(find.descendant(of: pill, matching: find.text('Every day')), findsNothing); + expect(_opacityOf(t, 'everyDay'), 0.28); + expect(_opacityOf(t, 'workoutsOnly'), 1); + }); + + testWidgets('a strap: heart rate and beat timing are ✓ under Workouts only, sleep ✗ in both', (t) async { + await pumpPair(t, _card(kBleHrs, DeviceSlot.workoutsOnly), size: const Size(412, 1100)); + final cmp = slotComparisonFor(kBleHrs); + expect(cmp.workoutsOnly.sends, isNotEmpty); + for (final k in cmp.workoutsOnly.sends.keys) { + expect(_icon(t, _mark('workoutsOnly', k), LucideIcons.check), isTrue, reason: k.name); + } + expect(_icon(t, _mark('workoutsOnly', DeviceCapability.workoutHeartRate), LucideIcons.check), isTrue); + expect(_icon(t, _mark('workoutsOnly', DeviceCapability.workoutBeatToBeat), LucideIcons.check), isTrue); + for (final side in ['everyDay', 'workoutsOnly']) { + expect(_icon(t, _mark(side, DeviceCapability.sleep), LucideIcons.x), isTrue, reason: side); + expect(_icon(t, _mark(side, DeviceCapability.sleep), LucideIcons.check), isFalse, reason: side); + } + expect(find.byIcon(LucideIcons.minus), findsNothing); + }); + + testWidgets('a strap’s note: it names the switch and stands alone; no Experimental word', (t) async { + // WHY: a workout sensor records nothing until the switch is on (default off). + await pumpPair(t, _card(kBleHrs, DeviceSlot.workoutsOnly), size: const Size(412, 1100)); + expect(find.text('Turn on “Use during workouts” to record heart rate while you work out.'), findsOneWidget); + expect(find.textContaining('Experimental'), findsNothing); + expect(find.textContaining('Tier'), findsNothing); + }); + + testWidgets('a strap’s beat timing is conditional on the strap', (t) async { + await pumpPair(t, _card(kBleHrs, DeviceSlot.workoutsOnly), size: const Size(412, 1100)); + expect(find.text('Workouts only: If this device sends it, not confirmed'), findsOneWidget); + }); + + testWidgets('a ring: Every day chip, Workouts only faded, the orange experimental note', (t) async { + await pumpPair(t, _card(kOura, DeviceSlot.everyDay), size: const Size(412, 1400)); + final pill = find.byKey(const ValueKey('device-slot-pill')); + expect(find.descendant(of: pill, matching: find.text('Every day')), findsOneWidget); + expect(_opacityOf(t, 'workoutsOnly'), 0.28); + expect(_opacityOf(t, 'everyDay'), 1); + const note = 'Fills days without your WHOOP. Experimental, so switch it on below.'; + expect(find.text(note), findsOneWidget); + expect(find.text('Turn on “Use during workouts” to record heart rate while you work out.'), findsNothing); + // Orange, not the grey of the strap's note. + final grey = t.widget(find.text(note)).style!.color; + await pumpPair(t, _card(kBleHrs, DeviceSlot.workoutsOnly), size: const Size(412, 1100)); + final strapNote = t.widget(find.text('Turn on “Use during workouts” to record heart rate while you work out.')).style!.color; + expect(grey, isNot(strapNote)); + }); + + testWidgets('a ring sends in the Every day column, nothing in Workouts only', (t) async { + await pumpPair(t, _card(kOura, DeviceSlot.everyDay), size: const Size(412, 1400)); + expect(_icon(t, _mark('everyDay', DeviceCapability.sleep), LucideIcons.check), isTrue); + expect(_icon(t, _mark('workoutsOnly', DeviceCapability.sleep), LucideIcons.x), isTrue); + expect(_icon(t, _mark('workoutsOnly', DeviceCapability.workoutHeartRate), LucideIcons.x), isTrue); + }); + + for (final (e, s) in [ + (kOura, DeviceSlot.everyDay), + (kPolarPmd, DeviceSlot.workoutsOnly), + ]) { + testWidgets('German at 2x text does not overflow (${e.id})', (t) async { + await pumpPair(t, _card(e, s), + locale: const Locale('de'), textScale: 2, size: const Size(360, 2000)); + expect(t.takeException(), isNull); + expect(find.text('Was es sendet'), findsOneWidget); + }); + } + }); + + group('on the sources list', () { + testWidgets('a strap’s row shows its Workouts only chip, no Tier pill, no Experimental word', (t) async { + await pumpPair(t, Scaffold(body: SourceRow(_src('ble_hrs'))), size: const Size(412, 600)); + expect(find.byKey(const ValueKey('source-slot-workoutsOnly')), findsOneWidget); + expect(find.byKey(const ValueKey('source-slot-everyDay')), findsNothing); + expect(find.textContaining('Tier'), findsNothing); + expect(find.text('Experimental'), findsNothing); + expect(find.text('Waiting for a workout'), findsOneWidget); + }); + + testWidgets('a ring’s row shows an Every day chip and no Tier pill', (t) async { + await pumpPair( + t, + Scaffold( + body: SourceRow(HealthSource( + name: 'Oura Ring', + kind: 'Ring', + tier: SourceTier.wristOptical, + icon: Icons.circle, + deviceId: 'oura-1', + family: 'oura'))), + size: const Size(412, 600)); + expect(find.byKey(const ValueKey('source-slot-everyDay')), findsOneWidget); + expect(find.textContaining('Tier'), findsNothing); + expect(find.text('Experimental'), findsNothing); + }); + + testWidgets('the band’s row says Every day', (t) async { + await pumpPair( + t, + const Scaffold( + body: SourceRow(HealthSource( + name: 'WHOOP 5', + kind: 'WHOOP', + tier: SourceTier.wristOptical, + icon: Icons.watch, + isBand: true))), + size: const Size(412, 600)); + expect(find.byKey(const ValueKey('source-slot-everyDay')), findsOneWidget); + }); + + testWidgets('a device with no column (Coros) keeps its Tier pill and has no slot chip', (t) async { + await pumpPair( + t, + const Scaffold( + body: SourceRow(HealthSource( + name: 'Coros', + kind: 'Watch', + tier: SourceTier.wristOptical, + icon: Icons.watch, + deviceId: 'coros-1', + family: 'coros'))), + size: const Size(412, 600)); + expect(find.textContaining('Tier'), findsOneWidget); + expect(find.byKey(const ValueKey('source-slot-everyDay')), findsNothing); + expect(find.byKey(const ValueKey('source-slot-workoutsOnly')), findsNothing); + }); + }); + + group('on its detail page', () { + testWidgets('the card replaces the tier row and the Support row, and the use switch follows it', (t) async { + await pumpPair(t, DeviceDetailView(_src('ble_hrs')), size: const Size(412, 2000)); + expect(find.byKey(const ValueKey('device-slot-card')), findsOneWidget); + expect(find.textContaining('Tier'), findsNothing); + // No Support: Experimental row either. + expect(find.text('Support'), findsNothing); + expect(find.text('Experimental'), findsNothing); + // The switch widget sits right after the card in the page (it draws + // nothing here: no device is registered with WearableDisplay). + final items = t + .widgetList(find.descendant( + of: find.byType(DeviceDetailView), matching: find.byWidgetPredicate((w) => w is DeviceSlotCard || w is DeviceUseSwitch))) + .toList(); + expect(items.map((w) => w.runtimeType), [DeviceSlotCard, DeviceUseSwitch]); + }); + + testWidgets('a ring’s page gets the card and the switch too', (t) async { + await pumpPair(t, DeviceDetailView(_src('oura', name: 'Oura Ring')), size: const Size(412, 2400)); + expect(find.byKey(const ValueKey('device-slot-card')), findsOneWidget); + expect(find.byType(DeviceUseSwitch), findsOneWidget); + expect(find.textContaining('Tier'), findsNothing); + }); + + testWidgets('a band’s page does not get the card', (t) async { + await pumpPair( + t, + DeviceDetailView(const HealthSource( + name: 'WHOOP 5', + kind: 'WHOOP', + tier: SourceTier.wristOptical, + icon: Icons.watch, + isBand: true)), + size: const Size(412, 2000)); + expect(find.byKey(const ValueKey('device-slot-card')), findsNothing); + expect(find.byType(DeviceUseSwitch), findsNothing); + }); + }); +} diff --git a/test/ui2_pair_band_view_test.dart b/test/ui2_pair_band_view_test.dart new file mode 100644 index 000000000..8fd88fd13 --- /dev/null +++ b/test/ui2_pair_band_view_test.dart @@ -0,0 +1,267 @@ +// First-run "Pair your band": the list, the filter pills, the strap-only +// sheet, the always-open Trouble connecting card and the way out. Rendered with fakes. +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; +import 'package:openstrap_edge/ble/adapters/_registry.dart'; +import 'package:openstrap_edge/ui2/community_links.dart'; +import 'package:openstrap_edge/ui2/pairing/pair_band_view.dart'; +import 'package:openstrap_edge/ui2/pairing/pair_help.dart' show PairLinkOpener; +import 'package:openstrap_edge/ui2/pairing/pair_text.dart' show PairFilter; + +import 'support/pair_ui_support.dart'; + +class _Links implements PairLinkOpener { + final opened = []; + @override + Future open(String url) async { + opened.add(url); + return true; + } +} + +class _Host implements PairBandHost { + final void Function(BandEntry) onPick; + final VoidCallback onStrap; + _Host(this.onPick, this.onStrap); + @override + void pickBand(BandEntry entry) => onPick(entry); + @override + void strapOnlyConfirmed() => onStrap(); +} + +Finder _row(BandEntry e) => find.byKey(ValueKey('band-row-${e.id}')); + +void main() { + group('which devices the first run offers', () { + test('only the WHOOP bands', () { + final ids = [for (final e in firstRunBandEntries()) e.id]; + expect(ids, ['gen4', 'gen5']); + // Other bands pair as additional devices from "Add a device"; sensors, + // scales and the thermometer are never a main device. + for (final id in ['oura', 'colmi', 'miband234', 'ultrahuman', 'pebble', 'coros', 'garmin', + 'ble_hrs', 'polar_pmd', 'thermometer', 'miscale_bc', 'miscale2']) { + expect(ids, isNot(contains(id)), reason: id); + } + }); + }); + + group('PairBandView', () { + Widget view({ + List? entries, + ValueChanged? onPick, + VoidCallback? onStrap, + VoidCallback? onSkip, + VoidCallback? onBack, + String? problem, + _Links? links, + }) => + PairBandView( + entries: entries ?? firstRunBandEntries(), + host: _Host(onPick ?? (_) {}, onStrap ?? () {}), + onSkip: onSkip, + onBack: onBack, + problem: problem, + openLink: links ?? _Links(), + ); + + testWidgets('title, subtitle, and one row per device with what it sends', (t) async { + await pumpPair(t, view(), size: const Size(412, 2400)); + expect(find.text('Set up'), findsOneWidget); + expect(find.byKey(const ValueKey('pair-band-title')), findsOneWidget); + expect(find.text('Pair your band'), findsOneWidget); + expect(find.text('Pick the one you wear. We will look for it nearby.'), findsOneWidget); + for (final e in firstRunBandEntries()) { + expect(_row(e), findsOneWidget, reason: e.id); + expect( + find.descendant( + of: _row(e), + matching: find.text('Sleep, recovery, strain, heart rate and more')), + findsOneWidget, + reason: e.id); + } + }); + + + + testWidgets('the WHOOP description is not shown under other devices', (t) async { + await pumpPair(t, view(entries: [kWhoopGen5, kOura, kColmi]), + size: const Size(412, 2400)); + const line = 'Sleep, recovery, strain, heart rate and more'; + expect(find.descendant(of: _row(kWhoopGen5), matching: find.text(line)), + findsOneWidget); + for (final e in [kOura, kColmi]) { + expect(_row(e), findsOneWidget, reason: e.id); + expect(find.descendant(of: _row(e), matching: find.text(line)), + findsNothing, + reason: e.id); + } + }); + + testWidgets('says plainly that only WHOOP is the main band', (t) async { + await pumpPair(t, view(), size: const Size(412, 2400)); + expect(find.byKey(const ValueKey('main-band-whoop-only-note')), findsOneWidget); + expect(find.text('Main band: WHOOP 4.0 or WHOOP 5.0/MG only. Other devices can be added as additional devices.'), findsOneWidget); + }); + + testWidgets('each row carries the Every day chip', (t) async { + await pumpPair(t, view(), size: const Size(412, 2400)); + for (final e in firstRunBandEntries()) { + expect(find.descendant(of: _row(e), matching: find.text('Every day')), findsOneWidget, + reason: e.id); + expect(find.descendant(of: _row(e), matching: find.text('Workouts only')), findsNothing, + reason: e.id); + } + }); + + testWidgets('never says what a band would NOT send, nor primary/secondary/tier', (t) async { + await pumpPair(t, view(), size: const Size(412, 2400)); + for (final w in ['Doesn’t send', 'primary', 'Primary', 'secondary', 'Secondary', 'Tier', 'Experimental']) { + expect(find.textContaining(w), findsNothing, reason: w); + } + }); + + testWidgets('pills show only the groups in the list; Rings narrows it', (t) async { + // The view works for any list; the first run itself offers WHOOP only. + final all = [kWhoopGen5, kOura, kColmi, kUltrahuman, kMiBand234, kPebble]; + await pumpPair(t, view(entries: all), size: const Size(412, 2400)); + for (final k in ['All', 'WHOOP', 'Rings', 'Watches']) { + expect(find.text(k), findsOneWidget, reason: k); + } + expect(find.text('Chest straps & armbands'), findsNothing); + expect(find.text('Bands'), findsNothing); + expect(find.text('Scales'), findsNothing); + await t.tap(find.text('Rings')); + await t.pumpAndSettle(); + expect(_row(kOura), findsOneWidget); + expect(_row(kColmi), findsOneWidget); + expect(_row(kUltrahuman), findsOneWidget); + expect(_row(kWhoopGen5), findsNothing); + expect(_row(kMiBand234), findsNothing); + // The Mi Band is a watch, with the other watches. + await t.tap(find.text('Watches')); + await t.pumpAndSettle(); + expect(_row(kMiBand234), findsOneWidget); + expect(_row(kPebble), findsOneWidget); + expect(_row(kOura), findsNothing); + await t.tap(find.text('All')); + await t.pumpAndSettle(); + expect(_row(kWhoopGen5), findsOneWidget); + }); + + test('the pills’ groups are PairFilter values (WHOOP, rings, watches, straps)', () { + expect(PairFilter.values.map((f) => f.name), ['whoop', 'rings', 'watches', 'straps']); + }); + + testWidgets('tapping a row picks that device', (t) async { + final picked = []; + await pumpPair(t, view(onPick: (e) => picked.add(e.id)), size: const Size(412, 2400)); + await t.tap(_row(kWhoopGen5)); + expect(picked, ['gen5']); + }); + + testWidgets('the strap-only link opens the strap sheet', (t) async { + await pumpPair(t, view(), size: const Size(412, 2400)); + await t.tap(find.text('I only have a heart-rate strap')); + await t.pumpAndSettle(); + expect(find.text('This is a heart-rate sensor'), findsOneWidget); + expect(find.text('Pair Bluetooth heart rate sensor'), findsOneWidget); + expect(find.text('Go back'), findsOneWidget); + expect(find.text('Sleep'), findsWidgets); + }); + + testWidgets('Go back closes the sheet and pairs nothing', (t) async { + var confirmed = 0; + await pumpPair(t, view(onStrap: () => confirmed++), size: const Size(412, 2400)); + await t.tap(find.text('I only have a heart-rate strap')); + await t.pumpAndSettle(); + await t.tap(find.text('Go back')); + await t.pumpAndSettle(); + expect(find.text('This is a heart-rate sensor'), findsNothing); + expect(confirmed, 0); + }); + + testWidgets('Pair closes the sheet and carries on (strapOnlyConfirmed)', (t) async { + var confirmed = 0; + await pumpPair(t, view(onStrap: () => confirmed++), size: const Size(412, 2400)); + await t.tap(find.text('I only have a heart-rate strap')); + await t.pumpAndSettle(); + await t.tap(find.text('Pair Bluetooth heart rate sensor')); + await t.pumpAndSettle(); + expect(find.text('This is a heart-rate sensor'), findsNothing); + expect(confirmed, 1); + }); + + testWidgets('there is no “I can’t pair my band” button, and no dialog anywhere', (t) async { + await pumpPair(t, view(), size: const Size(412, 2400)); + expect(find.text('I can’t pair my band'), findsNothing); + await t.tap(_row(kWhoopGen5)); + await t.pumpAndSettle(); + expect(find.byType(Dialog), findsNothing); + expect(find.text('Need a hand pairing?'), findsNothing); + }); + + testWidgets('the Trouble connecting card is always there, with a link per WHOOP and Discord', (t) async { + final links = _Links(); + await pumpPair(t, view(links: links), size: const Size(412, 2400)); + expect(find.byKey(const ValueKey('trouble-connecting')), findsOneWidget); + expect(find.text('Trouble connecting?'), findsOneWidget); + for (final e in firstRunBandEntries()) { + expect(find.byKey(ValueKey('trouble-link-${e.id}')), findsOneWidget, reason: e.id); + } + await t.tap(find.byKey(const ValueKey('trouble-link-discord'))); + expect(links.opened, [kDiscordUrl]); + }); + + testWidgets('the card stays, unchanged, after trying a device; its links open each model’s page', (t) async { + final links = _Links(); + await pumpPair(t, view(links: links), size: const Size(412, 2400)); + await t.tap(_row(kWhoopGen5)); + await t.pumpAndSettle(); + expect(find.byKey(const ValueKey('trouble-connecting')), findsOneWidget); + await t.tap(find.byKey(ValueKey('trouble-link-${kWhoopGen5.id}'))); + expect(links.opened, [kWhoopGen5.resetSteps!.officialUrl]); + expect(find.byType(Dialog), findsNothing); + }); + + testWidgets('Skip for now shows only when there is something to skip', (t) async { + await pumpPair(t, view(), size: const Size(412, 2400)); + expect(find.text('Skip for now'), findsNothing); + var skipped = 0; + await pumpPair(t, view(onSkip: () => skipped++), size: const Size(412, 2400)); + // The first-run help and comparison chips can put Skip below the fold. + await t.ensureVisible(find.text('Skip for now')); + await t.pumpAndSettle(); + await t.tap(find.text('Skip for now')); + expect(skipped, 1); + }); + + testWidgets('the back chevron goes where the first run says', (t) async { + var back = 0; + await pumpPair(t, view(onBack: () => back++), size: const Size(412, 2400)); + await t.tap(find.byIcon(LucideIcons.chevronLeft)); + expect(back, 1); + }); + + testWidgets('a problem is said in a card', (t) async { + await pumpPair(t, view(problem: 'Bluetooth is off.'), size: const Size(412, 2400)); + expect(find.text('Bluetooth is off.'), findsOneWidget); + // The card is under it, not instead of it. + expect(find.byKey(const ValueKey('trouble-connecting')), findsOneWidget); + }); + + testWidgets('German at 2x text on a small phone does not overflow', (t) async { + await pumpPair(t, view(onSkip: () {}), + locale: const Locale('de'), textScale: 2, size: const Size(320, 700)); + expect(t.takeException(), isNull); + // The retained firmware warning adds substantial height at 2x text. + await t.scrollUntilVisible(find.text('Ich habe nur einen Herzfrequenzgurt'), 200, maxScrolls: 100); + await t.ensureVisible(find.text('Ich habe nur einen Herzfrequenzgurt')); + await t.pumpAndSettle(); + await t.tap(find.text('Ich habe nur einen Herzfrequenzgurt')); + await t.pumpAndSettle(); + expect(find.text('Das ist ein Herzfrequenzsensor'), findsOneWidget); + expect(t.takeException(), isNull); + }); + }); +} diff --git a/test/ui2_pair_device_settings_test.dart b/test/ui2_pair_device_settings_test.dart new file mode 100644 index 000000000..e9f1eb9bb --- /dev/null +++ b/test/ui2_pair_device_settings_test.dart @@ -0,0 +1,408 @@ +// Settings > My sources > "Pair a device": the one "Your band" card (no band, +// a band paired), and what the "Add a device" screen adds (pills, slot chips, +// the paired notice). +import 'package:flutter/material.dart'; +import 'package:flutter_blue_plus/flutter_blue_plus.dart' show BluetoothDevice; +import 'package:flutter_test/flutter_test.dart'; +import 'package:openstrap_edge/ble/adapters/_registry.dart'; +import 'package:openstrap_edge/ble/hrs_link.dart' show BandCandidate; +import 'package:openstrap_edge/state/app_state.dart'; +import 'package:openstrap_edge/ui2/pairing/device_picker.dart'; +import 'package:openstrap_edge/ui2/pairing/pair_text.dart' show PairFilter; +import 'package:openstrap_edge/ui2/profile/devices.dart'; +import 'package:openstrap_edge/ui2/ui2.dart'; + +import 'support/pair_ui_support.dart'; + +HealthSource _band([String name = 'Tyler’s WHOOP 5.0 / MG']) => HealthSource( + name: name, + kind: 'WHOOP', + tier: SourceTier.wristOptical, + icon: Icons.watch, + connected: true, + isBand: true, + ); + +HealthSource _strap() => const HealthSource( + name: 'Polar H10', + kind: 'Bluetooth heart rate sensor', + tier: SourceTier.beatToBeat, + icon: Icons.favorite, + isBand: false, + deviceId: 'ble_hrs-0a1b2c3d', + family: 'ble_hrs', + ); + +BandCandidate _cand(String entryId, + {String id = 'AA:BB:CC:DD:EE:01', String? label, BandEntry? alsoBand}) => + ( + device: BluetoothDevice.fromId(id), + label: label, + rssi: -60, + entryId: entryId, + alsoBand: alsoBand == null ? null : (entry: alsoBand, modelCertain: true), + ); + +void main() { + group('My sources: Pair a device', () { + Widget view(List sources, + {VoidCallback? onPair, VoidCallback? onAdd, VoidCallback? onUnpair}) => + MyDevicesView( + sources: sources, + onPair: onPair, + onAddSensor: onAdd, + onUnpair: onUnpair); + + Finder inCard(String key, Finder f) => + find.descendant(of: find.byKey(ValueKey(key)), matching: f); + + testWidgets('no band: ONE Your band card says so, says WHOOP only, and Pair your band opens the band flow', (t) async { + var pair = 0; + await pumpPair(t, view(const [], onPair: () => pair++, onAdd: () {}), + size: const Size(412, 1400)); + expect(find.text('Pair a device'), findsOneWidget); + expect(find.byKey(const ValueKey('pair-band-card')), findsOneWidget); + expect(find.byKey(const ValueKey('band-paired-card')), findsNothing); + expect(inCard('pair-band-card', find.text('Your band')), findsOneWidget); + expect(inCard('pair-band-card', find.text('Every day')), findsOneWidget); + expect(inCard('pair-band-card', find.byKey(const ValueKey('your-band-status'))), + findsOneWidget); + expect(inCard('pair-band-card', find.text('No band is paired')), findsOneWidget); + expect( + inCard('pair-band-card', + find.text('WHOOP 4.0 or WHOOP 5.0/MG only. Sleep, recovery and strain, around the clock.')), + findsOneWidget); + expect(find.byKey(const ValueKey('main-band-whoop-only-note')), findsOneWidget); + final button = inCard('pair-band-card', find.byType(BigButton)); + expect(button, findsOneWidget); + expect(find.descendant(of: button, matching: find.text('Pair your band')), findsOneWidget); + await t.tap(button); + expect(pair, 1); + expect(find.text('Unpair band'), findsNothing); + }); + + testWidgets('no band: no separate “No band is paired” status card above the Your band card', (t) async { + // WHY: the owner's rule is ONE card; a second one said the same thing twice. + await pumpPair(t, view(const [], onPair: () {}, onAdd: () {}), size: const Size(412, 1400)); + expect(find.text('No band is paired'), findsOneWidget); + expect(find.text('Nothing is measuring yet'), findsNothing); + expect(find.byType(StatusCard), findsNothing); + expect(find.text('Pair a band'), findsNothing); + // One button for the band; the Add a device row is not a BigButton. + expect(find.byType(BigButton), findsOneWidget); + }); + + testWidgets('no band: the same card says what that costs, once', (t) async { + // WHY: one card, but it must still say that every metric abstains; the + // WHOOP-only line alone never told a person their data was empty. + const phone = HealthSource( + name: 'This phone', + kind: 'Motion coprocessor', + tier: SourceTier.phone, + icon: Icons.smartphone, + connected: false, + ); + await pumpPair(t, view(const [phone], onPair: () {}, onAdd: () {}), + size: const Size(412, 1400)); + expect( + inCard('pair-band-card', find.byKey(const ValueKey('no-band-consequence'))), + findsOneWidget); + expect(find.textContaining('every metric in the app will abstain'), findsOneWidget); + expect(find.textContaining('The phone counts steps and nothing else'), findsNothing); + }); + + testWidgets('no band, phone steps arriving: says only the phone counts steps', (t) async { + const phone = HealthSource( + name: 'This phone', + kind: 'Motion coprocessor', + tier: SourceTier.phone, + icon: Icons.smartphone, + connected: true, + ); + await pumpPair(t, view(const [phone], onPair: () {}, onAdd: () {}), + size: const Size(412, 1400)); + expect(find.textContaining('The phone counts steps and nothing else'), findsOneWidget); + expect(find.textContaining('every metric in the app will abstain'), findsNothing); + }); + + testWidgets('no band, a connected ring: does not say every metric abstains', (t) async { + // WHY: an active ring fills the everyday columns; telling the user that + // heart rate, sleep and recovery abstain would contradict their own data. + const ring = HealthSource( + name: 'Oura Ring', + kind: 'Ring', + tier: SourceTier.wristOptical, + icon: Icons.circle, + connected: true, + deviceId: 'oura-1', + family: 'oura', + ); + await pumpPair(t, view(const [ring], onPair: () {}, onAdd: () {}), + size: const Size(412, 1400)); + expect(find.byKey(const ValueKey('no-band-consequence')), findsNothing); + expect(find.textContaining('every metric in the app will abstain'), findsNothing); + expect(find.textContaining('The phone counts steps and nothing else'), findsNothing); + }); + + testWidgets('no band, a connected chest strap: is not mistaken for phone steps', (t) async { + // WHY: phoneCounting used to be true for ANY connected non-band source. + const strap = HealthSource( + name: 'Chest strap', + kind: 'Heart-rate strap', + tier: SourceTier.beatToBeat, + icon: Icons.favorite, + connected: true, + deviceId: 'hrs-1', + family: 'ble_hrs', + ); + await pumpPair(t, view(const [strap], onPair: () {}, onAdd: () {}), + size: const Size(412, 1400)); + expect(find.textContaining('The phone counts steps and nothing else'), findsNothing); + expect(find.textContaining('every metric in the app will abstain'), findsOneWidget); + }); + + testWidgets('a paired band: no consequence line', (t) async { + await pumpPair(t, view([_band()], onUnpair: () {}), size: const Size(412, 1400)); + expect(find.byKey(const ValueKey('no-band-consequence')), findsNothing); + }); + + testWidgets('“Add a device” is its own row, below the band card', (t) async { + var add = 0; + await pumpPair(t, view(const [], onPair: () {}, onAdd: () => add++), size: const Size(412, 1400)); + expect(find.descendant(of: find.byKey(const ValueKey('pair-band-card')), matching: find.text('Add a device')), + findsNothing); + expect(find.text('Rings, watches and heart-rate straps'), findsOneWidget); + expect(t.getTopLeft(find.text('Add a device')).dy, + greaterThan(t.getBottomLeft(find.byKey(const ValueKey('pair-band-card'))).dy)); + await t.tap(find.text('Add a device')); + expect(add, 1); + }); + + testWidgets('the WHOOP-only line is in the card with no band; a paired band has no such line', (t) async { + await pumpPair(t, view(const [], onPair: () {}, onAdd: () {}), size: const Size(412, 1400)); + expect(find.byKey(const ValueKey('main-band-whoop-only-note')), findsOneWidget); + await pumpPair(t, view([_band()], onUnpair: () {}, onAdd: () {}), size: const Size(412, 1400)); + expect(find.byKey(const ValueKey('main-band-whoop-only-note')), findsNothing); + }); + + testWidgets('the old “Add a sensor” row is gone', (t) async { + await pumpPair(t, view(const [], onPair: () {}, onAdd: () {}), size: const Size(412, 1400)); + expect(find.text('Add a sensor'), findsNothing); + }); + + testWidgets('a paired strap is not a band: still the Your band card, no band', (t) async { + await pumpPair(t, view([_strap()], onPair: () {}, onAdd: () {}), size: const Size(412, 1400)); + expect(find.byKey(const ValueKey('pair-band-card')), findsOneWidget); + expect(find.byKey(const ValueKey('band-paired-card')), findsNothing); + }); + + testWidgets('a band paired: the same card names it, shows its state, offers Unpair band; Add a device stays', (t) async { + var unpair = 0, add = 0; + await pumpPair(t, view([_band()], onPair: () {}, onAdd: () => add++, onUnpair: () => unpair++), + size: const Size(412, 1400)); + expect(find.byKey(const ValueKey('pair-band-card')), findsNothing); + final card = find.byKey(const ValueKey('band-paired-card')); + expect(card, findsOneWidget); + expect(inCard('band-paired-card', find.text('Your band')), findsOneWidget); + expect(inCard('band-paired-card', find.text('Every day')), findsOneWidget); + expect( + t.widget(inCard('band-paired-card', find.byKey(const ValueKey('your-band-status')))).data, + 'Tyler’s WHOOP 5.0 / MG'); + expect(inCard('band-paired-card', find.text('Connected')), findsOneWidget); + // None of the old copy. + expect(find.text('Paired'), findsNothing); + expect(find.textContaining('You already have a band paired'), findsNothing); + expect(find.text('No band is paired'), findsNothing); + expect(find.byKey(const ValueKey('main-band-whoop-only-note')), findsNothing); + expect(find.text('Pair your band'), findsNothing); + await t.tap(inCard('band-paired-card', find.text('Unpair band'))); + expect(unpair, 1); + await t.tap(find.text('Add a device')); + expect(add, 1); + }); + + testWidgets('Unpair band is tinted red, soft, not a filled button', (t) async { + await pumpPair(t, view([_band()], onUnpair: () {}), size: const Size(412, 1400)); + final button = t.widget(find.byType(BigButton)); + expect(button.color, C.red); + expect(button.soft, isTrue); + expect(find.text('Unpair band'), findsOneWidget); + }); + + testWidgets('Pair your band is the filled one', (t) async { + await pumpPair(t, view(const [], onPair: () {}), size: const Size(412, 1400)); + expect(t.widget(find.byType(BigButton)).soft, isFalse); + }); + + testWidgets('no callbacks, no band: no Pair a device section at all', (t) async { + await pumpPair(t, const MyDevicesView(), size: const Size(412, 1400)); + expect(find.text('Pair a device'), findsNothing); + expect(find.byKey(const ValueKey('pair-band-card')), findsNothing); + }); + + testWidgets('the forget flow asks first, and Keep it paired changes nothing', (t) async { + final app = AppState(); + addTearDown(app.dispose); + await pumpPair( + t, + Builder( + builder: (c) => Scaffold( + body: TextButton( + onPressed: () => debugConfirmForgetBand(c, app, 'Tyler’s WHOOP'), + child: const Text('go')))), + size: const Size(412, 900)); + await t.tap(find.text('go')); + await t.pumpAndSettle(); + expect(find.text('Forget Tyler’s WHOOP?'), findsOneWidget); + await t.tap(find.text('Keep it paired')); + await t.pumpAndSettle(); + expect(find.text('Forget Tyler’s WHOOP?'), findsNothing); + }); + + testWidgets('German at 2x text does not overflow, in either state', (t) async { + for (final (sources, card) in [ + (const [], 'pair-band-card'), + ([_band()], 'band-paired-card'), + ]) { + await pumpPair(t, view(sources, onPair: () {}, onAdd: () {}, onUnpair: () {}), + locale: const Locale('de'), textScale: 2, size: const Size(360, 1800)); + final ex = t.takeException(); + expect(ex, isNull, reason: ex is FlutterError ? ex.toStringDeep() : '$ex'); + expect(find.byKey(ValueKey(card)), findsOneWidget); + } + }); + }); + + group('Add a device (the unified scan screen)', () { + DevicePickerView view({ + List found = const [], + List<({BandEntry entry, String blurb, IconData icon})> categories = const [], + ValueNotifier? kindSelection, + String? notice, + ValueChanged? onPick, + }) => + DevicePickerView( + query: TextEditingController(), + title: 'Add a device', + subtitle: 'Scan once.', + found: found, + categories: categories, + kindSelection: kindSelection ?? ValueNotifier(null), + notice: notice, + onPickNearby: onPick, + ); + + testWidgets('a WHOOP heard as a strap gets the Every day chip, read off the band; a plain strap Workouts only', (t) async { + await pumpPair( + t, + view(found: [ + _cand('ble_hrs', label: 'Jordan’s WHOOP', alsoBand: kWhoopGen5, id: 'AA:01'), + _cand('ble_hrs', label: 'Polar H10', id: 'AA:02'), + ]), + size: const Size(412, 1400)); + expect(find.text('This is a band'), findsNothing); + // Both candidates are ble_hrs rows; the chip under each is its own. + final chips = find.byKey(const ValueKey('row-slot-ble_hrs')); + expect(find.byKey(ValueKey('row-slot-${kWhoopGen5.id}')), findsOneWidget); + expect(find.descendant(of: find.byKey(ValueKey('row-slot-${kWhoopGen5.id}')), matching: find.text('Every day')), + findsOneWidget); + expect(chips, findsOneWidget); + expect(find.descendant(of: chips, matching: find.text('Workouts only')), findsOneWidget); + }); + + testWidgets('a ring that is nearby gets the Every day chip', (t) async { + await pumpPair(t, view(found: [_cand('oura', label: 'Oura Ring')]), size: const Size(412, 1400)); + expect(find.descendant(of: find.byKey(const ValueKey('row-slot-oura')), matching: find.text('Every day')), + findsOneWidget); + expect(find.text('This is a band'), findsNothing); + }); + + testWidgets('a device that fits neither column (Coros) gets no chip', (t) async { + await pumpPair(t, view(found: [_cand('coros', label: 'Coros')]), size: const Size(412, 1400)); + expect(find.byKey(const ValueKey('row-slot-coros')), findsNothing); + }); + + testWidgets('Browse rows carry the chip too', (t) async { + await pumpPair( + t, + view(categories: [ + (entry: kOura, blurb: 'ring blurb', icon: Icons.circle), + (entry: kBleHrs, blurb: 'strap blurb', icon: Icons.favorite), + ]), + size: const Size(412, 1400)); + expect(find.descendant(of: find.byKey(const ValueKey('row-slot-oura')), matching: find.text('Every day')), + findsOneWidget); + expect(find.descendant(of: find.byKey(const ValueKey('row-slot-ble_hrs')), matching: find.text('Workouts only')), + findsOneWidget); + }); + + testWidgets('pills cover the found devices and the browse list; Rings narrows both', (t) async { + final kind = ValueNotifier(null); + Widget harness() => ValueListenableBuilder( + valueListenable: kind, + builder: (_, _, _) => view( + kindSelection: kind, + found: [ + _cand('oura', label: 'Oura Ring', id: 'AA:01'), + _cand('ble_hrs', label: 'Polar H10', id: 'AA:02'), + _cand('polar_pmd', label: 'Polar Verity Sense', id: 'AA:03'), + ], + categories: [ + (entry: kOura, blurb: 'ring blurb', icon: Icons.circle), + (entry: kBleHrs, blurb: 'strap blurb', icon: Icons.favorite), + (entry: kPolarPmd, blurb: 'armband blurb', icon: Icons.favorite), + ])); + await pumpPair(t, harness(), size: const Size(412, 1400)); + expect(find.text('Rings'), findsOneWidget); + expect(find.text('Chest straps & armbands'), findsOneWidget); + await t.tap(find.text('Rings')); + await t.pumpAndSettle(); + expect(kind.value, PairFilter.rings); + expect(find.text('Polar H10'), findsNothing); + expect(find.text('Polar Verity Sense'), findsNothing); + expect(find.text('armband blurb'), findsNothing); + expect(find.text('Oura Ring'), findsWidgets); + expect(find.text('strap blurb'), findsNothing); + expect(find.text('ring blurb'), findsOneWidget); + }); + + testWidgets('(CR r1) a kind the search emptied out filters nothing', (t) async { + // WHY: with one kind left the pills hide, "All" with them; a stale + // selection then hid every row with no control to clear it. + final kind = ValueNotifier(PairFilter.rings); + await pumpPair( + t, + view(kindSelection: kind, found: [ + _cand('ble_hrs', label: 'Polar H10', id: 'AA:02'), + ]), + size: const Size(412, 1400)); + expect(find.text('All'), findsNothing); + expect(find.text('Polar H10'), findsWidgets); + }); + + testWidgets('no pills when onKind is not supplied (the old screen is unchanged)', (t) async { + await pumpPair( + t, + DevicePickerView( + query: TextEditingController(), + title: 't', + subtitle: 's', + found: [_cand('oura', label: 'Oura Ring'), _cand('ble_hrs', label: 'Polar H10', id: 'AA:02')]), + size: const Size(412, 1400)); + expect(find.text('All'), findsNothing); + }); + + testWidgets('after a workouts-only device pairs: “Paired for workouts only.”', (t) async { + await pumpPair(t, view(notice: 'Paired for workouts only.'), size: const Size(412, 1400)); + expect(find.text('Paired for workouts only.'), findsOneWidget); + }); + + testWidgets('tapping a nearby row hands the candidate over', (t) async { + final got = []; + await pumpPair(t, view(found: [_cand('ble_hrs', label: 'Polar H10')], onPick: (c) => got.add(c.entryId)), + size: const Size(412, 1400)); + await t.tap(find.text('Polar H10')); + expect(got, ['ble_hrs']); + }); + }); +} diff --git a/test/ui2_pair_sheets_test.dart b/test/ui2_pair_sheets_test.dart index 91fd54812..3ef340039 100644 --- a/test/ui2_pair_sheets_test.dart +++ b/test/ui2_pair_sheets_test.dart @@ -16,10 +16,12 @@ import 'package:openstrap_edge/l10n/app_localizations.dart'; import 'package:openstrap_edge/ui2/pairing/device_picker.dart' show DevicePickerView; import 'package:openstrap_edge/ui2/pairing/pair_text.dart' show PairFilter; import 'package:openstrap_edge/ui2/profile/pair_sensor.dart' show afterBandFoundText; +import 'package:openstrap_edge/ble/slot_comparison.dart'; import 'package:openstrap_edge/ui2/pairing/pair_choice_sheet.dart'; import 'package:openstrap_edge/ui2/pairing/pair_sheets.dart'; import 'support/pair_ui_support.dart'; +import 'package:openstrap_edge/ui2/pairing/slot_comparison_view.dart'; BandCandidate _cand(String entryId, {String id = 'AA:BB:CC:DD:EE:01', String? label, BandEntry? alsoBand}) => @@ -155,6 +157,84 @@ void main() { return got; } + testWidgets('pairing mode is up front: WHOOP 5’s steps, above the main button', (t) async { + await open(t, kWhoopGen5, hasMain: false); + expect(find.text('Put it in pairing mode'), findsOneWidget); + final step = t.getTopLeft(find.byKey(const ValueKey('pairing-mode-step-gen5-1'))).dy; + expect(step, lessThan(t.getTopLeft(find.text('Pair it as my band')).dy)); + expect(step, greaterThan(t.getTopLeft(find.byType(SlotTable)).dy)); + }); + + testWidgets('the table: every day sends sleep, workouts only does not; no dashes', (t) async { + await open(t, kWhoopGen5, hasMain: false); + expect(t.getSemantics(find.byKey(const ValueKey('slot-everyDay-sleep'))).label, 'Sleep, Every day: Sends'); + expect(t.getSemantics(find.byKey(const ValueKey('slot-workoutsOnly-sleep'))).label, 'Sleep, Workouts only: Doesn’t send'); + expect(t.getSemantics(find.byKey(const ValueKey('slot-workoutsOnly-workoutHeartRate'))).label, 'Heart rate during workouts, Workouts only: Sends'); + expect(find.byIcon(LucideIcons.minus), findsNothing); + expect(find.text('Workouts only: If this device sends it, not confirmed'), findsOneWidget); + expect(find.text('Blood oxygen'), findsNothing); + }); + + testWidgets('the sheet washes the Every day column, not Workouts only', (t) async { + await open(t, kWhoopGen5, hasMain: false); + Color? colour(String slot) => (t + .widget(find + .descendant( + of: find.byKey(const ValueKey('slot-row-sleep')), + matching: find.byKey(ValueKey('slot-cell-$slot'))) + .first) + .color); + expect(colour('everyDay'), isNotNull); + expect(colour('workoutsOnly'), isNull); + }); + + testWidgets('a ring fills every day: the ring’s rows with their captions, and the experimental note', (t) async { + await open(t, kOura, hasMain: false); + expect(find.text('This is a ring'), findsOneWidget); + expect(find.text('It can fill your days with sleep, recovery and heart rate.'), findsOneWidget); + expect(t.getSemantics(find.byKey(const ValueKey('slot-everyDay-sleep'))).label, 'Sleep, Every day: Sends. From the ring’s own sleep stages'); + expect(t.getSemantics(find.byKey(const ValueKey('slot-workoutsOnly-sleep'))).label, 'Sleep, Workouts only: Doesn’t send'); + expect(t.getSemantics(find.byKey(const ValueKey('slot-everyDay-strain'))).label, 'Strain, Every day: Doesn’t send'); + expect(find.text('Every day: From the ring’s own sleep stages'), findsOneWidget); + expect(find.text('Every day: Estimated for the first 14 nights'), findsOneWidget); + expect(find.text('Every day: Provisional estimate; needs a few nights'), findsOneWidget); + expect(find.text('Fills days without your WHOOP. Experimental, so switch it on in Devices.'), findsOneWidget); + expect(find.text('Pair Oura Ring'), findsOneWidget); + expect(find.text('Pair it as my band'), findsNothing); + }); + + testWidgets('a heart-rate strap: workouts only, the switch note, and Pair', (t) async { + await pumpPair(t, Builder(builder: (c) => Scaffold(body: TextButton( + onPressed: () => showStrapSheet(c, sensor: kBleHrs), + child: const Text('open')))), size: const Size(412, 2000)); + await t.tap(find.text('open')); + await t.pumpAndSettle(); + expect(find.text('This is a heart-rate sensor'), findsOneWidget); + expect(find.text('It adds heart rate while you work out. It does not record sleep, recovery or daily strain.'), findsOneWidget); + expect(find.text('Turn on “Use during workouts” to record heart rate while you work out.'), findsOneWidget); + expect(find.text('Workouts only: If this device sends it, not confirmed'), findsOneWidget); + expect(find.text('Pair Bluetooth heart rate sensor'), findsOneWidget); + expect(find.text('Go back'), findsOneWidget); + expect(t.getSemantics(find.byKey(const ValueKey('slot-everyDay-sleep'))).label, 'Sleep, Every day: Doesn’t send'); + expect(t.getSemantics(find.byKey(const ValueKey('slot-everyDay-workoutHeartRate'))).label, 'Heart rate during workouts, Every day: Doesn’t send'); + expect(t.getSemantics(find.byKey(const ValueKey('slot-workoutsOnly-workoutHeartRate'))).label, 'Heart rate during workouts, Workouts only: Sends'); + }); + + testWidgets('the confirm fits in German at 2x text', (t) async { + await pumpPair( + t, + Builder( + builder: (c) => Scaffold( + body: TextButton( + onPressed: () => showReplaceBandConfirm(c, + mainBandName: 'Jordans WHOOP'), + child: const Text('open')))), + locale: const Locale('de'), textScale: 2, size: const Size(360, 800)); + await t.tap(find.text('open')); + await t.pumpAndSettle(); + expect(t.takeException(), isNull); + expect(find.byType(SlotTable), findsNothing); + }); testWidgets('no main band yet: pair it as my band, or use it for workouts only', (t) async { await open(t, kWhoopGen5, hasMain: false); expect(find.text('This is a WHOOP band'), findsOneWidget); @@ -660,8 +740,11 @@ void main() { final calls = _Calls()..bandFlowResult = BandFlowResult.pairedWearable; await _tap(t, calls, _cand('oura', label: 'Oura Ring')); expect(find.text('This is a ring'), findsOneWidget); - // Not a WHOOP, so there is no main-band choice (DT12): one button. + // Not a WHOOP, so there is no main-band choice: one button. expect(find.text('Pair it as my band'), findsNothing); + // The comparison table and unverified guidance can put this below the fold. + await t.ensureVisible(find.text('Pair Oura Ring')); + await t.pumpAndSettle(); await t.tap(find.text('Pair Oura Ring')); await t.pumpAndSettle(); // The ring needs its own key screen, so it never pairs from here. @@ -679,6 +762,9 @@ void main() { final calls = _Calls(); await _tap(t, calls, ouraAsStrap); expect(find.text('This is a ring'), findsOneWidget); + // The comparison table and unverified guidance can put this below the fold. + await t.ensureVisible(find.text('Pair Oura Ring')); + await t.pumpAndSettle(); await t.tap(find.text('Pair Oura Ring')); await t.pumpAndSettle(); expect(calls.pairs, isEmpty); @@ -691,6 +777,9 @@ void main() { await _tap(t, calls, _cand('ble_hrs', label: 'HRM'), hasMain: true); await t.ensureVisible(find.text('Pair Oura Ring')); await t.pumpAndSettle(); + // The comparison table and unverified guidance can put this below the fold. + await t.ensureVisible(find.text('Pair Oura Ring')); + await t.pumpAndSettle(); await t.tap(find.text('Pair Oura Ring')); await t.pumpAndSettle(); expect(calls.pairs.length, 1, reason: 'only the first connect'); @@ -770,7 +859,7 @@ void main() { }); }); - group('G3 r1 S2: browsing goes through the same confirmations', () { + group('browsing goes through the same confirmations', () { // A button that runs confirmBrowse and prints the answer. Future browse(WidgetTester t, _Calls calls, BandEntry e, {required bool hasMain, String? tapLabel}) async { @@ -958,7 +1047,7 @@ void main() { }); } - group('G3 r1 S3: the handoff to the main-band flow', () { + group('the handoff to the main-band flow', () { final whoopOnly = _cand('gen5', label: 'WHOOP 5A1B'); testWidgets('the scan is stopped BEFORE the main-band flow opens', (t) async { @@ -981,7 +1070,7 @@ void main() { }); }); - group('G3 r1 S4: a WHOOP-only advertisement', () { + group('a WHOOP-only advertisement', () { testWidgets('the band-choice flow runs for a scanned framed entry; a secondary choice pairs under ble_hrs with the confirmation', (t) async { final calls = _Calls(); await _tap(t, calls, _cand('gen5', label: 'WHOOP 5A1B'), hasMain: true); @@ -1008,6 +1097,9 @@ void main() { deviceIcon: LucideIcons.watch, deviceName: 'A band', title: 'Pair this band', + comparison: const SlotComparison( + everyDay: SlotSide(sends: {}, doesNotSend: {}), + workoutsOnly: SlotSide(sends: {}, doesNotSend: {})), lead: List.filled(40, 'A long instruction line.').join(' '), primaryLabel: 'Pair', backLabel: 'Back', diff --git a/test/ui2_pairing_blocks_test.dart b/test/ui2_pairing_blocks_test.dart new file mode 100644 index 000000000..d9cfbfd91 --- /dev/null +++ b/test/ui2_pairing_blocks_test.dart @@ -0,0 +1,422 @@ +// The two swappable pairing building blocks: the capability matrix and +// the category filter pills, plus the registry field the pills read. +// Rendered, not read: both are layout. +import 'dart:convert'; +import 'dart:io'; +import 'dart:ui' show Tristate; + +import 'package:flutter/material.dart'; +import 'package:flutter/semantics.dart' show SemanticsNode; +import 'package:flutter_test/flutter_test.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; +import 'package:openstrap_edge/ble/adapters/_registry.dart'; +import 'package:openstrap_edge/ble/slot_comparison.dart'; +import 'package:openstrap_edge/ui2/pairing/category_filter_pills.dart'; +import 'package:openstrap_edge/ui2/ui2.dart' show S; +import 'package:openstrap_edge/ui2/pairing/pair_text.dart'; +import 'package:openstrap_edge/ui2/pairing/slot_comparison_view.dart'; + +import 'support/pair_ui_support.dart'; + +Finder _mark(String side, DeviceCapability c) => + find.byKey(ValueKey('slot-$side-${c.name}')); + +bool _hasIcon(WidgetTester t, Finder mark, IconData icon) => t + .widgetList(find.descendant(of: mark, matching: find.byType(Icon))) + .any((i) => i.icon == icon); + +bool _sel(SemanticsNode n) => n.getSemanticsData().flagsCollection.isSelected == Tristate.isTrue; + +void main() { + group('BandEntry.kind', () { + test('only generic HRS leaves physical placement unknown', () { + // WHY: HRS can be a watch, armband or strap; named devices retain their kinds. + final other = [ + for (final e in kBandRegistry) + if (e.kind == DeviceKind.other) e.id + ]; + expect(other, ['ble_hrs']); + }); + + test('the kinds the owner named', () { + expect(kWhoopGen4.kind, DeviceKind.strap); + expect(kWhoopGen5.kind, DeviceKind.strap); + expect(kOura.kind, DeviceKind.ring); + expect(kColmi.kind, DeviceKind.ring); + expect(kUltrahuman.kind, DeviceKind.ring); + expect(kGarmin.kind, DeviceKind.watch); + expect(kMiBand234.kind, DeviceKind.band); + expect(kBleHrs.kind, DeviceKind.other); + expect(kThermometer.kind, DeviceKind.thermometer); + expect(kMiScale2.kind, DeviceKind.scale); + }); + }); + + group('CategoryFilterPills', () { + Widget pills(List kinds, + {PairFilter? selected, ValueNotifier? selection}) => + Scaffold( + body: CategoryFilterPills( + kinds: kinds, + selection: selection ?? ValueNotifier(selected)), + ); + + testWidgets('all five filters keep reading order when the strap label wraps', + (t) async { + await pumpPair( + t, + pills([ + DeviceKind.chestStrap, + DeviceKind.watch, + DeviceKind.ring, + DeviceKind.strap, + ]), + size: const Size(600, 800)); + // The fuller strap label can wrap to the next line. Pin reading order + // in both dimensions, so wrapping does not masquerade as reordering. + final positions = [ + for (final k in ['All', 'WHOOP', 'Rings', 'Watches', 'Chest straps & armbands']) + t.getTopLeft(find.text(k)), + ]; + final readingOrder = [...positions]..sort((a, b) { + final row = a.dy.compareTo(b.dy); + return row == 0 ? a.dx.compareTo(b.dx) : row; + }); + expect(positions, readingOrder); + expect(positions.toSet().length, 5); + }); + + testWidgets('only the groups that have entries get a pill', (t) async { + await pumpPair(t, pills([DeviceKind.ring, DeviceKind.strap, DeviceKind.ring])); + expect(find.text('All'), findsOneWidget); + expect(find.text('WHOOP'), findsOneWidget); + expect(find.text('Rings'), findsOneWidget); + expect(find.text('Watches'), findsNothing); + expect(find.text('Chest straps & armbands'), findsNothing); + }); + + testWidgets('a Mi Band (DeviceKind.band) is under Watches, not a pill of its own', + (t) async { + await pumpPair(t, pills([DeviceKind.ring, DeviceKind.band])); + expect(find.text('Watches'), findsOneWidget); + expect(find.text('Bands'), findsNothing); + expect(pairFilterOf(DeviceKind.band), PairFilter.watches); + expect(pairFilterOf(DeviceKind.watch), PairFilter.watches); + }); + + testWidgets('a scale shows under All only: it earns no pill', (t) async { + await pumpPair(t, pills([DeviceKind.scale, DeviceKind.thermometer])); + expect(find.text('All'), findsNothing); + expect(pairFilterOf(DeviceKind.scale), isNull); + expect(pairFilterOf(DeviceKind.thermometer), isNull); + // With a ring beside it the scale still adds no pill. + await pumpPair(t, pills([DeviceKind.scale, DeviceKind.ring, DeviceKind.watch])); + expect(find.text('All'), findsOneWidget); + expect(find.text('Rings'), findsOneWidget); + expect(find.text('Watches'), findsOneWidget); + expect(find.byType(CategoryFilterPills), findsOneWidget); + }); + + test('every kind maps to its group', () { + expect(pairFilterOf(DeviceKind.strap), PairFilter.whoop); + expect(pairFilterOf(DeviceKind.ring), PairFilter.rings); + expect(pairFilterOf(DeviceKind.chestStrap), PairFilter.straps); + expect(pairFilterOf(DeviceKind.armband), PairFilter.straps); + expect(pairFilterOf(DeviceKind.other), isNull); + }); + + testWidgets('a list with a single group shows no pills at all', (t) async { + await pumpPair(t, pills([DeviceKind.ring, DeviceKind.ring])); + expect(find.text('All'), findsNothing); + expect(find.text('Rings'), findsNothing); + }); + + testWidgets('tapping a pill reports its group; All reports null', (t) async { + final got = []; + final sel = ValueNotifier(PairFilter.rings); + sel.addListener(() => got.add(sel.value)); + await pumpPair(t, pills([DeviceKind.ring, DeviceKind.watch], selection: sel)); + await t.tap(find.text('Watches')); + await t.tap(find.text('All')); + expect(got, [PairFilter.watches, null]); + }); + + testWidgets('the selected pill is marked selected for screen readers, the rest are not', + (t) async { + await pumpPair( + t, pills([DeviceKind.ring, DeviceKind.watch], selected: PairFilter.rings)); + final s = t.getSemantics(find.byKey(const ValueKey('pill-rings'))); + expect(_sel(s), isTrue); + final o = t.getSemantics(find.byKey(const ValueKey('pill-watches'))); + expect(_sel(o), isFalse); + }); + + testWidgets('nothing selected means All is the selected pill', (t) async { + await pumpPair(t, pills([DeviceKind.ring, DeviceKind.watch])); + expect(_sel(t.getSemantics(find.byKey(const ValueKey('pill-all')))), isTrue); + }); + + testWidgets('labels follow the locale', (t) async { + await pumpPair(t, pills([DeviceKind.ring, DeviceKind.watch]), + locale: const Locale('de')); + expect(find.text('Alle'), findsOneWidget); + expect(find.text('Ringe'), findsOneWidget); + expect(find.text('Uhren'), findsOneWidget); + }); + + testWidgets('five groups wrap instead of overflowing at 2x text on a narrow phone', + (t) async { + await pumpPair( + t, + pills([ + DeviceKind.strap, + DeviceKind.ring, + DeviceKind.watch, + DeviceKind.chestStrap + ]), + textScale: 2, + size: const Size(320, 700)); + expect(t.takeException(), isNull); + }); + + test('filterByGroup keeps only that group, null keeps all', () { + final all = [kWhoopGen5, kOura, kColmi, kMiBand234, kBleHrs, kPolarPmd, kMiScale2]; + expect(filterByGroup(all, null), all); + expect(filterByGroup(all, PairFilter.rings), [kOura, kColmi]); + expect(filterByGroup(all, PairFilter.whoop), [kWhoopGen5]); + expect(filterByGroup(all, PairFilter.watches), [kMiBand234]); + expect(filterByGroup(all, PairFilter.straps), [kPolarPmd]); + }); + }); + + group('slot rows (pure)', () { + final whoop = slotComparisonFor(kWhoopGen5); + final strap = slotComparisonFor(kBleHrs); + + test('every comparison lists the whole table, in order, and never blood oxygen', () { + for (final c in [whoop, strap, slotComparisonFor(kOura), slotComparisonFor(kCoros)]) { + expect([for (final r in slotRowsFor(c)) r.capability], [ + DeviceCapability.sleep, + DeviceCapability.recovery, + DeviceCapability.strain, + DeviceCapability.heartRate, + DeviceCapability.hrv, + DeviceCapability.respiration, + DeviceCapability.skinTemperature, + DeviceCapability.steps, + DeviceCapability.workoutHeartRate, + DeviceCapability.workoutBeatToBeat, + ]); + } + }); + + test('a WHOOP sends every day and, read as a strap, during workouts', () { + final rows = {for (final r in slotRowsFor(whoop)) r.capability: r}; + expect(rows[DeviceCapability.sleep]!.everyDay, isNotNull); + expect(rows[DeviceCapability.sleep]!.workouts, isNull); + expect(rows[DeviceCapability.workoutHeartRate]!.everyDay, isNotNull); + expect(rows[DeviceCapability.workoutHeartRate]!.workouts, isNotNull); + }); + + test('skin temperature keeps its condition', () { + final r = slotRowsFor(whoop) + .firstWhere((r) => r.capability == DeviceCapability.skinTemperature); + expect(r.everyDay!.kind, CapabilityKind.conditional); + expect(r.everyDay!.reasonKey, kReasonSkinTempNights); + }); + + test('a strap alone sends nothing every day: its rows are its workout lines plus the gaps', () { + final rows = {for (final r in slotRowsFor(strap)) r.capability: r}; + // WHOOP: "Doesn't send" must stay visible for what a workout sensor lacks. + expect(rows[DeviceCapability.sleep]!.workouts, isNull); + expect(rows[DeviceCapability.sleep]!.everyDay, isNull); + expect(rows[DeviceCapability.workoutHeartRate]!.workouts, isNotNull); + expect(rows[DeviceCapability.workoutHeartRate]!.everyDay, isNull); + }); + }); + + group('SlotTable', () { + Widget table(SlotComparison c, {DeviceSlot? focus, DeviceSlot? dim}) => + Scaffold( + body: SingleChildScrollView( + child: SlotTable(comparison: c, focus: focus, dim: dim))); + + const rowNames = [ + 'Sleep', + 'Recovery', + 'Strain', + 'Heart rate and resting heart rate', + 'Heart-rate variability', + 'Respiration', + 'Skin temperature', + 'Steps', + 'Heart rate during workouts', + 'Beat-to-beat timing during workouts', + ]; + + testWidgets('every row is drawn, under the two column heads', (t) async { + await pumpPair(t, table(slotComparisonFor(kWhoopGen5))); + expect(find.text('Every day'), findsOneWidget); + expect(find.text('Workouts only'), findsOneWidget); + expect(find.byKey(const ValueKey('slot-head-everyDay')), findsOneWidget); + expect(find.byKey(const ValueKey('slot-head-workoutsOnly')), findsOneWidget); + for (final c in kTableRows) { + expect(find.byKey(ValueKey('slot-row-${c.name}')), findsOneWidget, reason: c.name); + } + for (final n in rowNames) { + expect(find.text(n), findsOneWidget, reason: n); + } + // The workout rows name themselves; there is no group row. + expect(find.text('DURING WORKOUTS'), findsNothing); + expect(find.text('During workouts'), findsNothing); + }); + + testWidgets('the header leaves room above the column icons', (t) async { + await pumpPair(t, table(slotComparisonFor(kWhoopGen5))); + final top = t.getTopLeft(find.byType(SlotTable)).dy; + final icon = t.getTopLeft(find.descendant( + of: find.byKey(const ValueKey('slot-cell-everyDay')).first, + matching: find.byType(Icon))) + .dy; + // Was 1 px (the table's border) before the owner asked for room. + expect(icon - top, greaterThanOrEqualTo(S.x3)); + }); + + testWidgets('blood oxygen is never a row', (t) async { + await pumpPair(t, table(slotComparisonFor(kWhoopGen5))); + expect(find.byKey(const ValueKey('slot-row-bloodOxygen')), findsNothing); + expect(find.text('Blood oxygen'), findsNothing); + }); + + testWidgets('the workout rows come last, after Steps', (t) async { + await pumpPair(t, table(slotComparisonFor(kWhoopGen5))); + final steps = t.getTopLeft(find.text('Steps')).dy; + expect(t.getTopLeft(find.text('Heart rate during workouts')).dy, greaterThan(steps)); + expect(t.getTopLeft(find.text('Beat-to-beat timing during workouts')).dy, + greaterThan(t.getTopLeft(find.text('Heart rate during workouts')).dy)); + }); + + testWidgets('a check in the column that sends, a cross in the one that does not', (t) async { + await pumpPair(t, table(slotComparisonFor(kWhoopGen5))); + expect(_hasIcon(t, _mark('everyDay', DeviceCapability.sleep), LucideIcons.check), isTrue); + expect(_hasIcon(t, _mark('workoutsOnly', DeviceCapability.sleep), LucideIcons.x), isTrue); + expect(_hasIcon(t, _mark('workoutsOnly', DeviceCapability.sleep), LucideIcons.check), isFalse); + expect(_hasIcon(t, _mark('everyDay', DeviceCapability.sleep), LucideIcons.x), isFalse); + // A WHOOP kept for workouts sends heart rate in both columns. + expect(_hasIcon(t, _mark('workoutsOnly', DeviceCapability.workoutHeartRate), LucideIcons.check), isTrue); + }); + + testWidgets('a heart-rate strap crosses the whole-day column out', (t) async { + await pumpPair(t, table(slotComparisonFor(kBleHrs))); + for (final c in kDayCapabilities) { + expect(_hasIcon(t, _mark('everyDay', c), LucideIcons.x), isTrue, reason: c.name); + expect(_hasIcon(t, _mark('workoutsOnly', c), LucideIcons.x), isTrue, reason: c.name); + } + expect(_hasIcon(t, _mark('workoutsOnly', DeviceCapability.workoutHeartRate), LucideIcons.check), isTrue); + expect(_hasIcon(t, _mark('everyDay', DeviceCapability.workoutHeartRate), LucideIcons.x), isTrue); + }); + + testWidgets('no dash anywhere: a "no" is a cross', (t) async { + for (final e in [kWhoopGen5, kBleHrs, kOura, kCoros]) { + await pumpPair(t, table(slotComparisonFor(e))); + expect(find.byIcon(LucideIcons.minus), findsNothing, reason: e.id); + } + }); + + testWidgets('marks name the capability, column and sends status to a screen reader', (t) async { + await pumpPair(t, table(slotComparisonFor(kWhoopGen5))); + expect(t.getSemantics(_mark('everyDay', DeviceCapability.sleep)).label, 'Sleep, Every day: Sends'); + expect(t.getSemantics(_mark('workoutsOnly', DeviceCapability.sleep)).label, 'Sleep, Workouts only: Doesn’t send'); + }); + + testWidgets('a conditional capability shows its caption under the label', (t) async { + await pumpPair(t, table(slotComparisonFor(kWhoopGen5))); + expect(find.text('Every day: After a few nights'), findsOneWidget); + // Read as a workout sensor, a WHOOP's beat timing is conditional too. + expect(find.text('Workouts only: If this device sends it, not confirmed'), findsOneWidget); + // WHOOP 5 counts steps natively: no live-session caption. + expect(find.text('Every day: During live sessions'), findsNothing); + // The caption sits under its label, in the same row. + final row = find.byKey(const ValueKey('slot-row-skinTemperature')); + expect(find.descendant(of: row, matching: find.text('Skin temperature')), findsOneWidget); + expect(find.descendant(of: row, matching: find.text('Every day: After a few nights')), findsOneWidget); + expect(t.getTopLeft(find.text('Every day: After a few nights')).dy, + greaterThan(t.getTopLeft(find.text('Skin temperature')).dy)); + }); + + testWidgets('a strap says its beat timing is only if it sends it', (t) async { + await pumpPair(t, table(slotComparisonFor(kBleHrs))); + expect(find.text('Workouts only: If this device sends it, not confirmed'), findsOneWidget); + }); + + testWidgets('a ring’s captions: its own sleep stages and the first 14 nights', (t) async { + await pumpPair(t, table(slotComparisonFor(kOura))); + expect(find.text('Every day: From the ring’s own sleep stages'), findsOneWidget); + expect(find.text('Every day: Estimated for the first 14 nights'), findsOneWidget); + }); + + testWidgets('a vendor-reported value says so instead of looking native', (t) async { + await pumpPair( + t, + const Scaffold( + body: SingleChildScrollView( + child: SlotTable( + comparison: SlotComparison( + everyDay: SlotSide(sends: { + DeviceCapability.sleep: + CapabilityStatus(CapabilityKind.vendorReported) + }, doesNotSend: {}), + workoutsOnly: SlotSide(sends: {}, doesNotSend: {DeviceCapability.sleep})))))); + expect(find.text('Every day: The device’s own reading'), findsOneWidget); + }); + + testWidgets('focus washes only that column', (t) async { + Color? colorOf(String s) => t + .widget(find.byKey(ValueKey('slot-cell-$s')).first) + .color; + await pumpPair(t, table(slotComparisonFor(kBleHrs), focus: DeviceSlot.workoutsOnly)); + expect(colorOf('workoutsOnly'), isNotNull); + expect(colorOf('everyDay'), isNull); + await pumpPair(t, table(slotComparisonFor(kOura), focus: DeviceSlot.everyDay)); + expect(colorOf('everyDay'), isNotNull); + expect(colorOf('workoutsOnly'), isNull); + await pumpPair(t, table(slotComparisonFor(kOura))); + expect(colorOf('everyDay'), isNull); + expect(colorOf('workoutsOnly'), isNull); + }); + + testWidgets('dim fades only the other column (Opacity 0.28)', (t) async { + double opacityIn(String s) => t + .widget(find.descendant( + of: find.byKey(ValueKey('slot-cell-$s')).first, + matching: find.byType(Opacity)) + .first) + .opacity; + await pumpPair(t, table(slotComparisonFor(kBleHrs), dim: DeviceSlot.everyDay)); + expect(opacityIn('everyDay'), 0.28); + expect(opacityIn('workoutsOnly'), 1); + await pumpPair(t, table(slotComparisonFor(kOura), dim: DeviceSlot.workoutsOnly)); + expect(opacityIn('workoutsOnly'), 0.28); + expect(opacityIn('everyDay'), 1); + }); + + test('the WHOOP-only strings exist, non-blank, in every locale', () { + for (final f in Directory('lib/l10n').listSync().whereType().where((f) => RegExp(r'app_\w+\.arb$').hasMatch(f.path))) { + final arb = jsonDecode(f.readAsStringSync()) as Map; + for (final k in ['pairMainBandWhoopOnly']) { + expect(arb[k], isA(), reason: '${f.path} $k'); + expect((arb[k] as String).trim(), isNotEmpty, reason: '${f.path} $k'); + } + } + }); + + testWidgets('German heads and rows render without overflow at 2x text', (t) async { + for (final e in [kWhoopGen5, kBleHrs, kOura]) { + await pumpPair(t, table(slotComparisonFor(e), focus: DeviceSlot.everyDay, dim: DeviceSlot.workoutsOnly), + locale: const Locale('de'), textScale: 2, size: const Size(360, 900)); + expect(t.takeException(), isNull, reason: e.id); + expect(find.text('Schlaf'), findsOneWidget); + } + }); + }); +} diff --git a/test/ui2_pairing_review_test.dart b/test/ui2_pairing_review_test.dart new file mode 100644 index 000000000..5ffc5bfd4 --- /dev/null +++ b/test/ui2_pairing_review_test.dart @@ -0,0 +1,296 @@ +// PR #669 review regressions: exercise the rendered sheets, recovery screens, +// table and device details, rather than just their copy helpers. +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:openstrap_edge/ble/adapters/_registry.dart'; +import 'package:openstrap_edge/ble/slot_comparison.dart'; +import 'package:openstrap_edge/l10n/app_localizations.dart'; +import 'package:openstrap_edge/ui2/onboarding/pairing.dart'; +import 'package:openstrap_edge/ui2/pairing/pair_help.dart'; +import 'package:openstrap_edge/ui2/pairing/pair_sheets.dart'; +import 'package:openstrap_edge/ui2/pairing/pair_text.dart'; +import 'package:openstrap_edge/ui2/pairing/slot_comparison_view.dart'; +import 'package:openstrap_edge/ui2/profile/devices.dart'; + +import 'support/pair_ui_support.dart'; + +const _ouraKey = 'Already use the Oura app? Keep the ring in that app and pair with its existing key. Skip the reset steps below. Only reset it if you want a new key.'; +const _pebbleLead = 'Pebble 2 can fill your days with sleep and heart rate. Pebble 2 SE shows the watch’s own sleep and steps. It has no heart-rate sensor, so this app cannot calculate daily strain or estimate recovery from it.'; +const _strapLead = 'It adds heart rate while you work out. It does not record sleep, recovery or daily strain.'; + +Future _openBand(WidgetTester t, BandEntry entry) async { + await pumpPair(t, Builder(builder: (c) => Scaffold(body: TextButton( + onPressed: () => showBandFoundSheet(c, band: entry, hasMainBand: false), + child: const Text('open')))), size: const Size(412, 2400)); + await t.tap(find.text('open')); + await t.pumpAndSettle(); +} + +void _expectKeyBeforeReset(WidgetTester t) { + final guidance = find.text(_ouraKey); + expect(guidance, findsOneWidget); + final reset = find.text('Open the maker’s app and remove this device from it.'); + expect(reset, findsOneWidget, reason: 'new-key reset path stays available'); + expect(t.getTopLeft(guidance).dy, lessThan(t.getTopLeft(reset).dy)); +} + +void main() { + // WHY: synthetic-night calibration stays provisional after the minimum nights. + // catches: replacing the provisional warning with only a waiting period. + for (final ring in [kOura, kColmi, kUltrahuman]) { + testWidgets('${ring.id} skin temperature retains its provisional warning', (t) async { + await _openBand(t, ring); + final row = find.byKey(const ValueKey('slot-row-skinTemperature')); + expect(find.descendant(of: row, matching: find.text( + 'Every day: Provisional estimate; needs a few nights')), findsOneWidget); + expect(t.getSemantics(find.byKey(const ValueKey('slot-everyDay-skinTemperature'))).label, + contains('Provisional estimate; needs a few nights')); + }); + } + + // WHY: a name-only WHOOP could have either generation's step acquisition. + // catches: using the representative's live-only or stored-counter claim. + for (final representative in [kWhoopGen4, kWhoopGen5]) { + testWidgets('unknown WHOOP steps stay unconfirmed (${representative.id})', (t) async { + await pumpPair(t, Builder(builder: (c) => Scaffold(body: TextButton( + onPressed: () => showBandFoundSheet(c, band: representative, + hasMainBand: false, modelKnown: false), + child: const Text('open')))), size: const Size(412, 2400)); + await t.tap(find.text('open')); + await t.pumpAndSettle(); + final l = lookupAppLocalizations(const Locale('en')); + final row = find.byKey(const ValueKey('slot-row-steps')); + expect(find.descendant(of: row, matching: find.text( + l.slotColumnReason(l.slotEveryDay, l.capReasonUnconfirmed))), findsOneWidget); + expect(t.getSemantics(find.byKey(const ValueKey('slot-everyDay-steps'))).label, + contains(l.capReasonUnconfirmed)); + expect(find.text('WHOOP 4'), findsNothing); + expect(find.text('WHOOP 5'), findsNothing); + }); + } + + testWidgets('Oura sheet preserves the existing key before reset steps', (t) async { + await _openBand(t, kOura); + _expectKeyBeforeReset(t); + }); + + testWidgets('Oura trouble card preserves the existing key before reset steps', (t) async { + await pumpPair(t, Scaffold(body: SingleChildScrollView( + child: TroubleConnectingCard(entries: [kOura]))), + size: const Size(412, 2400)); + _expectKeyBeforeReset(t); + }); + + testWidgets('Oura bond-refused screen preserves the existing key before reset steps', (t) async { + await pumpPair(t, PairingView(phase: PairPhase.bondRefused, + onPair: () {}, resetEntry: kOura), size: const Size(412, 2400)); + _expectKeyBeforeReset(t); + expect(find.text('In your phone’s Bluetooth settings, find the device and choose Forget.'), + findsOneWidget); + }); + + testWidgets('Pebble lead keeps HR for Pebble 2 and excludes it for SE', (t) async { + await _openBand(t, kPebble); + expect(find.text(_pebbleLead), findsOneWidget); + expect(find.text('It can fill your days with sleep, recovery and heart rate.'), findsNothing); + }); + + testWidgets('Pebble HR captions qualify every affected row and its accessible mark', (t) async { + await _openBand(t, kPebble); + const only = 'Pebble 2 only. The 2 SE has no heart-rate sensor.'; + for (final (cap, reason) in [ + (DeviceCapability.recovery, 'Pebble 2 only, and an estimate, not a ' + 'direct reading. The 2 SE has no heart-rate sensor.'), + (DeviceCapability.strain, only), + (DeviceCapability.heartRate, only), + ]) { + final row = find.byKey(ValueKey('slot-row-${cap.name}')); + expect(find.descendant(of: row, matching: find.text('Every day: $reason')), + findsOneWidget, reason: '${cap.name} must exclude SE'); + final l = lookupAppLocalizations(const Locale('en')); + expect(t.getSemantics(find.byKey(ValueKey('slot-everyDay-${cap.name}'))).label, + '${capabilityLabel(l, cap)}, Every day: Sends. $reason'); + } + final sleep = find.byKey(const ValueKey('slot-row-sleep')); + expect(find.descendant(of: sleep, matching: find.text( + 'Every day: From the device’s own sleep stages')), findsOneWidget); + final steps = find.byKey(const ValueKey('slot-row-steps')); + expect(find.descendant(of: steps, matching: find.text( + 'Every day: The device’s own reading')), findsOneWidget); + }); + + testWidgets('strap lead excludes daily strain precisely', (t) async { + await pumpPair(t, Builder(builder: (c) => Scaffold(body: TextButton( + onPressed: () => showStrapSheet(c, sensor: kBleHrs), + child: const Text('open')))), size: const Size(412, 2400)); + await t.tap(find.text('open')); + await t.pumpAndSettle(); + expect(find.text(_strapLead), findsOneWidget); + }); + + test('Russian replacement says connect first and retain the old pairing on cancellation', () { + // WHY: the old copy described forgetting first, which could strand the user. + final l = lookupAppLocalizations(const Locale('ru')); + expect(l.pairReplaceConfirmTitle('WHOOP').toLowerCase(), contains('после подключения')); + expect(l.pairReplaceBand('WHOOP').toLowerCase(), contains('затем отключить')); + expect(l.pairReplaceConfirmBody.toLowerCase(), contains('останется сопряжённым')); + expect(l.pairReplaceConfirmBody.toLowerCase(), contains('отмените')); + }); + + test('Russian unpair explicitly removes the pairing', () { + // WHY: disconnecting a radio link does not remove its saved pairing. + final l = lookupAppLocalizations(const Locale('ru')); + expect(l.pairUnpairBand.toLowerCase(), contains('сопряжени')); + expect(l.pairUnpairBand.toLowerCase(), isNot(contains('отключ'))); + }); + + test('Thai strap filter names chest straps and armbands', () { + final l = lookupAppLocalizations(const Locale('th')); + expect(l.pairKindStrap, contains('คาดอก')); + expect(l.pairKindStrap, contains('ต้นแขน')); + }); + + testWidgets('WHOOP unconfirmed beat timing caption names only Workouts only', (t) async { + await pumpPair(t, Scaffold(body: SingleChildScrollView( + child: SlotTable(comparison: slotComparisonFor(kWhoopGen5)))), + size: const Size(412, 2000)); + final row = find.byKey(const ValueKey('slot-row-workoutBeatToBeat')); + expect(find.descendant(of: row, matching: find.text( + 'Workouts only: If this device sends it, not confirmed')), findsOneWidget); + expect(find.descendant(of: row, matching: find.text( + 'Every day: If this device sends it, not confirmed')), findsNothing); + }); + + testWidgets('different reasons in both columns remain associated with each column', (t) async { + await pumpPair(t, const Scaffold(body: SingleChildScrollView( + child: SlotTable(comparison: SlotComparison( + everyDay: SlotSide(sends: {DeviceCapability.sleep: + CapabilityStatus(CapabilityKind.vendorReported)}, doesNotSend: {}), + workoutsOnly: SlotSide(sends: {DeviceCapability.sleep: + CapabilityStatus(CapabilityKind.conditional, reasonKey: kReasonUnconfirmed)}, + doesNotSend: {}), + )))), size: const Size(412, 2000)); + final row = find.byKey(const ValueKey('slot-row-sleep')); + expect(find.descendant(of: row, matching: find.text( + 'Every day: The device’s own reading')), findsOneWidget); + expect(find.descendant(of: row, matching: find.text( + 'Workouts only: If this device sends it, not confirmed')), findsOneWidget); + }); + + testWidgets('each table mark announces its capability, column and status', (t) async { + await pumpPair(t, Scaffold(body: SingleChildScrollView( + child: SlotTable(comparison: slotComparisonFor(kWhoopGen5)))), + size: const Size(412, 2000)); + for (final (key, label) in [ + ('slot-everyDay-sleep', 'Sleep, Every day: Sends'), + ('slot-workoutsOnly-sleep', 'Sleep, Workouts only: Doesn’t send'), + ('slot-everyDay-workoutBeatToBeat', 'Beat-to-beat timing during workouts, Every day: Sends'), + ('slot-workoutsOnly-workoutBeatToBeat', 'Beat-to-beat timing during workouts, Workouts only: Sends. If this device sends it, not confirmed'), + ]) { + expect(t.getSemantics(find.byKey(ValueKey(key))).label, label, reason: key); + } + }); + + for (final family in ['colmi', 'oura']) { + testWidgets('$family detail uses its every-day description without workout-only copy', (t) async { + final l = lookupAppLocalizations(const Locale('en')); + await pumpPair(t, DeviceDetailView(HealthSource(name: family, kind: 'Ring', + tier: SourceTier.beatToBeat, icon: Icons.circle, isBand: false, + deviceId: '$family-test', family: family)), size: const Size(412, 2400)); + expect(find.text(l.pairWearableCardNote), findsOneWidget, + reason: 'the every-day card explains its role'); + expect(find.text(l.devicesWhatItDoesBeats), findsNothing); + }); + } + + testWidgets('workout strap detail retains the workout description', (t) async { + final l = lookupAppLocalizations(const Locale('en')); + await pumpPair(t, const DeviceDetailView(HealthSource(name: 'Strap', kind: 'Strap', + tier: SourceTier.beatToBeat, icon: Icons.favorite, isBand: false, + deviceId: 'ble_hrs-test', family: 'ble_hrs')), size: const Size(412, 2400)); + expect(find.text(l.devicesWhatItDoesBeats), findsOneWidget); + }); + + test('every Pebble locale names the SE limits and watch-reported readings', () { + const copy = { + 'en': ('Pebble 2 only. The 2 SE has no heart-rate sensor.', + 'Pebble 2 SE shows the watch’s own sleep and steps. It has no heart-rate sensor, so this app cannot calculate daily strain or estimate recovery from it.'), + 'de': ('Nur Pebble 2. Die 2 SE hat keinen Herzfrequenzsensor.', + 'Pebble 2 SE zeigt die eigenen Schlaf- und Schrittdaten der Uhr. Sie hat keinen Herzfrequenzsensor, daher kann diese App daraus weder die tägliche Belastung berechnen noch die Erholung schätzen.'), + 'es': ('Solo Pebble 2. El 2 SE no tiene sensor de frecuencia cardiaca.', + 'Pebble 2 SE muestra el sueño y los pasos registrados por el propio reloj. No tiene sensor de frecuencia cardiaca, por lo que esta app no puede calcular la carga diaria ni estimar la recuperación a partir de sus datos.'), + 'fr': ('Pebble 2 uniquement. La 2 SE n’a pas de capteur de fréquence cardiaque.', + 'Pebble 2 SE affiche le sommeil et les pas enregistrés par la montre. Elle n’a pas de capteur de fréquence cardiaque, donc cette app ne peut pas calculer la charge quotidienne ni estimer la récupération à partir de ses données.'), + 'hi': ('केवल Pebble 2। 2 SE में हृदय गति सेंसर नहीं है।', + 'Pebble 2 SE घड़ी की अपनी नींद और कदमों की रीडिंग दिखाता है। उसमें हृदय गति सेंसर नहीं है, इसलिए यह ऐप उसके डेटा से रोज़ का शारीरिक भार नहीं निकाल सकता और न ही रिकवरी का अनुमान लगा सकता है।'), + 'ru': ('Только Pebble 2. У 2 SE нет датчика пульса.', + 'Pebble 2 SE показывает сон и шаги по данным самих часов. У него нет датчика пульса, поэтому приложение не может рассчитать дневную нагрузку или оценить восстановление по его данным.'), + 'th': ('เฉพาะ Pebble 2 รุ่น 2 SE ไม่มีเซ็นเซอร์วัดอัตราการเต้นของหัวใจ', + 'Pebble 2 SE แสดงข้อมูลการนอนและจำนวนก้าวที่นาฬิกาบันทึกเอง รุ่นนี้ไม่มีเซ็นเซอร์วัดอัตราการเต้นของหัวใจ แอปจึงคำนวณภาระร่างกายรายวันหรือประเมินการฟื้นตัวจากข้อมูลของรุ่นนี้ไม่ได้'), + 'zh': ('仅限 Pebble 2。2 SE 没有心率传感器。', + 'Pebble 2 SE 显示手表自身记录的睡眠和步数。它没有心率传感器,因此本应用无法根据它的数据计算每日身体负荷或估算恢复。'), + }; + expect(AppLocalizations.supportedLocales.map((l) => l.languageCode).toSet(), + copy.keys.toSet()); + for (final entry in copy.entries) { + final l = lookupAppLocalizations(Locale(entry.key)); + expect(capabilityReason(l, const CapabilityStatus(CapabilityKind.conditional, + reasonKey: 'capReasonPebble2Only')), entry.value.$1, reason: entry.key); + expect(l.pairWearableLeadPebble, endsWith(entry.value.$2), reason: entry.key); + // Recovery is also an estimate on Pebble 2: its caption keeps both. + final both = capabilityReason(l, const CapabilityStatus( + CapabilityKind.conditional, reasonKey: kReasonPebble2OnlyEstimated))!; + expect(both.toLowerCase(), contains(l.capReasonEstimated.toLowerCase()), + reason: entry.key); + expect(both, contains('2 SE'), reason: entry.key); + } + }); + + for (final locale in AppLocalizations.supportedLocales) { + testWidgets('Pebble conditions render and are announced in $locale at 2x text', (t) async { + final l = lookupAppLocalizations(locale); + String reason(String key) => capabilityReason(l, + CapabilityStatus(CapabilityKind.conditional, reasonKey: key))!; + await pumpPair(t, Scaffold(body: SingleChildScrollView( + child: SlotTable(comparison: slotComparisonFor(kPebble)))), + locale: locale, textScale: 2, size: const Size(360, 900)); + for (final (cap, key) in [ + (DeviceCapability.recovery, kReasonPebble2OnlyEstimated), + (DeviceCapability.strain, kReasonPebble2Only), + (DeviceCapability.heartRate, kReasonPebble2Only), + ]) { + final row = find.byKey(ValueKey('slot-row-${cap.name}')); + expect(find.descendant(of: row, matching: find.text( + l.slotColumnReason(l.slotEveryDay, reason(key)))), findsOneWidget); + final mark = find.byKey(ValueKey('slot-everyDay-${cap.name}')); + await t.ensureVisible(mark); + await t.pumpAndSettle(); + expect(t.getSemantics(mark).label, contains(reason(key))); + } + expect(t.takeException(), isNull); + }); + } + + test('every conditional mark in every locale has its caption', () { + // A check whose condition has no caption would claim more than the device + // gives. Every registry entry, both columns, every shipped locale. + var seen = 0; + for (final locale in AppLocalizations.supportedLocales) { + final l = lookupAppLocalizations(locale); + for (final e in kBandRegistry) { + final cmp = slotComparisonFor(e); + for (final side in [cmp.everyDay, cmp.workoutsOnly]) { + for (final MapEntry(key: cap, value: st) in side.sends.entries) { + if (st.kind != CapabilityKind.conditional) continue; + seen++; + final caption = capabilityReason(l, st); + expect(caption, isNotNull, + reason: '${e.id} $cap ${st.reasonKey} in $locale has no caption'); + expect(caption!.trim(), isNotEmpty); + } + } + } + } + expect(seen, greaterThan(0), reason: 'the registry has conditional marks'); + }); +} diff --git a/test/ui2_router_test.dart b/test/ui2_router_test.dart index 9f3ad78be..0a382ba8d 100644 --- a/test/ui2_router_test.dart +++ b/test/ui2_router_test.dart @@ -519,8 +519,15 @@ void main() { sources: [band(connected: false)], status: bandStatusFor(connection: 'disconnected')), )); - // Exactly one "Not connected": the row. No card repeating it. - expect(find.text('Not connected'), findsOneWidget); + // No failure card. "Not connected" is said by the row and by the + // "Your band" card's state line, never by a StatusCard. + expect(find.byType(StatusCard), findsNothing); + expect(find.text('Not connected'), findsNWidgets(2)); + expect( + find.descendant( + of: find.byKey(const ValueKey('band-paired-card')), + matching: find.text('Not connected')), + findsOneWidget); }); }); @@ -549,8 +556,8 @@ void main() { child: MaterialApp( theme: buildTheme(Brightness.light), home: const MyDevices()), )); - expect(find.text('Your band'), findsOneWidget); - expect(find.text('Pair a band'), findsNothing); + expect(find.byKey(const ValueKey('band-paired-card')), findsOneWidget); + expect(find.text('Pair your band'), findsNothing); // Forget. `unpair()` itself is platform-bound (ASK, the engine, the // foreground service); what it leaves behind for this screen is this. @@ -558,10 +565,15 @@ void main() { app.notifyListeners(); await tester.pump(); - expect(find.text('Your band'), findsNothing); + // The band's row is gone; the one "Your band" left is the card's + // heading, now saying so and offering the way back. + expect(find.byKey(const ValueKey('band-paired-card')), findsNothing); + expect(find.text('Your band'), findsOneWidget); + expect(find.text('No band is paired'), findsOneWidget); + expect(find.widgetWithText(BigButton, 'Pair your band'), findsOneWidget); expect(find.text('This phone'), findsOneWidget, reason: 'the phone row is what used to swallow the empty state'); - expect(find.text('Pair a band'), findsOneWidget); + expect(find.byKey(const ValueKey('pair-band-card')), findsOneWidget); }); testWidgets('and for someone who only ever had the phone', (tester) async { @@ -581,7 +593,7 @@ void main() { onPair: () => pairs++, ), )); - await tester.tap(find.text('Pair a band')); + await tester.tap(find.widgetWithText(BigButton, 'Pair your band')); expect(pairs, 1); }); @@ -622,7 +634,7 @@ void main() { isBand: true), ], onPair: () {}), )); - expect(find.text('Pair a band'), findsNothing); + expect(find.text('Pair your band'), findsNothing); }); }); diff --git a/test/ui2_tokens_test.dart b/test/ui2_tokens_test.dart index 1a39100ca..308423c6c 100644 --- a/test/ui2_tokens_test.dart +++ b/test/ui2_tokens_test.dart @@ -275,10 +275,18 @@ const _notComponents = { // `start_session_card_test.dart`, which renders it at a real phone width and // asserts the copy is not truncated and nothing overflows. 'StartCard', - // Pairing pieces are exercised on routes by the pairing widget tests. - 'PairNote', 'CategoryFilterPills', 'PairChoiceSheet', - // Pairing pieces are exercised on routes by the pairing widget tests. - 'TroubleConnectingCard', 'ResetStepsView', 'PairingModeSection', 'PairStepRow', 'TextLinkButton', 'ChoiceRow', + // The pairing screens' building blocks (lib/ui2/pairing): each is one + // swappable piece of a pairing screen, driven by registry data and pumped, + // state by state, by ui2_pairing_blocks_test.dart, + // ui2_pairing_help_reset_test.dart, ui2_pair_band_view_test.dart and + // ui2_device_slot_card_test.dart. A + // gallery cell is too narrow for the slot table and the sheets, and the + // sheets open over a route. + 'SlotTable', 'SlotMark', 'PairNote', 'CategoryFilterPills', + 'TroubleConnectingCard', 'ResetStepsView', 'PairingModeSection', + 'PairBandView', + 'PairChoiceSheet', 'PairStepRow', 'TextLinkButton', 'ChoiceRow', + 'DeviceSlotCard', // tabs and drill-downs 'HomeScreen', 'HealthScreen', 'WorkoutScreen', 'NutritionScreen', 'WellnessScreen', 'CycleTab', 'MetricDetail', 'ReadinessDetail',