diff --git a/lib/alarm/logic/alarm_isolate.dart b/lib/alarm/logic/alarm_isolate.dart index 58d1396e..8372fcac 100644 --- a/lib/alarm/logic/alarm_isolate.dart +++ b/lib/alarm/logic/alarm_isolate.dart @@ -25,6 +25,10 @@ const String setAlarmVolumePortName = "setAlarmVolumePort"; @pragma('vm:entry-point') void triggerScheduledNotification(int scheduleId, Json params) async { + FlutterError.onError = (FlutterErrorDetails details) { + logger.f(details.exception.toString()); + }; + logger.i("Alarm triggered: $scheduleId"); // print("Alarm Trigger Isolate: ${Service.getIsolateID(Isolate.current)}"); if (params == null) { @@ -74,10 +78,9 @@ void stopScheduledNotification(List message) { } void triggerAlarm(int scheduleId, Json params) async { + logger.i("Alarm triggered $scheduleId"); if (params == null) { - if (kDebugMode) { - print("Params was null when triggering alarm"); - } + logger.e("Params was null when triggering alarm"); return; } @@ -101,6 +104,7 @@ void triggerAlarm(int scheduleId, Json params) async { now.millisecondsSinceEpoch > alarm.currentScheduleDateTime!.millisecondsSinceEpoch + 1000 * 60 * 60) { + logger.i("Skipping alarm $scheduleId"); return; } @@ -124,7 +128,6 @@ void triggerAlarm(int scheduleId, Json params) async { IsolateNameServer.registerPortWithName( receivePort.sendPort, setAlarmVolumePortName); receivePort.listen((message) { - print("recieve message: $message"); setVolume(message[0]); }); @@ -147,10 +150,11 @@ void triggerAlarm(int scheduleId, Json params) async { } void setVolume(double volume) { - RingtonePlayer.setVolume(volume/100); + RingtonePlayer.setVolume(volume / 100); } void stopAlarm(int scheduleId, AlarmStopAction action) async { + logger.i("Stopping alarm $scheduleId with action: ${action.name}"); if (action == AlarmStopAction.snooze) { await updateAlarmById(scheduleId, (alarm) async => await alarm.snooze()); // await createSnoozeNotification(scheduleId); @@ -168,6 +172,7 @@ void stopAlarm(int scheduleId, AlarmStopAction action) async { } void triggerTimer(int scheduleId, Json params) async { + logger.i("Timer triggered $scheduleId"); ClockTimer? timer = getTimerById(scheduleId); if (timer == null || !timer.isRunning) { @@ -204,6 +209,7 @@ void triggerTimer(int scheduleId, Json params) async { } void stopTimer(int scheduleId, AlarmStopAction action) async { + logger.i("Stopping timer $scheduleId with action: ${action.name}"); ClockTimer? timer = getTimerById(scheduleId); if (timer == null) return; if (action == AlarmStopAction.snooze) { diff --git a/lib/audio/types/ringtone_player.dart b/lib/audio/types/ringtone_player.dart index d5742ad2..091c201e 100644 --- a/lib/audio/types/ringtone_player.dart +++ b/lib/audio/types/ringtone_player.dart @@ -1,6 +1,7 @@ import 'package:audio_session/audio_session.dart'; import 'package:clock_app/alarm/types/alarm.dart'; import 'package:clock_app/audio/types/ringtone_manager.dart'; +import 'package:clock_app/debug/logic/logger.dart'; import 'package:clock_app/timer/types/timer.dart'; import 'package:just_audio/just_audio.dart'; import 'package:vibration/vibration.dart'; @@ -98,6 +99,7 @@ class RingtonePlayer { } static Future setVolume(double volume) async { + logger.t("Setting volume to $volume"); await activePlayer?.setVolume(volume); } @@ -117,15 +119,15 @@ class RingtonePlayer { await activePlayer?.stop(); await activePlayer?.setLoopMode(loopMode); await activePlayer?.setAudioSource(AudioSource.uri(Uri.parse(ringtoneUri))); - await activePlayer?.setVolume(volume); - // activePlayer.setMode + await setVolume(volume); + // Gradually increase the volume if (secondsToMaxVolume > 0) { for (int i = 0; i <= 10; i++) { Future.delayed( Duration(milliseconds: i * (secondsToMaxVolume * 100)), () { - activePlayer?.setVolume((i / 10) * volume); + setVolume((i / 10) * volume); }, ); } diff --git a/lib/main.dart b/lib/main.dart index afa62221..1d9b101c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,12 +18,10 @@ import 'package:clock_app/settings/types/listener_manager.dart'; import 'package:clock_app/system/data/app_info.dart'; import 'package:clock_app/system/data/device_info.dart'; import 'package:clock_app/system/logic/handle_boot.dart'; -import 'package:clock_app/system/logic/quick_actions.dart'; import 'package:clock_app/timer/logic/update_timers.dart'; import 'package:flutter/material.dart'; import 'package:flutter_boot_receiver/flutter_boot_receiver.dart'; import 'package:flutter_show_when_locked/flutter_show_when_locked.dart'; -import 'package:quick_actions/quick_actions.dart'; import 'package:timezone/data/latest_all.dart'; void main() async {