Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #328

Merged
merged 37 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
07a36b1
Merge pull request #303 from vicolo-dev/feature-i18n
AhsanSarwar45 Jun 29, 2024
2c7ff87
Bump pubspec
Jun 29, 2024
37db4b6
Update changelog
Jun 29, 2024
e858f34
Fix timer bugs
Jun 29, 2024
29055e7
Change timer title to include remaining time
Jun 29, 2024
d891ad4
Fix stopwatch
Jun 29, 2024
8b977c5
Update changelog
Jun 29, 2024
14cb7d7
Update changelog
Jun 29, 2024
45b1b6e
Add multiselect
Aug 24, 2024
26074ce
Add multiselect chips
Aug 25, 2024
90d60f3
Add multiselect to other screens
Aug 25, 2024
3440114
Fix card colors
Aug 25, 2024
62f328a
Add backup options
Aug 25, 2024
1567d70
Change id generation
Aug 25, 2024
5044ce9
Revert id generation
Aug 26, 2024
2ded544
Add more backup options
Aug 26, 2024
b3d131d
Improve backup
Aug 27, 2024
4849cb3
Add animations
Aug 29, 2024
601379a
Fix non-deletable items getting delted
Aug 29, 2024
d29fc68
Add animations to all list filter chips
Aug 30, 2024
500faab
Fixed range weekly schedule not working
Aug 31, 2024
e298171
Add numpad input
Aug 31, 2024
619acf9
Improve numpad
Aug 31, 2024
3da6976
Improve numpad
Aug 31, 2024
33c471c
Make tasks reorderable and selectable
Sep 1, 2024
a7144ad
Fix custom actions not worki;ng
Sep 1, 2024
aca0dd0
Add option to reduce volume while solving tasks
Sep 6, 2024
cb20778
Improve logging system
Sep 6, 2024
6d3272f
Update workflow flutter version
Sep 7, 2024
dda4467
Update build flutter version
Sep 7, 2024
db793af
Update pubspec flutter sdk version
Sep 7, 2024
286a744
Change sdk version
Sep 7, 2024
e293aa8
Improve loggin
Sep 7, 2024
46b2d23
Add additional logs
Sep 7, 2024
3d06281
Add more logs
Sep 7, 2024
e5c58b6
Add quick actions
Sep 8, 2024
08ede4d
Merge pull request #327 from vicolo-dev/release/0.5.2
AhsanSarwar45 Sep 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- uses: subosito/flutter-action@v2
with:
flutter-version: "3.19.3"
flutter-version: "3.22.2"
channel: 'stable'
cache: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- uses: subosito/flutter-action@v2
with:
flutter-version: "3.19.3"
flutter-version: "3.22.2"
channel: 'stable'
cache: false

Expand Down
10 changes: 6 additions & 4 deletions fastlane/metadata/android/en-US/changelogs/251.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
✨ Enhancements

* Added option to turn on foreground notification to keep app alive. Goto General > Display > Reliability > Show Foreground Notification
* Added option to turn on foreground notification to keep app alive. Go to General > Display > Reliability > Show Foreground Notification
* Added current lap card for stopwatch. Now you can view the current lap time in real time.
* Added option to show next alarm in filters
* Added option to show next alarm in filters. Go to Settings > Alarms > Filters > Show Next Alarm.
* Changed timer and stopwatch notification so time appears in title
* Updated translations

🐛 Fixes

* Fixed range schedule automatically getttin disabled

* Fixed range schedule automatically getting disabled
* Fixed timer dismiss actions being mapped incorrectly
* Fixed timer add length not working correctly after timer rings

14 changes: 14 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/252.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
✨ Enhancements

* Added option to turn on foreground notification to keep app alive. Go to General > Display > Reliability > Show Foreground Notification
* Added current lap card for stopwatch. Now you can view the current lap time in real time.
* Added option to show next alarm in filters. Go to Settings > Alarms > Filters > Show Next Alarm.
* Changed timer and stopwatch notification so time appears in title
* Updated translations

