Commit cdaa672
authored
Add custom alarm sounds (#699)
* Add custom alarm sounds
Users can now import their own audio for alarm tones via the tone picker
(document picker, `.audio` UTType) or by dropping files into the app's
Documents folder from the Files app. Imported files are copied into
`Documents/CustomSounds/`, validated with AVAudioPlayer, and capped at
2 MB / 30 s.
SoundFile is now an enum with `.builtin(String)` and `.custom(UUID)`
cases. Built-in values encode as a bare string so existing stored alarms
keep loading; custom values encode as a keyed object. Static aliases
(`.indeed`, `.wrongAnswer`, …) preserve all existing call sites.
AlarmSound.setSoundFile now resolves built-in via the bundle and custom
via CustomSoundStore, and falls back to the default built-in with a log
when a file is missing (deleted custom sound, etc.) instead of crashing.
* Harden custom alarm sound imports
Validate files dropped into Documents in place before moving them into the
store, applying the same size, duration, and format checks as the in-app
importer. This prevents a user's file from being deleted when it fails the
audio check and stops oversized files from bypassing the caps.
Reset the alarm's sound to the fallback built-in when the selected custom
sound is deleted, and avoid rewriting the index when nothing changed.
* Prevent duplicate custom sound when importing from shared folder
Move the picked file into the store instead of copying when it already lives
in the app's shared Documents folder, so absorbDroppedFiles() doesn't re-ingest
the leftover original as a second entry. Validate before the file operation so a
rejected import never deletes the user's original.1 parent ac18d68 commit cdaa672
6 files changed
Lines changed: 594 additions & 130 deletions
File tree
- LoopFollow.xcodeproj
- LoopFollow
- Alarm
- AlarmEditing/Components
- Controllers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| 264 | + | |
264 | 265 | | |
265 | 266 | | |
266 | 267 | | |
| |||
727 | 728 | | |
728 | 729 | | |
729 | 730 | | |
| 731 | + | |
730 | 732 | | |
731 | 733 | | |
732 | 734 | | |
| |||
1434 | 1436 | | |
1435 | 1437 | | |
1436 | 1438 | | |
| 1439 | + | |
1437 | 1440 | | |
1438 | 1441 | | |
1439 | 1442 | | |
| |||
2468 | 2471 | | |
2469 | 2472 | | |
2470 | 2473 | | |
| 2474 | + | |
2471 | 2475 | | |
2472 | 2476 | | |
2473 | 2477 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| |||
Lines changed: 97 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
114 | 119 | | |
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
118 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
119 | 130 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 131 | + | |
124 | 132 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
133 | 145 | | |
134 | | - | |
135 | 146 | | |
136 | 147 | | |
137 | 148 | | |
| |||
144 | 155 | | |
145 | 156 | | |
146 | 157 | | |
| 158 | + | |
147 | 159 | | |
148 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
149 | 230 | | |
| 231 | + | |
| 232 | + | |
150 | 233 | | |
151 | 234 | | |
152 | 235 | | |
0 commit comments