mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-21 23:02:20 +01:00
Two defects that each defeated the alarm in a different way:
1. Nothing finished AlarmActivity after a correct answer. Sound stopped and
the alarm re-armed, but the dismiss screen stayed up over the lockscreen
forever — back is disabled in both halves by design — and the live instance
kept _inRoom=true with the solved answer still typed, so the next ring
could reuse an already-passed gate. AlarmActivity now handles
closeRingScreen; the shared AlarmChannel deliberately holds
applicationContext and cannot finish an activity, hence the split handler.
2. Nothing could write roomProof.nfcTagId — there was no registration UI — so
checkNfc always answered "no tag registered" and checkQr was never called.
Functionally that left steps as the only satisfiable proof, which is
exactly the state the decision rules out ("NFC or QR qualifies; steps alone
does NOT") and removes the redundancy whose purpose is that one failing
mechanism at 06:00 must never block dismissal. Added RoomProofScreen
(reader mode from MainActivity, since registration needs an Activity) and
linked it from Settings.
Also: StepCounter kept one listener instead of registering a fresh one per
ring and never unregistering, and the ring screen drops its NFC handler on
dispose.
New tests cover what had been dead code: a registered tag satisfies the proof
and reveals the challenge, a foreign tag does not, and a correct answer
invokes BOTH dismiss and closeRingScreen. The emulator cannot reach the
dismiss path at all (no step sensor, no NFC), which is why it is covered by
widget tests rather than claimed from the AVD run.
Documented ringNow/main_ring_probe.dart in AGENTS.md as a deliberate manual
test handle, the phone-side equivalent of wake-alarm.service.
flutter test: 69 pass. dart analyze lib/ test/: clean. pre-commit: passed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EckWmyfetYq3Mi8MAnUudh
69 lines
2.7 KiB
Dart
69 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:sync_settings_ui/sync_settings_ui.dart';
|
|
|
|
import 'package:wake_alarm_sync/screens/github_mirror_screen.dart';
|
|
import 'package:wake_alarm_sync/screens/room_proof_screen.dart';
|
|
import 'package:wake_alarm_sync/services/firebase_backend.dart';
|
|
import 'package:wake_alarm_sync/services/google_sign_in_backend.dart';
|
|
|
|
/// Settings screen: links to the two sync surfaces.
|
|
///
|
|
/// "Sync settings" is the shared `sync_settings_ui` package (Firebase,
|
|
/// identical in shape to every other kuhy app's Sync settings screen).
|
|
/// "Advanced sync (GitHub)" stays app-local ([GitHubMirrorScreen]), and
|
|
/// "Room proof" registers the NFC tag / QR code ([RoomProofScreen]) — without
|
|
/// a registered tag, NFC can never satisfy the dismiss room proof.
|
|
class SettingsScreen extends StatelessWidget {
|
|
/// Creates a [SettingsScreen].
|
|
const SettingsScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Settings')),
|
|
body: ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
ListTile(
|
|
contentPadding: EdgeInsets.zero,
|
|
title: const Text('Sync settings'),
|
|
subtitle: const Text('Firebase sync'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () => Navigator.of(context).push<void>(
|
|
MaterialPageRoute(
|
|
builder: (_) => SyncSettingsScreen(
|
|
accountLoader: loadAccount,
|
|
accountSaver: saveAccount,
|
|
accountClearer: clearAccount,
|
|
sessionProbe: isFirebaseConfigured,
|
|
firebaseFactory: openFirebase,
|
|
googleFirebaseFactory: openFirebaseWithGoogle,
|
|
googleAvailable: googleSignInSupported,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
ListTile(
|
|
contentPadding: EdgeInsets.zero,
|
|
title: const Text('Room proof'),
|
|
subtitle: const Text('NFC tag and QR code for the other room'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () => Navigator.of(context).push<void>(
|
|
MaterialPageRoute(builder: (_) => const RoomProofScreen()),
|
|
),
|
|
),
|
|
ListTile(
|
|
contentPadding: EdgeInsets.zero,
|
|
title: const Text('Advanced sync (GitHub)'),
|
|
subtitle: const Text('Cutover mirror — not recommended'),
|
|
trailing: const Icon(Icons.chevron_right),
|
|
onTap: () => Navigator.of(context).push<void>(
|
|
MaterialPageRoute(builder: (_) => const GitHubMirrorScreen()),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|