🐛 Fixes

* Fixed range schedule automatically getting disabled
* Fixed timer dismiss actions being mapped incorrectly
* Fixed timer add length not working correctly after timer rings

14 changes: 14 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/253.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
✨ Enhancements

* Added option to turn on foreground notification to keep app alive. Go to General > Display > Reliability > Show Foreground Notification
* Added current lap card for stopwatch. Now you can view the current lap time in real time.
* Added option to show next alarm in filters. Go to Settings > Alarms > Filters > Show Next Alarm.
* Changed timer and stopwatch notification so time appears in title
* Updated translations

🐛 Fixes

* Fixed range schedule automatically getting disabled
* Fixed timer dismiss actions being mapped incorrectly
* Fixed timer add length not working correctly after timer rings

14 changes: 13 additions & 1 deletion lib/alarm/data/alarm_settings_schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import 'package:clock_app/settings/types/setting.dart';
import 'package:clock_app/settings/types/setting_enable_condition.dart';
import 'package:clock_app/settings/types/setting_group.dart';
import 'package:clock_app/timer/types/time_duration.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

Expand Down Expand Up @@ -209,6 +210,15 @@ SettingGroup alarmSettingsSchema = SettingGroup(
100,
100,
unit: "%"),
SliderSetting(
"task_volume",
(context) => AppLocalizations.of(context)!.volumeWhileTasks,
0,
100,
50,
unit: "%",
getDescription: (context) => "Percentage of base volume",
),
SwitchSetting(
"Rising Volume",
(context) => AppLocalizations.of(context)!.risingVolumeSetting,
Expand Down Expand Up @@ -294,7 +304,9 @@ SettingGroup alarmSettingsSchema = SettingGroup(
ListSetting<AlarmTask>(
"Tasks",
(context) => AppLocalizations.of(context)!.tasksSetting,
[],
kDebugMode
? [AlarmTask(AlarmTaskType.math), AlarmTask(AlarmTaskType.sequence)]
: [],
alarmTaskSchemasMap.keys.map((key) => AlarmTask(key)).toList(),
addCardBuilder: (item) => AlarmTaskCard(task: item, isAddCard: true),
cardBuilder: (item, [onDelete, onDuplicate]) => AlarmTaskCard(
Expand Down
41 changes: 25 additions & 16 deletions lib/alarm/logic/alarm_isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'dart:ui';
import 'package:clock_app/common/types/json.dart';
import 'package:clock_app/common/types/notification_type.dart';
import 'package:clock_app/common/utils/list_storage.dart';
import 'package:clock_app/debug/logic/logger.dart';
import 'package:clock_app/system/logic/initialize_isolate.dart';
import 'package:clock_app/timer/types/time_duration.dart';
import 'package:clock_app/timer/types/timer.dart';
import 'package:flutter/foundation.dart';
import 'package:clock_app/alarm/logic/schedule_alarm.dart';
Expand All @@ -21,18 +21,23 @@ import 'package:clock_app/timer/utils/timer_id.dart';

const String stopAlarmPortName = "stopAlarmPort";
const String updatePortName = "updatePort";
const String setAlarmVolumePortName = "setAlarmVolumePort";

@pragma('vm:entry-point')
void triggerScheduledNotification(int scheduleId, Json params) async {
debugPrint("Alarm triggered: $scheduleId");
FlutterError.onError = (FlutterErrorDetails details) {
logger.f(details.exception.toString());
};

logger.i("Alarm isolate triggered $scheduleId");
// print("Alarm Trigger Isolate: ${Service.getIsolateID(Isolate.current)}");
if (params == null) {
debugPrint("Params was null when triggering alarm");
logger.e("Params was null when triggering alarm");
return;
}

if (params['type'] == null) {
debugPrint("Params Type was null when triggering alarm");
logger.e("Params Type was null when triggering alarm");
return;
}

Expand Down Expand Up @@ -73,10 +78,9 @@ void stopScheduledNotification(List<dynamic> 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;
}

Expand All @@ -100,6 +104,7 @@ void triggerAlarm(int scheduleId, Json params) async {
now.millisecondsSinceEpoch >
alarm.currentScheduleDateTime!.millisecondsSinceEpoch +
1000 * 60 * 60) {
logger.i("Skipping alarm $scheduleId");
return;
}

Expand All @@ -118,6 +123,14 @@ void triggerAlarm(int scheduleId, Json params) async {
RingtonePlayer.playAlarm(alarm);
RingingManager.ringAlarm(scheduleId);

ReceivePort receivePort = ReceivePort();
IsolateNameServer.removePortNameMapping(setAlarmVolumePortName);
IsolateNameServer.registerPortWithName(
receivePort.sendPort, setAlarmVolumePortName);
receivePort.listen((message) {
setVolume(message[0]);
});

String timeFormatString = await loadTextFile("time_format_string");
String title = alarm.label.isEmpty ? "Alarm Ringing..." : alarm.label;

Expand All @@ -137,10 +150,11 @@ void triggerAlarm(int scheduleId, Json params) async {
}

void setVolume(double volume) {
RingtonePlayer.setVolume(volume);
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);
Expand All @@ -158,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) {
Expand Down Expand Up @@ -194,18 +209,12 @@ 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) {
await scheduleSnoozeAlarm(
scheduleId,
Duration(minutes: timer.addLength.floor()),
ScheduledNotificationType.timer,
"stopTimer(): ${timer.addLength.floor()} added to timer",
);
updateTimerById(scheduleId, (timer) async {
timer.setTime(const TimeDuration(minutes: 1));
await timer.start();
await timer.snooze();
});
} else if (action == AlarmStopAction.dismiss) {
// If there was an alarm already ringing when the timer was triggered, we
Expand Down
32 changes: 20 additions & 12 deletions lib/alarm/logic/alarm_time.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,34 @@ import 'package:clock_app/common/utils/date_time.dart';
// Calculates the DateTime when the provided `time` will next occur
DateTime getDailyAlarmDate(
Time time, {
DateTime? scheduledDate,
DateTime? scheduleStartDate,
int interval = 1,
}) {
if (scheduledDate != null && scheduledDate.isAfter(DateTime.now())) {
return DateTime(scheduledDate.year, scheduledDate.month, scheduledDate.day,
time.hour, time.minute, time.second);
if (scheduleStartDate != null && scheduleStartDate.isAfter(DateTime.now())) {
return DateTime(scheduleStartDate.year, scheduleStartDate.month,
scheduleStartDate.day, time.hour, time.minute, time.second);
}

// If a date has not been provided, assume it to be today
scheduledDate = DateTime.now();
DateTime scheduleDate = DateTime.now();
DateTime alarmTime;

if (time.toHours() > scheduledDate.toHours()) {
if (time.toHours() > scheduleDate.toHours()) {
// If the time is in the future, set the alarm for today
alarmTime = DateTime(scheduledDate.year, scheduledDate.month,
scheduledDate.day, time.hour, time.minute, time.second);
alarmTime = DateTime(scheduleDate.year, scheduleDate.month,
scheduleDate.day, time.hour, time.minute, time.second);
} else {
// If the time has already passed, set the alarm for tomorrow
DateTime nextDateTime = scheduledDate.add(const Duration(days: 1));
alarmTime = DateTime(nextDateTime.year, nextDateTime.month,
nextDateTime.day, time.hour, time.minute, time.second);
// If the time has already passed, set the alarm for next occurence
if (scheduleStartDate != null) {
scheduleDate = scheduleStartDate;
}

while (scheduleDate.isBefore(DateTime.now())) {
scheduleDate = scheduleDate.add(Duration(days: interval));
}

alarmTime = DateTime(scheduleDate.year, scheduleDate.month,
scheduleDate.day, time.hour, time.minute, time.second);
}

return alarmTime;
Expand Down
11 changes: 9 additions & 2 deletions lib/alarm/logic/schedule_alarm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:clock_app/common/types/schedule_id.dart';
import 'package:clock_app/common/utils/date_time.dart';
import 'package:clock_app/common/utils/list_storage.dart';
import 'package:clock_app/common/utils/time_of_day.dart';
import 'package:clock_app/debug/logic/logger.dart';
import 'package:clock_app/settings/data/settings_schema.dart';

Future<void> scheduleAlarm(
Expand Down Expand Up @@ -68,7 +69,7 @@ Future<void> scheduleAlarm(
scheduleIds.add(ScheduleId(id: scheduleId));
await saveList<ScheduleId>(name, scheduleIds);

//
//
// if (type == ScheduledNotificationType.alarm && !snooze) {
// }
//
Expand All @@ -88,8 +89,10 @@ Future<void> scheduleAlarm(
'type': type.name,
},
);

logger.i('Scheduled alarm $scheduleId for $startDate of type ${type.name}: $description');
}
}
}

Future<void> cancelAlarm(int scheduleId, ScheduledNotificationType type) async {
if (!Platform.environment.containsKey('FLUTTER_TEST')) {
Expand All @@ -113,6 +116,8 @@ Future<void> cancelAlarm(int scheduleId, ScheduledNotificationType type) async {
}

AndroidAlarmManager.cancel(scheduleId);

logger.i('Canceled alarm $scheduleId of type ${type.name}');
}
}

Expand All @@ -128,4 +133,6 @@ Future<void> scheduleSnoozeAlarm(int scheduleId, Duration delay,
if (!Platform.environment.containsKey('FLUTTER_TEST')) {
await createSnoozeNotification(scheduleId, DateTime.now().add(delay));
}

logger.i('Scheduled snooze alarm $scheduleId for ${DateTime.now().add(delay)} with type ${type.name}: $description');
}
10 changes: 9 additions & 1 deletion lib/alarm/screens/alarm_notification_screen.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import 'dart:ui';

import 'package:clock_app/alarm/logic/alarm_isolate.dart';
import 'package:clock_app/alarm/logic/update_alarms.dart';
import 'package:clock_app/alarm/utils/alarm_id.dart';
import 'package:clock_app/alarm/types/alarm.dart';
import 'package:clock_app/common/types/notification_type.dart';
import 'package:clock_app/common/widgets/clock/clock.dart';
import 'package:clock_app/debug/logic/logger.dart';
import 'package:clock_app/navigation/types/routes.dart';
import 'package:clock_app/notifications/types/fullscreen_notification_manager.dart';
import 'package:clock_app/navigation/types/alignment.dart';
Expand Down Expand Up @@ -37,6 +41,8 @@ class _AlarmNotificationScreenState extends State<AlarmNotificationScreen> {
void _setNextWidget() {
setState(() {
if (_currentIndex < 0) {
IsolateNameServer.lookupPortByName(setAlarmVolumePortName)
?.send([alarm.volume]);
_currentWidget = actionWidget;
} else if (_currentIndex >= alarm.tasks.length) {
if (widget.onPop != null) {
Expand All @@ -47,6 +53,8 @@ class _AlarmNotificationScreenState extends State<AlarmNotificationScreen> {
widget.dismissType, ScheduledNotificationType.alarm);
}
} else {
IsolateNameServer.lookupPortByName(setAlarmVolumePortName)
?.send([alarm.volume * alarm.volumeDuringTasks / 100]);
// RingtonePlayer.setVolume(0);
_currentWidget = alarm.tasks[_currentIndex].builder(_setNextWidget);
}
Expand Down Expand Up @@ -81,7 +89,7 @@ class _AlarmNotificationScreenState extends State<AlarmNotificationScreen> {
snoozeLabel: "Snooze",
);

debugPrint(e.toString());
logger.e(e.toString());
}

_setNextWidget();
Expand Down
Loading
Loading