Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

Added CMMotionActivity support #53

Merged
merged 4 commits into from
Aug 11, 2015
Merged

Added CMMotionActivity support #53

merged 4 commits into from
Aug 11, 2015

Conversation

fotiDim
Copy link

@fotiDim fotiDim commented Jul 28, 2015

As promised this is my CMMotionActivity support contribution. I had to make a few minor changes to the way you present the dialog for the permissions to avoid a "flash" that was happening when all permissions were satisfied and the dialog shouldn't appear.

@nickoneill
Copy link
Owner

This looks good, thanks! Where was the flash being seen? Device or sim?

@felix-dumit
Copy link
Contributor

Now that I'm integrating this into my app I'm also experiencing the flash issue with bluetooth.
The problem with bluetooth, and from what I saw, coremotion as well, is that to get the status you need to perform an async request. So when the show method is called the status is still .Unknown and therefore the alert is shown, but shortly afterwards (I found that for bluetooth about 10ms) the status is updated and the alert is dismissed (if previously accepted).

I've been thinking of a few different ways to solve this. Would be great to have some feedback.

  • The first measure we can take is on the addPermission method, as soon as bluetooth or coremotion are added, we can trigger the status update - so there is some extra time from that point until show is called.
  • Then we can either do what is already done here - delay the alert by some time in order for all statuses to update, or we can modify the statusForBluetooth (and motion) methods so they become synchronous and therefore wait for the status to be updated. <- This would involve moving a significant part of the code to a background thread and maybe making some methods require completion closures.
  • We can also delay the alert while we are still waiting for either bluetooth or coremotion to complete. (instead of a fixed amount of time).

@fotiDim
Copy link
Author

fotiDim commented Aug 1, 2015

Sorry I forgot to answer about the flash issue. Indeed this was happening when the dialog should not appear (conditions met) because the motion status check was an async request. This gave the time to the dialog to appear momentarily and then disappear resulting in a flash effect.

The way I solved this was:

  • The initial position of the dialog before transitioning is outside the visible window
  • I set a few seconds delay before starting the transition

@felix-dumit Do you experience the flash with my pull request?

@felix-dumit
Copy link
Contributor

@Navideck-fotis I did not try it, but from the changes you made I'm fairly confident it would solve it.

Edit: @Navideck-fotis It didn't work for me with bluetooth. I ended up doing a different approach, I think it would be a good idea to do something similar for motion as well.
You can see my changes at #57

@nickoneill
Copy link
Owner

I like the way this is handled in #57 versus relying on the implementation in the app (which is what I think you're suggested?). It should be simple enough to duplicate the async detection similar to bluetooth. Fix that up and we can pull this in.

@fotiDim
Copy link
Author

fotiDim commented Aug 10, 2015

@nickoneill Done!
@felix-dumit Nice implementation! It should be bullet-proof this way.

I did my testing and everything works the same for me as before.

nickoneill added a commit that referenced this pull request Aug 11, 2015
Added CMMotionActivity support
@nickoneill nickoneill merged commit 0817658 into nickoneill:master Aug 11, 2015
@nickoneill
Copy link
Owner

Thanks!

@nickoneill nickoneill mentioned this pull request Aug 21, 2015
6 tasks
@bre7 bre7 added this to the 1.0 milestone Aug 21, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants