jpsim / JPSVolumeButtonHandler

JPSVolumeButtonHandler provides an easy block interface to hardware volume buttons on iOS devices. Perfect for camera apps!
MIT License
333 stars 90 forks source link

JPSVolumeButtonHandler Added feature to allow the handler to only res… #45

Closed apple-ihack-geek closed 7 years ago

apple-ihack-geek commented 7 years ago

…pond to exact button presses, rather than just responding to any change in volume.

  1. Basically, our app and another app were having some major interference. What we do when we received a volume button caused another app to change the volume of the phone, but not by the same amount. However, because this is a volume change, one button press would trigger another and so on. This PR adds a new feature, where an app, if they call useExactJumpsOnly:YES, the handler will only respond to jumps that are exactly the 6.25% that actual button presses are (+/- .05% since these are floating point values).

  2. I cleaned up the logging a little.

apple-ihack-geek commented 7 years ago

@jpsim Hey, I just wanted to take a moment and thank you for creating and maintaining this library so far. It's been very helpful.
I don't mean to pushy or anything, but we're creating a release candidate on Friday, and I would love to have this fix in our code first. I'll maintain my fork if I have to, but I would prefer to keep it pointed here (to save myself some time in the future).
Thanks again.

jpsim commented 7 years ago

Sure, looks good to me, though I really can't take much credit for "continuing" to maintain this. I haven't used this myself in years and all contributions come from more active users like yourself.

That being said, this looks good to me, or at the very least this shouldn't do any harm to existing users.

I'll merge and produce a release asap. Thanks!

jpsim commented 7 years ago

1.0.4 has been tagged in this repo: https://github.com/jpsim/JPSVolumeButtonHandler/releases/tag/1.0.4

and pushed to CocoaPods trunk: https://github.com/CocoaPods/Specs/commit/2af491ec3c5502400e64ae9f1c5a32eeceaf55f9

jpeyer commented 7 years ago

One instance where this logic doesn't work is if the volume is already at min/max. It will get adjusted up/down to 0.00001f or 0.99999f, which means down/up in those cases won't trigger because the .00001 difference is < 0.0625.

I am not using this new functionality, so it isn't affecting me, but I thought I'd mention it @apple-ihack-geek

apple-ihack-geek commented 7 years ago

Thanks, yes, our testers did end up realizing that, but sadly thanks to https://github.com/jpsim/JPSVolumeButtonHandler/issues/46 I had to pull out this feature from our app entirely. If I ever do end of using this library again, I do plan to address that.

apple-ihack-geek commented 7 years ago

@jpeyer Thanks, I've addressed this in my new PR https://github.com/jpsim/JPSVolumeButtonHandler/pull/47