Skip to content

Commit

Permalink
Feature: Changed implementation of custom ringtone, and added it on a…
Browse files Browse the repository at this point in the history
… per alarm basis (#203)

* adding the writing and reading from storage permissions

* adding the ringtoneName field to the alarmModel

* adding the ringtoneModel

* adding the counter status enum

* adding the fastHash and updating counter of ringtone usage methods

* removing the ringtone status methods

* adding the methods for creating, updating, and deleting ringtones

* deleting the custom ringtone file from settings

* adding the choose ringtone tile

* modifying the play and stop methods calling

* removing the ringtone methods from settings controller

* removing the custom ringtone tile from settings view

* updating the counter usage of ringtone on deleting an alarm on home screen

* adding the ringtone methods to add or update alarm controller

* adding the choose ringtone tile file

* resolving the merge conflict

* custom ringtone file deleted for resolving merge conflicts

* handling the shared alarm edge case

* changing the ringtoneName field to alarmRecord
  • Loading branch information
superiorsd10 authored Dec 15, 2023
1 parent 00208fb commit b3fd247
Show file tree
Hide file tree
Showing 18 changed files with 952 additions and 473 deletions.
2 changes: 2 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>

<application
tools:replace="android:label"
Expand Down
5 changes: 5 additions & 0 deletions lib/app/data/models/alarm_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AlarmModel {
late String label;
late bool isOneTime;
late int snoozeDuration;
late String ringtoneName;
@ignore
Map? offsetDetails;

Expand Down Expand Up @@ -75,6 +76,7 @@ class AlarmModel {
required this.label,
required this.isOneTime,
required this.snoozeDuration,
required this.ringtoneName,
});

AlarmModel.fromDocumentSnapshot({
Expand Down Expand Up @@ -126,6 +128,7 @@ class AlarmModel {
qrValue = documentSnapshot['qrValue'];
isShakeEnabled = documentSnapshot['isShakeEnabled'];
shakeTimes = documentSnapshot['shakeTimes'];
ringtoneName = documentSnapshot['ringtoneName'];
}

AlarmModel.fromMap(Map<String, dynamic> alarmData) {
Expand Down Expand Up @@ -162,6 +165,7 @@ class AlarmModel {
shakeTimes = alarmData['shakeTimes'];
label = alarmData['label'];
isOneTime = alarmData['isOneTime'];
ringtoneName = alarmData['ringtoneName'];
}

AlarmModel.fromJson(String alarmData, UserModel? user) {
Expand Down Expand Up @@ -203,6 +207,7 @@ class AlarmModel {
'isShakeEnabled': alarmRecord.isShakeEnabled,
'shakeTimes': alarmRecord.shakeTimes,
'snoozeDuration': alarmRecord.snoozeDuration,
'ringtoneName': alarmRecord.ringtoneName,
};

if (alarmRecord.isSharedAlarmEnabled) {
Expand Down
213 changes: 198 additions & 15 deletions lib/app/data/models/alarm_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions lib/app/data/models/ringtone_model.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import 'package:isar/isar.dart';
import 'package:ultimate_alarm_clock/app/utils/utils.dart';

part 'ringtone_model.g.dart';

@collection
class RingtoneModel {
Id isarId = Isar.autoIncrement;
late String ringtoneName;
late List<int> ringtoneData;
late String ringtonePath;
late int currentCounterOfUsage;

Id get isarId => Utils.fastHash(ringtoneName);

RingtoneModel({
required this.ringtoneName,
required this.ringtoneData,
required this.ringtonePath,
required this.currentCounterOfUsage,
});
}
Loading

0 comments on commit b3fd247

Please sign in to comment.