Parse per-notification vibration patterns from the notification body #71
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.
It turns out Android can't actually set per-notification vibration patterns since Android 8. So the code that's currently in the app that tries to grab the vibration pattern from the notification just always returns null. The only way to set custom vibration patterns in modern Android is by setting the notification channel's vibration pattern. And other apps aren't allowed to read this pattern. This is a (perhaps a little hacky) workaround for that. If a notification body contains a
|symbol followed by a comma-separated list of numbers, it'll parse that as a vibration pattern instead and remove it from the body when displaying on the watch. If it can't parse it, then it will leave the body and vibration pattern untouched.