Add custom alarm sounds#699
Open
bjorkert wants to merge 4 commits into
Open
Conversation
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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds user-imported alarm sounds alongside the built-in tones.