Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plyer android proximity sensor #287

Merged
merged 8 commits into from
Mar 16, 2017

Conversation

sumitmadhwani
Copy link
Contributor

Proximity sensor api for android platform.

The work is based on #159 and I have done some additional changes to bring it in merge-able state.

Issue in the original pr - Once the proximity sensor is enabled, after covering the sensor, it should display yes meaning sensor has detected a object instead it was always displaying no irrespective of whether it is covered or not. Maybe this was due to not returning correct value by _get_proximity function.

I made the required changes and after that, the example is working something like this -
Initially

screenshot_2017-02-14-00-20-08-144_org test plyer proximity

Just after pressing enable

screenshot_2017-02-14-00-20-18-707_org test plyer proximity

After covering the top part of mobile where sensor is located

screenshot_2017-02-14-00-20-46-977_org test plyer proximity

Additionally, rebasing is also done since the original pr is 117 commits behind master.

Tested on -
Devices - Xiaomi Mi 4i, Samsung Galaxy S6 Edge
Toolchain - old and new both
Android api - 19
Android sdk - 24

def _disable(self, **kwargs):
if self.listener:
self.listener.disable()
delattr(self, 'listener')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will crash if the sensor is enabled and disabled then either enabled or disabled again.

class Test():
    prop = None


var = Test()
delattr(var, 'prop')
print(var.prop)

It may be better to just use self.listener = None.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch that, i've made a mistake. 😋

Of course it works:

class Test():
    prop = None

    def set(self):
        self.prop = 1

    def delete(self):
        delattr(self, 'prop')


var = Test()
var.set()
var.delete()

print(var.prop)

@dessant dessant merged commit 8fea193 into kivy:master Mar 16, 2017
@dessant dessant mentioned this pull request Mar 16, 2017
@sumitmadhwani
Copy link
Contributor Author

Thanks @dessant

@sumitmadhwani sumitmadhwani deleted the plyer_android_proximity branch March 16, 2017 19:17
@dessant
Copy link
Contributor

dessant commented Mar 16, 2017

@Malverick, thanks for the fixes. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants