diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 387e2646b..427565814 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -94,7 +94,7 @@ "alarmChangeTheTime": "Uhrzeit ändern", "alarmTestTheBuzz": "Vibration testen", "alarmCancelTheAlarm": "Wecker löschen", - "alarmBuzzingTheBand": "Band vibriert…", + "alarmBuzzingTheBand": "Vibration ans Band gesendet", "alarmCancelled": "Wecker gelöscht", "alarmSentToBand": "Wecker ans Band gesendet", "alarmInThePast": "Dieser Zeitpunkt liegt in der Vergangenheit – der Wecker hat bereits geklingelt oder wurde verpasst", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 4e83d12d2..a8f137e72 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -393,9 +393,9 @@ "@alarmCancelTheAlarm": { "description": "Button: cancel the alarm." }, - "alarmBuzzingTheBand": "Buzzing the band", + "alarmBuzzingTheBand": "Buzz sent to the band", "@alarmBuzzingTheBand": { - "description": "Snackbar: testing the buzz." + "description": "Snackbar: the test buzz command reached the band. The app gets no signal when the buzz ends, so this must not claim the band is still buzzing." }, "alarmCancelled": "Alarm cancelled", "@alarmCancelled": { diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index eb9add55d..49e9670de 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -91,7 +91,7 @@ "alarmChangeTheTime": "Cambiar la hora", "alarmTestTheBuzz": "Probar la vibración", "alarmCancelTheAlarm": "Cancelar la alarma", - "alarmBuzzingTheBand": "Vibrando la banda", + "alarmBuzzingTheBand": "Vibración enviada a la banda", "alarmCancelled": "Alarma cancelada", "alarmSentToBand": "Alarma enviada a la banda", "alarmInThePast": "En el pasado: ya sonó o se pasó", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index fdd2ab4b0..4d2a096d8 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -91,7 +91,7 @@ "alarmChangeTheTime": "Changer l’heure", "alarmTestTheBuzz": "Tester la vibration", "alarmCancelTheAlarm": "Annuler l’alarme", - "alarmBuzzingTheBand": "Vibration du bracelet", + "alarmBuzzingTheBand": "Vibration envoyée au bracelet", "alarmCancelled": "Alarme annulée", "alarmSentToBand": "Alarme envoyée au bracelet", "alarmInThePast": "Dans le passé — elle s’est déjà déclenchée ou a été manquée", diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index fb3c59901..d4028beae 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -100,7 +100,7 @@ "alarmChangeTheTime": "Изменить время", "alarmTestTheBuzz": "Проверить вибрацию", "alarmCancelTheAlarm": "Отменить будильник", - "alarmBuzzingTheBand": "Браслет вибрирует", + "alarmBuzzingTheBand": "Вибрация отправлена на браслет", "alarmCancelled": "Будильник отменён", "alarmSentToBand": "Будильник отправлен на браслет", "alarmInThePast": "Время прошло — будильник уже сработал или был пропущен", diff --git a/lib/ui2/profile/alarm.dart b/lib/ui2/profile/alarm.dart index e740cefdd..cf27f3235 100644 --- a/lib/ui2/profile/alarm.dart +++ b/lib/ui2/profile/alarm.dart @@ -358,7 +358,7 @@ class AlarmScreenView extends StatelessWidget { color: C.blue, soft: true, onTap: () => _run( - c, onTest, l?.alarmBuzzingTheBand ?? 'Buzzing the band')), + c, onTest, l?.alarmBuzzingTheBand ?? 'Buzz sent to the band')), const SizedBox(height: S.x3), ], if (at != null || anyDayEnabled) @@ -444,8 +444,16 @@ class AlarmScreenView extends StatelessWidget { } } - static void _say(BuildContext c, String msg) => - ScaffoldMessenger.of(c).showSnackBar(SnackBar(content: Text(msg))); + /// Replaces what this screen said before, shown or still queued, instead of + /// stacking behind it: repeat taps would otherwise queue one 4-second + /// snackbar each and keep an old result on screen long after it stopped + /// being true. Only while this screen is on top — a result that lands after + /// the user moved on must not wipe another screen's message. + static void _say(BuildContext c, String msg) { + final messenger = ScaffoldMessenger.of(c); + if (ModalRoute.of(c)?.isCurrent ?? true) messenger.clearSnackBars(); + messenger.showSnackBar(SnackBar(content: Text(msg))); + } static String _hhmm(DateTime d) => _hhmmOf(d.hour, d.minute); diff --git a/test/ui2_alarm_test.dart b/test/ui2_alarm_test.dart index 66dacb1a6..260e8c479 100644 --- a/test/ui2_alarm_test.dart +++ b/test/ui2_alarm_test.dart @@ -137,4 +137,71 @@ void main() { expect(find.text('Fired or missed'), findsOneWidget); }); }); + group('the test buzz', () { + setUp(() => ClockFormatController.seed(ClockFormat.h24)); + tearDown(ClockFormatController.debugReset); + + // The app gets no signal when the strap stops buzzing, so the confirmation + // may only say the command was sent, and repeat taps must not queue one + // 4-second snackbar each and keep "buzzing" on screen long after the band + // has stopped. + testWidgets('says the buzz was sent, once, however often it is tapped', + (t) async { + final now = DateTime(2026, 8, 22, 9); + await t.pumpWidget(MaterialApp( + home: AlarmScreenView( + armedAt: DateTime(2026, 8, 23, 6, 30), + state: AlarmArmState.confirmed, + connected: true, + now: now, + onTest: () async {}))); + final button = find.text('Test the buzz'); + await t.ensureVisible(button); + for (var i = 0; i < 3; i++) { + await t.tap(button); + await t.pump(); + } + await t.pump(const Duration(milliseconds: 750)); + expect(find.text('Buzz sent to the band'), findsOneWidget); + expect(find.textContaining('Buzzing'), findsNothing); + // One snackbar's lifetime later nothing is left waiting in the queue. + await t.pump(const Duration(seconds: 5)); + await t.pump(const Duration(seconds: 1)); + expect(find.text('Buzz sent to the band'), findsNothing); + }); + + testWidgets('a result that lands while the last one is leaving replaces it', + (t) async { + // Tap, let the message show, tap again (its exit starts), and tap a + // third time mid-exit: only the latest may follow, not a queue of two. + await t.pumpWidget(MaterialApp( + home: AlarmScreenView( + armedAt: DateTime(2026, 8, 23, 6, 30), + state: AlarmArmState.confirmed, + connected: true, + now: DateTime(2026, 8, 22, 9), + onTest: () async {}))); + final button = find.text('Test the buzz'); + await t.ensureVisible(button); + Future step(int ms) async { + for (var i = 0; i < ms ~/ 50; i++) { + await t.pump(const Duration(milliseconds: 50)); + } + } + + await t.tap(button); + await step(1000); + await t.tap(button); + await step(50); + await t.tap(button); + await step(1000); + // The latest message is up, alone. + expect(find.byType(SnackBar), findsOneWidget); + expect(find.text('Buzz sent to the band'), findsOneWidget); + // One message's enter, 4 s on screen and exit, with a second of slack; + // a second queued message would still be showing here. + await step(6000); + expect(find.text('Buzz sent to the band'), findsNothing); + }); + }); }