diff --git a/lib/features/routines/notifications/workout_notification_content.dart b/lib/features/routines/notifications/workout_notification_content.dart index 15b403037..af2b121ca 100644 --- a/lib/features/routines/notifications/workout_notification_content.dart +++ b/lib/features/routines/notifications/workout_notification_content.dart @@ -164,7 +164,7 @@ class WorkoutNotificationLabels extends Equatable { : logSet = i18n.workoutNotificationLogSet, skipRest = i18n.workoutNotificationSkipRest, controlsChannel = i18n.workoutNotificationChannel, - alarmChannel = i18n.gymModeRestAlarm, + alarmChannel = i18n.workoutNotificationAlarmChannel, notLoggedTitle = i18n.workoutNotificationNotLoggedTitle, notLoggedBody = i18n.workoutNotificationNotLoggedBody; @@ -247,7 +247,7 @@ WorkoutNotificationTarget buildWorkoutNotification( final endsAt = state.restEndsAt; final restRunning = endsAt != null && endsAt.isAfter(now); - final alarm = state.restAlarmEnabled && restRunning + final alarm = state.alertOnCountdownEnd && restRunning ? RestAlarm( at: endsAt, title: i18n.workoutNotificationRestOver, diff --git a/lib/features/routines/providers/gym_state.dart b/lib/features/routines/providers/gym_state.dart index c2e22d32a..5b3dac3ce 100644 --- a/lib/features/routines/providers/gym_state.dart +++ b/lib/features/routines/providers/gym_state.dart @@ -34,7 +34,6 @@ const PREFS_COUNTDOWN_DURATION = 'countdownDurationSecondsPrefs'; const PREFS_LOG_SCOPE_WEEKS = 'logScopeWeeksPrefs'; const PREFS_SHOW_DISTINCT_LOGS = 'showDistinctLogsPrefs'; const PREFS_SHOW_WORKOUT_DURATION = 'showWorkoutDurationPrefs'; -const PREFS_REST_ALARM = 'restAlarmPrefs'; const PREFS_WORKOUT_NOTIFICATION = 'workoutNotificationPrefs'; /// In seconds @@ -187,6 +186,9 @@ class GymModeState { // User settings final bool showExercisePages; final bool showTimerPages; + + /// Alert at the end of a rest: a vibration in gym mode, an OS notification + /// with the app in the background final bool alertOnCountdownEnd; final bool useCountdownBetweenSets; final Duration countdownDuration; @@ -194,9 +196,6 @@ class GymModeState { final bool showDistinctLogs; final bool showWorkoutDuration; - /// OS notification when the rest is over, also with the app in the background - final bool restAlarmEnabled; - /// Ongoing notification with the rest and the next set (Android) final bool showWorkoutNotification; @@ -220,7 +219,6 @@ class GymModeState { this.logScopeWeeks, this.showDistinctLogs = true, this.showWorkoutDuration = true, - this.restAlarmEnabled = true, this.showWorkoutNotification = true, int? dayId, int? iteration, @@ -271,7 +269,6 @@ class GymModeState { bool clearLogScopeWeeks = false, bool? showDistinctLogs, bool? showWorkoutDuration, - bool? restAlarmEnabled, bool? showWorkoutNotification, }) { return GymModeState( @@ -297,7 +294,6 @@ class GymModeState { logScopeWeeks: clearLogScopeWeeks ? null : (logScopeWeeks ?? this.logScopeWeeks), showDistinctLogs: showDistinctLogs ?? this.showDistinctLogs, showWorkoutDuration: showWorkoutDuration ?? this.showWorkoutDuration, - restAlarmEnabled: restAlarmEnabled ?? this.restAlarmEnabled, showWorkoutNotification: showWorkoutNotification ?? this.showWorkoutNotification, ); } diff --git a/lib/features/routines/providers/gym_state_notifier.dart b/lib/features/routines/providers/gym_state_notifier.dart index cef4f2245..8ba45c589 100644 --- a/lib/features/routines/providers/gym_state_notifier.dart +++ b/lib/features/routines/providers/gym_state_notifier.dart @@ -93,11 +93,6 @@ class GymStateNotifier extends _$GymStateNotifier { state = state.copyWith(showWorkoutDuration: showWorkoutDuration); } - final restAlarm = await prefs.getBool(PREFS_REST_ALARM); - if (restAlarm != null && restAlarm != state.restAlarmEnabled) { - state = state.copyWith(restAlarmEnabled: restAlarm); - } - final workoutNotification = await prefs.getBool(PREFS_WORKOUT_NOTIFICATION); if (workoutNotification != null && workoutNotification != state.showWorkoutNotification) { state = state.copyWith(showWorkoutNotification: workoutNotification); @@ -113,7 +108,6 @@ class GymStateNotifier extends _$GymStateNotifier { 'logScopeWeeks=$logScopeWeeks ' 'showDistinctLogs=$showDistinctLogs ' 'showWorkoutDuration=$showWorkoutDuration ' - 'restAlarm=$restAlarm ' 'workoutNotification=$workoutNotification ', ); } @@ -135,7 +129,6 @@ class GymStateNotifier extends _$GymStateNotifier { } await prefs.setBool(PREFS_SHOW_DISTINCT_LOGS, state.showDistinctLogs); await prefs.setBool(PREFS_SHOW_WORKOUT_DURATION, state.showWorkoutDuration); - await prefs.setBool(PREFS_REST_ALARM, state.restAlarmEnabled); await prefs.setBool(PREFS_WORKOUT_NOTIFICATION, state.showWorkoutNotification); _logger.finer( @@ -148,7 +141,6 @@ class GymStateNotifier extends _$GymStateNotifier { 'logScopeWeeks=${state.logScopeWeeks} ' 'showDistinctLogs=${state.showDistinctLogs} ' 'showWorkoutDuration=${state.showWorkoutDuration} ' - 'restAlarm=${state.restAlarmEnabled} ' 'workoutNotification=${state.showWorkoutNotification} ', ); } @@ -471,11 +463,6 @@ class GymStateNotifier extends _$GymStateNotifier { _savePrefs(); } - void setRestAlarmEnabled(bool value) { - state = state.copyWith(restAlarmEnabled: value); - _savePrefs(); - } - void setShowWorkoutNotification(bool value) { state = state.copyWith(showWorkoutNotification: value); _savePrefs(); diff --git a/lib/features/routines/widgets/gym_mode/gym_mode.dart b/lib/features/routines/widgets/gym_mode/gym_mode.dart index 00a15dda1..3a9b60880 100644 --- a/lib/features/routines/widgets/gym_mode/gym_mode.dart +++ b/lib/features/routines/widgets/gym_mode/gym_mode.dart @@ -127,7 +127,8 @@ class _GymModeState extends ConsumerState { final gymState = ref.read(gymStateProvider); final service = ref.read(workoutNotificationServiceProvider); final wanted = - gymState.restAlarmEnabled || (service.supportsControls && gymState.showWorkoutNotification); + gymState.alertOnCountdownEnd || + (service.supportsControls && gymState.showWorkoutNotification); if (wanted && mounted) { unawaited( service.requestPermissions(WorkoutNotificationLabels.of(AppLocalizations.of(context))), diff --git a/lib/features/routines/widgets/gym_mode/start_page.dart b/lib/features/routines/widgets/gym_mode/start_page.dart index 160634a63..988aa5e0d 100644 --- a/lib/features/routines/widgets/gym_mode/start_page.dart +++ b/lib/features/routines/widgets/gym_mode/start_page.dart @@ -169,27 +169,21 @@ class _GymModeOptionsState extends ConsumerState { ), ), + // Enabled without the default countdown too, a set's rest time + // is always counted down SwitchListTile( key: const ValueKey('gym-mode-notify-countdown'), - title: Text(i18n.gymModeNotifyOnCountdownFinish), + title: Text(i18n.gymModeAlertOnRestEnd), + subtitle: Text(i18n.gymModeAlertOnRestEndHelp), value: gymState.alertOnCountdownEnd, - onChanged: (gymState.showTimerPages && gymState.useCountdownBetweenSets) - ? (value) => gymNotifier.setAlertOnCountdownEnd(value) - : null, - ), - SwitchListTile( - key: const ValueKey('gym-mode-rest-alarm'), - title: Text(i18n.gymModeRestAlarm), - subtitle: Text(i18n.gymModeRestAlarmHelp), - value: gymState.restAlarmEnabled, onChanged: gymState.showTimerPages - ? (value) => gymNotifier.setRestAlarmEnabled(value) + ? (value) => gymNotifier.setAlertOnCountdownEnd(value) : null, ), // Android delays alarms without the exact alarm permission if (isAndroid && gymState.showTimerPages && - gymState.restAlarmEnabled && + gymState.alertOnCountdownEnd && ref.watch(exactAlarmsAllowedProvider).value == false) ListTile( key: const ValueKey('gym-mode-exact-alarm-hint'), diff --git a/lib/l10n/app_ar.arb b/lib/l10n/app_ar.arb index f22efe890..dd288fe0e 100644 --- a/lib/l10n/app_ar.arb +++ b/lib/l10n/app_ar.arb @@ -823,7 +823,6 @@ "countdown": "عد تنازلي", "stopwatch": "ساعة توقيت", "gymModeDefaultCountdownTime": "وقت العد التنازلي الافتراضي، بالثواني", - "gymModeNotifyOnCountdownFinish": "إشعار عند انتهاء العد التنازلي", "duration": "المدة", "durationHoursMinutes": "{hours}سا {minutes}د", "@durationHoursMinutes": { diff --git a/lib/l10n/app_ca.arb b/lib/l10n/app_ca.arb index a04c5b486..706bc7482 100644 --- a/lib/l10n/app_ca.arb +++ b/lib/l10n/app_ca.arb @@ -870,7 +870,6 @@ "countdown": "Compte enrere", "stopwatch": "Cronometre", "gymModeDefaultCountdownTime": "Temps de compte enrere per defecte, en segons", - "gymModeNotifyOnCountdownFinish": "Notifica en finalitzar el compte enrere", "duration": "Duració", "durationHoursMinutes": "{hours}h {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_cs.arb b/lib/l10n/app_cs.arb index 0a29ed607..a58291e18 100644 --- a/lib/l10n/app_cs.arb +++ b/lib/l10n/app_cs.arb @@ -873,7 +873,6 @@ "countdown": "Odpočet", "stopwatch": "Stopky", "gymModeDefaultCountdownTime": "Výchozí doba odpočítávání v sekundách", - "gymModeNotifyOnCountdownFinish": "Upozornit na konec odpočítávání", "duration": "Doba trvání", "durationHoursMinutes": "{hours}h {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 865a77e64..6ba3a11b0 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -848,7 +848,6 @@ "countdown": "Herunterzählen", "stopwatch": "Stoppuhr", "gymModeDefaultCountdownTime": "Standard-Countdown-Zeit in Sekunden", - "gymModeNotifyOnCountdownFinish": "Benachrichtigung bei Ende des Countdowns", "duration": "Dauer", "durationHoursMinutes": "{hours}h {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 0c0d62230..11f935b58 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -375,13 +375,12 @@ "countdown": "Countdown", "stopwatch": "Stopwatch", "gymModeDefaultCountdownTime": "Default countdown time, in seconds", - "gymModeNotifyOnCountdownFinish": "Notify on countdown end", - "gymModeRestAlarm": "Rest alarm", - "gymModeRestAlarmHelp": "System notification when the rest is over, also with the screen locked", + "gymModeAlertOnRestEnd": "Alert when rest ends", + "gymModeAlertOnRestEndHelp": "Vibrates in gym mode, or sends a notification when the app is in the background", "gymModeWorkoutNotification": "Workout notification", "gymModeExactAlarmMissing": "Without the exact alarm permission, the rest alarm can be a few minutes late", "gymModeExactAlarmAllow": "Allow", - "gymModeWorkoutNotificationHelp": "Shows the rest and the next set, with buttons to log it or skip the rest", + "gymModeWorkoutNotificationHelp": "While the app is in the background: rest countdown and next set, with buttons to log or skip", "workoutNotificationRestOver": "Rest is over", "workoutNotificationNext": "Next: {set}", "@workoutNotificationNext": { @@ -411,6 +410,10 @@ "workoutNotificationSkipRest": "Skip rest", "workoutNotificationNotLoggedTitle": "Set not logged", "workoutNotificationNotLoggedBody": "Open gym mode to continue the workout", + "workoutNotificationAlarmChannel": "Rest alarm", + "@workoutNotificationAlarmChannel": { + "description": "Name of the Android notification channel for the alert at the end of a rest" + }, "workoutNotificationChannel": "Workout", "@workoutNotificationChannel": { "description": "Name of the Android notification channel for the ongoing workout notification" diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index eeb9974c7..4513855ae 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -838,7 +838,6 @@ "countdown": "Cuenta regresiva", "stopwatch": "Cronómetro", "gymModeDefaultCountdownTime": "Tiempo predeterminado de cuenta regresiva, en segundos", - "gymModeNotifyOnCountdownFinish": "Notificar al terminar cuenta regresiva", "duration": "Duración", "volume": "Volumen", "@volume": { diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 11f0a9372..a76b3559d 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -840,7 +840,6 @@ "countdown": "Compte à rebours", "stopwatch": "Chronomètre", "gymModeDefaultCountdownTime": "Temps de compte à rebours par défaut, en secondes", - "gymModeNotifyOnCountdownFinish": "Notifier à la fin du compte à rebours", "duration": "Durée", "durationHoursMinutes": "{hours}h {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_hr.arb b/lib/l10n/app_hr.arb index 898722460..2ef18eb77 100644 --- a/lib/l10n/app_hr.arb +++ b/lib/l10n/app_hr.arb @@ -992,7 +992,6 @@ "countdown": "Odbrojavanje", "stopwatch": "Štoperica", "gymModeDefaultCountdownTime": "Zadano vrijeme odbrojavanja, u sekundama", - "gymModeNotifyOnCountdownFinish": "Obavijesti pri kraju odbrojavanja", "duration": "Trajanje", "durationHoursMinutes": "{hours} h {minutes} min", "@durationHoursMinutes": { diff --git a/lib/l10n/app_hu.arb b/lib/l10n/app_hu.arb index 412ddf210..201f95c3f 100644 --- a/lib/l10n/app_hu.arb +++ b/lib/l10n/app_hu.arb @@ -406,7 +406,6 @@ "countdown": "Visszaszámláló", "stopwatch": "Stopperóra", "gymModeDefaultCountdownTime": "Alapértelmezett visszaszámlálási idő másodpercben", - "gymModeNotifyOnCountdownFinish": "Értesítés a visszaszámlálás végén", "duration": "Időtartam", "durationHoursMinutes": "{hours} ó {minutes} p", "@durationHoursMinutes": { diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index ed4ea80a8..ed0296ba7 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -918,7 +918,6 @@ "gymModeTimerTypeHelText": "Jika set memiliki waktu jeda, hitung mundur akan selalu digunakan.", "countdown": "Hitung Mundur", "gymModeDefaultCountdownTime": "Waktu hitung mundur default, dalam detik", - "gymModeNotifyOnCountdownFinish": "Beri notifikasi saat hitung mundur selesai", "duration": "Durasi", "durationHoursMinutes": "{hours}j {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb index 063cee369..958b6ec52 100644 --- a/lib/l10n/app_it.arb +++ b/lib/l10n/app_it.arb @@ -943,7 +943,6 @@ "countdown": "Conto alla rovescia", "stopwatch": "Cronometro", "gymModeDefaultCountdownTime": "Conto alla rovescia di default, in secondi", - "gymModeNotifyOnCountdownFinish": "Notifica quando il conto alla rovescia finisce", "duration": "Durata", "durationHoursMinutes": "{hours}h {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_mk.arb b/lib/l10n/app_mk.arb index cc2f2e4f0..cf4fa5e66 100644 --- a/lib/l10n/app_mk.arb +++ b/lib/l10n/app_mk.arb @@ -550,7 +550,6 @@ "countdown": "Одбројување", "stopwatch": "Штоперица", "gymModeDefaultCountdownTime": "Стандардно време на одбројување, во секунди", - "gymModeNotifyOnCountdownFinish": "Извести на крајот од одбројувањето", "duration": "Времетраење", "durationHoursMinutes": "{hours}ч {minutes}м", "@durationHoursMinutes": { diff --git a/lib/l10n/app_nl.arb b/lib/l10n/app_nl.arb index 3bf36afe3..7a95c7c10 100644 --- a/lib/l10n/app_nl.arb +++ b/lib/l10n/app_nl.arb @@ -254,7 +254,6 @@ "countdown": "Afteller", "stopwatch": "Stopwatch", "gymModeDefaultCountdownTime": "Standaard afteltijd, in secondes", - "gymModeNotifyOnCountdownFinish": "Notificeer op einde aftelling", "duration": "Duur", "durationHoursMinutes": "{hours}u {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index 45cbf48b9..25a8a38be 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -834,7 +834,6 @@ "countdown": "Odliczanie", "stopwatch": "Stoper", "gymModeDefaultCountdownTime": "Domyślny czas timera, w sekundach", - "gymModeNotifyOnCountdownFinish": "Powiadom na koniec odliczania", "duration": "Czas trwania", "durationHoursMinutes": "{hours}h {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_pt.arb b/lib/l10n/app_pt.arb index 330b94703..6d849fb2e 100644 --- a/lib/l10n/app_pt.arb +++ b/lib/l10n/app_pt.arb @@ -850,7 +850,6 @@ "countdown": "Contagem regressiva", "stopwatch": "Cronômetro", "gymModeDefaultCountdownTime": "Tempo de contagem regressiva padrão, em segundos", - "gymModeNotifyOnCountdownFinish": "Notificar quando a contagem regressiva terminar", "duration": "Duração", "durationHoursMinutes": "{hours}h {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_pt_BR.arb b/lib/l10n/app_pt_BR.arb index da6fa0b07..cc3a14f61 100644 --- a/lib/l10n/app_pt_BR.arb +++ b/lib/l10n/app_pt_BR.arb @@ -902,7 +902,6 @@ "countdown": "Contagem regressiva", "stopwatch": "cronômetro", "gymModeDefaultCountdownTime": "Tempo de contagem regressiva padrão, em segundos", - "gymModeNotifyOnCountdownFinish": "Notificar no final da contagem regressiva", "duration": "Duração", "durationHoursMinutes": "{hours}h {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_ro.arb b/lib/l10n/app_ro.arb index a884c2c32..5b5d7b531 100644 --- a/lib/l10n/app_ro.arb +++ b/lib/l10n/app_ro.arb @@ -365,7 +365,6 @@ "countdown": "Numărătoare inversă", "stopwatch": "Cronometru", "gymModeDefaultCountdownTime": "Timp implicit pentru numărătoare inversă, în secunde", - "gymModeNotifyOnCountdownFinish": "Notifică la finalul numărătorii inverse", "duration": "Durată", "durationHoursMinutes": "{hours}h {minutes}m", "@durationHoursMinutes": { diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index 77f91901d..cb0210a1a 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -884,7 +884,6 @@ "countdown": "Обратный отсчёт", "stopwatch": "Секундомер", "gymModeDefaultCountdownTime": "Время обратного отсчёта по умолчанию (в секундах)", - "gymModeNotifyOnCountdownFinish": "Уведомлять об окончании отсчёта", "duration": "Длительность", "durationHoursMinutes": "{hours} ч {minutes} мин", "@durationHoursMinutes": { diff --git a/lib/l10n/app_sl.arb b/lib/l10n/app_sl.arb index 14a7debd4..c00745be7 100644 --- a/lib/l10n/app_sl.arb +++ b/lib/l10n/app_sl.arb @@ -328,7 +328,6 @@ "countdown": "Odštevanje", "stopwatch": "Štoparica", "gymModeDefaultCountdownTime": "Privzeti čas za odštevanje, v sekundah", - "gymModeNotifyOnCountdownFinish": "Opomnik ob koncu odštevanja", "duration": "Trajanje", "durationHoursMinutes": "{hours} h {minutes} min", "@durationHoursMinutes": { diff --git a/lib/l10n/app_uk.arb b/lib/l10n/app_uk.arb index 4801908cf..5b81274f2 100644 --- a/lib/l10n/app_uk.arb +++ b/lib/l10n/app_uk.arb @@ -920,7 +920,6 @@ "countdown": "Зворотний відлік", "stopwatch": "Секундомір", "gymModeDefaultCountdownTime": "Час зворотного відліку за замовчуванням, у секундах", - "gymModeNotifyOnCountdownFinish": "Повідомити про закінчення зворотного відліку", "duration": "Тривалість", "durationHoursMinutes": "{hours}год {minutes}хв", "@durationHoursMinutes": { diff --git a/lib/l10n/app_zh_Hant.arb b/lib/l10n/app_zh_Hant.arb index 62a08ddd4..8ad6b1c6f 100644 --- a/lib/l10n/app_zh_Hant.arb +++ b/lib/l10n/app_zh_Hant.arb @@ -1021,7 +1021,6 @@ "countdown": "倒數計時", "stopwatch": "碼表", "gymModeDefaultCountdownTime": "預設倒數時間(秒)", - "gymModeNotifyOnCountdownFinish": "倒數結束時通知", "personalRecords": "個人紀錄", "errorViewDetails": "技術細節", "errorInfoDescription": "不好意思,目前出了點問題。你可以前往 GitHub 提交問題以幫助我們修復此問題。", diff --git a/test/core/validators_test.mocks.dart b/test/core/validators_test.mocks.dart index d81e0e6dd..a14405407 100644 --- a/test/core/validators_test.mocks.dart +++ b/test/core/validators_test.mocks.dart @@ -1472,12 +1472,155 @@ class MockAppLocalizations extends _i1.Mock implements _i2.AppLocalizations { as String); @override - String get gymModeNotifyOnCountdownFinish => + String get gymModeAlertOnRestEnd => (super.noSuchMethod( - Invocation.getter(#gymModeNotifyOnCountdownFinish), + Invocation.getter(#gymModeAlertOnRestEnd), returnValue: _i3.dummyValue( this, - Invocation.getter(#gymModeNotifyOnCountdownFinish), + Invocation.getter(#gymModeAlertOnRestEnd), + ), + ) + as String); + + @override + String get gymModeAlertOnRestEndHelp => + (super.noSuchMethod( + Invocation.getter(#gymModeAlertOnRestEndHelp), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#gymModeAlertOnRestEndHelp), + ), + ) + as String); + + @override + String get gymModeWorkoutNotification => + (super.noSuchMethod( + Invocation.getter(#gymModeWorkoutNotification), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#gymModeWorkoutNotification), + ), + ) + as String); + + @override + String get gymModeExactAlarmMissing => + (super.noSuchMethod( + Invocation.getter(#gymModeExactAlarmMissing), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#gymModeExactAlarmMissing), + ), + ) + as String); + + @override + String get gymModeExactAlarmAllow => + (super.noSuchMethod( + Invocation.getter(#gymModeExactAlarmAllow), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#gymModeExactAlarmAllow), + ), + ) + as String); + + @override + String get gymModeWorkoutNotificationHelp => + (super.noSuchMethod( + Invocation.getter(#gymModeWorkoutNotificationHelp), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#gymModeWorkoutNotificationHelp), + ), + ) + as String); + + @override + String get workoutNotificationRestOver => + (super.noSuchMethod( + Invocation.getter(#workoutNotificationRestOver), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#workoutNotificationRestOver), + ), + ) + as String); + + @override + String get workoutNotificationInProgress => + (super.noSuchMethod( + Invocation.getter(#workoutNotificationInProgress), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#workoutNotificationInProgress), + ), + ) + as String); + + @override + String get workoutNotificationLogSet => + (super.noSuchMethod( + Invocation.getter(#workoutNotificationLogSet), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#workoutNotificationLogSet), + ), + ) + as String); + + @override + String get workoutNotificationSkipRest => + (super.noSuchMethod( + Invocation.getter(#workoutNotificationSkipRest), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#workoutNotificationSkipRest), + ), + ) + as String); + + @override + String get workoutNotificationNotLoggedTitle => + (super.noSuchMethod( + Invocation.getter(#workoutNotificationNotLoggedTitle), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#workoutNotificationNotLoggedTitle), + ), + ) + as String); + + @override + String get workoutNotificationNotLoggedBody => + (super.noSuchMethod( + Invocation.getter(#workoutNotificationNotLoggedBody), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#workoutNotificationNotLoggedBody), + ), + ) + as String); + + @override + String get workoutNotificationAlarmChannel => + (super.noSuchMethod( + Invocation.getter(#workoutNotificationAlarmChannel), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#workoutNotificationAlarmChannel), + ), + ) + as String); + + @override + String get workoutNotificationChannel => + (super.noSuchMethod( + Invocation.getter(#workoutNotificationChannel), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#workoutNotificationChannel), ), ) as String); @@ -3687,6 +3830,17 @@ class MockAppLocalizations extends _i1.Mock implements _i2.AppLocalizations { ) as String); + @override + String get authorHelpText => + (super.noSuchMethod( + Invocation.getter(#authorHelpText), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#authorHelpText), + ), + ) + as String); + @override String get imageDetailsAuthorLink => (super.noSuchMethod( @@ -5554,6 +5708,28 @@ class MockAppLocalizations extends _i1.Mock implements _i2.AppLocalizations { ) as String); + @override + String workoutNotificationNext(String? set) => + (super.noSuchMethod( + Invocation.method(#workoutNotificationNext, [set]), + returnValue: _i3.dummyValue( + this, + Invocation.method(#workoutNotificationNext, [set]), + ), + ) + as String); + + @override + String workoutNotificationSetOf(int? current, int? total) => + (super.noSuchMethod( + Invocation.method(#workoutNotificationSetOf, [current, total]), + returnValue: _i3.dummyValue( + this, + Invocation.method(#workoutNotificationSetOf, [current, total]), + ), + ) + as String); + @override String durationHoursMinutes(int? hours, int? minutes) => (super.noSuchMethod( diff --git a/test/features/routines/notifications/workout_notification_content_test.dart b/test/features/routines/notifications/workout_notification_content_test.dart index 567adfcf5..b825ceebe 100644 --- a/test/features/routines/notifications/workout_notification_content_test.dart +++ b/test/features/routines/notifications/workout_notification_content_test.dart @@ -91,7 +91,7 @@ void main() { }); test('No alarm when the setting is off', () { - notifier.state = notifier.state.copyWith(restAlarmEnabled: false); + notifier.state = notifier.state.copyWith(alertOnCountdownEnd: false); onPage(timers().first, restStartedAt: now, restEndsAt: now.add(const Duration(seconds: 90))); final target = build(); diff --git a/test/features/routines/notifications/workout_notification_controller_test.dart b/test/features/routines/notifications/workout_notification_controller_test.dart index 7665e3718..a2823280d 100644 --- a/test/features/routines/notifications/workout_notification_controller_test.dart +++ b/test/features/routines/notifications/workout_notification_controller_test.dart @@ -190,7 +190,7 @@ void main() { test('Each setting only switches off its own notification', () async { initGymMode(); - gymState.state = gymState.state.copyWith(restAlarmEnabled: false); + gymState.state = gymState.state.copyWith(alertOnCountdownEnd: false); await startRest(); verifyNever(service.scheduleRestAlarm(any, any)); verify(service.showControls(any, any)); @@ -198,7 +198,7 @@ void main() { clearInteractions(service); await withClock(Clock.fixed(now), () async { gymState.state = gymState.state.copyWith( - restAlarmEnabled: true, + alertOnCountdownEnd: true, showWorkoutNotification: false, ); await settle(); diff --git a/test/features/routines/providers/gym_state_test.dart b/test/features/routines/providers/gym_state_test.dart index 392ec6da5..29e8172ae 100644 --- a/test/features/routines/providers/gym_state_test.dart +++ b/test/features/routines/providers/gym_state_test.dart @@ -525,30 +525,30 @@ void main() { test('Both are on without stored preferences', () async { await notifier.loadPrefs(); - expect(notifier.state.restAlarmEnabled, isTrue); + expect(notifier.state.alertOnCountdownEnd, isTrue); expect(notifier.state.showWorkoutNotification, isTrue); }); test('Stored values are loaded', () async { - await PreferenceHelper.asyncPref.setBool(PREFS_REST_ALARM, false); + await PreferenceHelper.asyncPref.setBool(PREFS_ALERT_COUNTDOWN, false); await PreferenceHelper.asyncPref.setBool(PREFS_WORKOUT_NOTIFICATION, false); await notifier.loadPrefs(); - expect(notifier.state.restAlarmEnabled, isFalse); + expect(notifier.state.alertOnCountdownEnd, isFalse); expect(notifier.state.showWorkoutNotification, isFalse); }); test('The setters change only their own flag and persist it', () async { - notifier.setRestAlarmEnabled(false); + notifier.setAlertOnCountdownEnd(false); await pumpEventQueue(); - expect(notifier.state.restAlarmEnabled, isFalse); + expect(notifier.state.alertOnCountdownEnd, isFalse); expect(notifier.state.showWorkoutNotification, isTrue); - expect(await PreferenceHelper.asyncPref.getBool(PREFS_REST_ALARM), false); + expect(await PreferenceHelper.asyncPref.getBool(PREFS_ALERT_COUNTDOWN), false); notifier.setShowWorkoutNotification(false); await pumpEventQueue(); - expect(notifier.state.restAlarmEnabled, isFalse); + expect(notifier.state.alertOnCountdownEnd, isFalse); expect(notifier.state.showWorkoutNotification, isFalse); expect(await PreferenceHelper.asyncPref.getBool(PREFS_WORKOUT_NOTIFICATION), false); }); diff --git a/test/features/routines/screens/gym_mode_test.dart b/test/features/routines/screens/gym_mode_test.dart index 885b814d3..c22d106cd 100644 --- a/test/features/routines/screens/gym_mode_test.dart +++ b/test/features/routines/screens/gym_mode_test.dart @@ -608,10 +608,10 @@ void main() { testWidgets( 'no permission request with both notification settings off', (WidgetTester tester) async { - await PreferenceHelper.asyncPref.setBool(PREFS_REST_ALARM, false); + await PreferenceHelper.asyncPref.setBool(PREFS_ALERT_COUNTDOWN, false); await PreferenceHelper.asyncPref.setBool(PREFS_WORKOUT_NOTIFICATION, false); addTearDown(() async { - await PreferenceHelper.asyncPref.remove(PREFS_REST_ALARM); + await PreferenceHelper.asyncPref.remove(PREFS_ALERT_COUNTDOWN); await PreferenceHelper.asyncPref.remove(PREFS_WORKOUT_NOTIFICATION); }); diff --git a/test/features/routines/widgets/gym_mode/start_page_test.dart b/test/features/routines/widgets/gym_mode/start_page_test.dart index baa94d185..d1b397ce9 100644 --- a/test/features/routines/widgets/gym_mode/start_page_test.dart +++ b/test/features/routines/widgets/gym_mode/start_page_test.dart @@ -63,7 +63,6 @@ void main() { showTimerPages: true, useCountdownBetweenSets: true, countdownDuration: const Duration(seconds: DEFAULT_COUNTDOWN_DURATION), - alertOnCountdownEnd: false, dayId: routine.days.first.id, iteration: 1, routine: routine, @@ -102,18 +101,13 @@ void main() { await tester.tap(optionsTile); await tester.pumpAndSettle(); - // Toggle notify countdown first (it is only enabled while timer/countdown are active) + // Toggle the rest end alert first (it is only enabled while timer pages are shown) final notifySwitch = find.byKey(const ValueKey('gym-mode-notify-countdown')); expect(notifySwitch, findsOneWidget); + await tester.ensureVisible(notifySwitch); await tester.tap(notifySwitch); await tester.pump(); - // The rest alarm is only enabled while timer pages are shown - final restAlarmSwitch = find.byKey(const ValueKey('gym-mode-rest-alarm')); - await tester.ensureVisible(restAlarmSwitch); - await tester.tap(restAlarmSwitch); - await tester.pump(); - final workoutNotificationSwitch = find.byKey(const ValueKey('gym-mode-workout-notification')); await tester.ensureVisible(workoutNotificationSwitch); await tester.tap(workoutNotificationSwitch); @@ -143,12 +137,27 @@ void main() { final notifier = container.read(gymStateProvider.notifier); expect(notifier.state.showExercisePages, isFalse); expect(notifier.state.showTimerPages, isFalse); - expect(notifier.state.alertOnCountdownEnd, isTrue); + expect(notifier.state.alertOnCountdownEnd, isFalse); expect(notifier.state.showWorkoutDuration, isFalse); - expect(notifier.state.restAlarmEnabled, isFalse); expect(notifier.state.showWorkoutNotification, isFalse); }); + testWidgets('The rest end alert works without the default countdown', (tester) async { + // A set's own rest time is counted down regardless of the setting + final notifier = container.read(gymStateProvider.notifier); + notifier.setUseCountdownBetweenSets(false); + await pumpGymModeOptions(tester); + await tester.tap(find.byKey(const ValueKey('gym-mode-options-tile'))); + await tester.pumpAndSettle(); + + final alertSwitch = find.byKey(const ValueKey('gym-mode-notify-countdown')); + await tester.ensureVisible(alertSwitch); + await tester.tap(alertSwitch); + await tester.pump(); + + expect(notifier.state.alertOnCountdownEnd, isFalse); + }); + testWidgets('The workout notification switch only shows on Android', (tester) async { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; addTearDown(() => debugDefaultTargetPlatformOverride = null); @@ -157,7 +166,7 @@ void main() { await tester.tap(find.byKey(const ValueKey('gym-mode-options-tile'))); await tester.pumpAndSettle(); - expect(find.byKey(const ValueKey('gym-mode-rest-alarm')), findsOneWidget); + expect(find.byKey(const ValueKey('gym-mode-notify-countdown')), findsOneWidget); expect(find.byKey(const ValueKey('gym-mode-workout-notification')), findsNothing); debugDefaultTargetPlatformOverride = null; }); @@ -303,13 +312,13 @@ void main() { expect(hint, findsNothing); }); - testWidgets('Not shown with the permission or with the rest alarm off', (tester) async { + testWidgets('Not shown with the permission or with the rest end alert off', (tester) async { await openOptions(tester); expect(hint, findsNothing); when(notificationService.canScheduleExactAlarms()).thenAnswer((_) async => false); container.invalidate(exactAlarmsAllowedProvider); - container.read(gymStateProvider.notifier).setRestAlarmEnabled(false); + container.read(gymStateProvider.notifier).setAlertOnCountdownEnd(false); await tester.pumpAndSettle(); expect(hint, findsNothing); });