Fix beacon distance callouts at geofence transitions #109
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.
There was a very subtle issue with how I implemented the configurable beacon immediate-vicinity distance (#102 ). The original non-configurable implementation had two distance threshold constants, one for entering the vicinity (15m) and one for exiting (30m). The setting I added was only for the first constant, which meant you could set an enter-vicinity distance greater than the exit-vicinity distance. When this was true, the region considered "near" the beacon was no longer a circle drawn around the location, but a donut-shaped area. This led to the weird callout behavior @fraziercarr observed, where walking towards the beacon led to repeated callouts of "Beacon within x units," which would be played each time the user crossed in or out of the donut. I've now updated it so that the exit-vicinity distance is always set to the enter-vicinity distance plus 15m, ensuring the exit-vicinity distance is always the outer of the two circles.
Fixing this revealed another bug. When the enter-vicinity distance was set to larger values (25m+), when walking away from the beacon, you would hear something like "Beacon: 110 feet" before "Beacon within 80ft," which was very confusing since it implied you were walking in the opposite direction. The periodic "Beacon: 110 feet" distance callouts were being prioritized over the "Beacon within 80ft" callout played only when entering or exiting the beacon vicinity. This was because large vicinity radii exceed the normal interval at which distance callouts are announced (50m), and periodic distance callouts are disabled when you are within the beacon vicinity, so the periodic distance callouts were overdue by the time you exited the beacon vicinity. I addressed this by only playing the "Beacon within x units" callouts when entering (not exiting) the beacon vicinity.